Compare commits

...

81 Commits

Author SHA1 Message Date
26b955a1e8 Add networking block 2021-05-01 23:01:36 -07:00
bb17ad6135 Change Base directory to just the python stuff 2021-04-30 00:38:42 +00:00
40c7d020d2 Add sonarqube-check 2021-04-30 00:26:12 +00:00
9b5adba3ed Add sonar-project.properties 2021-04-30 00:19:32 +00:00
semantic-release-bot
73740ffa39 chore(release): 1.7.3 [skip ci]
## [1.7.3](https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt/compare/v1.7.2...v1.7.3) (2021-04-12)

### Bug Fixes

* Empty commit to get recent changes into build (last commit should've been labeled this) ([e513752](e513752c46))
2021-04-12 22:11:57 +00:00
Evan Richardson
e513752c46 fix: Empty commit to get recent changes into build (last commit should've been labeled this) 2021-04-12 14:53:10 -07:00
evanrich
cfb392dc6a refactor: Add new docker labels to better identify container properties 2021-04-09 17:14:51 -07:00
f3f78c4ad5 docs: Fix badges formatting, also add docker version and # of pulls 2021-04-08 23:58:44 +00:00
d1723db798 docs: Add build status 2021-04-08 23:49:27 +00:00
ba8486017a docs: add dependency badge 2021-04-08 22:50:03 +00:00
37d8b17076 docs: add semantic-release badge 2021-04-08 22:29:53 +00:00
semantic-release-bot
da83d88229 chore(release): 1.7.2 [skip ci]
## [1.7.2](https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt/compare/v1.7.1...v1.7.2) (2021-04-08)

### Bug Fixes

* Cleanup CHANGELOG.md since using new semantic-release format ([a72ac7a](a72ac7a1df))
* fix asset info for git commit ([00c95c4](00c95c42ea))
2021-04-08 22:17:41 +00:00
evanrich
00c95c42ea fix: fix asset info for git commit 2021-04-08 15:16:21 -07:00
evanrich
a72ac7a1df fix: Cleanup CHANGELOG.md since using new semantic-release format
fix: Remove package-lock.json file (only commit CHANGELOG.md)
2021-04-08 15:11:32 -07:00
semantic-release-bot
ffbde1eff5 chore(release): 1.7.1 [skip ci]
## [1.7.1](https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt/compare/v1.7.0...v1.7.1) (2021-04-08)

### Bug Fixes

* refactor Dockerfile to improve build ([40ac8c5](40ac8c5ada))
2021-04-08 22:06:11 +00:00
1e58da7572 Merge branch 'dev' into 'master'
fix: refactor Dockerfile to improve build

See merge request erichardson/py-eagle-mqtt!2
2021-04-08 22:04:41 +00:00
evanrich
40ac8c5ada fix: refactor Dockerfile to improve build 2021-04-08 14:59:58 -07:00
evanrich
2c49af0f32 Merge branch 'master' of https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt 2021-04-08 14:47:21 -07:00
evanrich
a4c715068d Fix: Commit 3.9.4-alpine3.13 base change 2021-04-08 14:44:39 -07:00
91b6464e8c build: add missing npm install for git plugin 2021-04-08 21:34:14 +00:00
b9ad4e8ec1 build: add git plugin to sematic-release config file 2021-04-08 21:31:46 +00:00
evanrich
ac8c039b33 feat: remove astral again to try and fix semver (again?) 2021-04-07 15:12:30 -07:00
Evan Richardson
46cc86ed0b revert: add astral back in due to mistake in release system 2021-04-07 15:08:19 -07:00
Evan Richardson
3db668ff98 feat: remove astral package, since it actually isn't being used 2021-04-07 15:00:27 -07:00
evanrich
99661058bd Add Semver release mechanism 2021-04-06 20:59:01 -07:00
evanrich
575e2fe6ce Fix tagging issue 2021-04-06 15:31:09 -07:00
evanrich
10c5443914 Fix dockerhub push issue 2021-04-06 15:30:14 -07:00
evanrich
058638eb83 Add README
update CHANGELOG
remove extra section of CI file
2021-04-06 15:21:31 -07:00
evanrich
8cb86673ed 1.6.8 release 2021-04-06 15:18:26 -07:00
evanrich
6b500de774 Added CHANGELOG
Refactored ci file
2021-04-06 15:17:26 -07:00
6b26f12b9a Pin base image version 2021-04-04 03:35:12 +00:00
08b304be38 Update README.md 2021-04-04 01:24:44 +00:00
Evan Richardson
e6f6342027 Add missing defusedxml package 2021-04-03 18:19:15 -07:00
Evan Richardson
197c762909 Add ignore rule for assert test 2021-04-02 15:00:44 -07:00
e4a88ea26b Fix SAST errors 2021-04-02 21:39:06 +00:00
cadbfac97e Replace xml.etree with defusedxml for SAST scans 2021-04-02 21:36:56 +00:00
0f2098d884 Merge branch 'set-sast-config-1' into 'master'
Set .gitlab-ci.yml to enable or configure SAST

See merge request erichardson/py-eagle-mqtt!1
2021-04-02 21:27:26 +00:00
8f25241cc8 refactor ci file 2021-04-02 21:25:57 +00:00
0390fd17e7 Update .gitlab-ci.yml 2021-04-02 21:20:22 +00:00
11e271a368 Set .gitlab-ci.yml to enable or configure SAST 2021-04-02 21:14:57 +00:00
30d300c7fd Update Dockerfile 2021-03-05 05:42:56 +00:00
1cf7d117c7 Update .gitlab-ci.yml file 2021-03-04 22:55:39 +00:00
7e2fd67729 Update .gitlab-ci.yml file 2021-03-04 22:52:26 +00:00
245ebc8c2d Update .gitlab-ci.yml file 2021-03-04 22:47:24 +00:00
119f854de5 Update .gitlab-ci.yml file 2021-03-04 22:40:46 +00:00
Evan Richardson
c2925e425d Merge branch 'master' of https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt 2021-03-04 14:36:29 -08:00
Evan Richardson
b394aa9ee8 Add stage to push to docker hub 2021-03-04 14:36:24 -08:00
e6231d837f Update .gitlab-ci.yml file 2021-03-04 22:18:21 +00:00
Evan Richardson
dfb700aae4 move base image and variables out 2021-03-04 14:17:46 -08:00
Evan Richardson
e9b52ec54f Forgot docker build directory 2021-03-04 14:14:02 -08:00
Evan Richardson
695c4b3655 Add push stage 2021-03-04 14:12:49 -08:00
Evan Richardson
7b80ce48e1 Add feature flag to override registry 2021-03-04 14:04:59 -08:00
Evan Richardson
ff72639dbb Fix variable name for MQTT_PASSWORD
update deployment api version
2021-03-04 14:02:30 -08:00
096225b537 Update dependencies to latest version 2021-03-04 21:51:04 +00:00
eb78e4bd7c Update .gitlab-ci.yml file 2021-03-03 02:09:17 +00:00
44ff9a7c9a Update .gitlab-ci.yml file 2021-03-03 02:08:10 +00:00
2ae6ccabb9 Update .gitlab-ci.yml file 2021-03-03 01:44:28 +00:00
df9bbd1d47 Update .gitlab-ci.yml file 2021-03-03 01:41:34 +00:00
41c82e52b6 Update .gitlab-ci.yml file 2021-03-03 01:41:19 +00:00
44fef1d926 Update .gitlab-ci.yml file 2021-03-03 01:40:03 +00:00
f0a1401018 Update .gitlab-ci.yml file 2021-03-03 01:37:09 +00:00
54a838c2da Update .gitlab-ci.yml file 2021-03-03 01:19:39 +00:00
550ba6df4a Update .gitlab-ci.yml file 2021-03-03 01:18:28 +00:00
620ca572ff Update .gitlab-ci.yml file 2021-03-03 01:13:41 +00:00
4674578d88 Update .gitlab-ci.yml file 2021-03-03 01:12:58 +00:00
9913d0bcb3 Update .gitlab-ci.yml file 2021-03-03 01:10:18 +00:00
b24144cb4b Update .gitlab-ci.yml file 2021-03-03 01:08:55 +00:00
f568d5ba5b Update .gitlab-ci.yml file 2021-03-03 01:08:52 +00:00
6e3673fced Update .gitlab-ci.yml file 2021-03-03 01:07:00 +00:00
f1a87650f0 Update .gitlab-ci.yml file 2021-03-03 01:04:41 +00:00
29a221f449 Update .gitlab-ci.yml file 2021-03-03 01:03:01 +00:00
2f556ceadc Update .gitlab-ci.yml file 2021-03-03 01:01:50 +00:00
5e7d61c499 Update .gitlab-ci.yml file 2021-03-03 01:00:37 +00:00
7f2a4e40d6 Update .gitlab-ci.yml file 2021-03-03 00:58:53 +00:00
2052bcb96c Update .gitlab-ci.yml file 2021-03-03 00:55:10 +00:00
9f4cfceee7 Update .gitlab-ci.yml file 2021-03-03 00:55:06 +00:00
88ac743dda Update .gitlab-ci.yml file 2021-03-03 00:55:03 +00:00
631ee88812 Update .gitlab-ci.yml 2021-03-03 00:53:57 +00:00
4565a6f7ba Update .gitlab-ci.yml 2019-12-21 03:18:46 +00:00
ede4bb616d Update .gitlab-ci.yml 2019-12-21 03:16:55 +00:00
f30ae06f45 Update .gitlab-ci.yml 2019-12-21 03:14:49 +00:00
14 changed files with 328 additions and 129 deletions

View File

@@ -1,36 +1,112 @@
# This file is a template, and might need editing before it works on your project. # You can override the included template(s) by including variable overrides
# Official docker image. # See https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings
image: docker:latest # Note that environment variables can be set in several places
# See https://docs.gitlab.com/ee/ci/variables/#priority-of-environment-variables
services:
- docker:18.09-dind
stages: stages:
- build - test
- build
- push_local
- release
- push_dockerhub
variables: .docker_base:
DOCKER_HOST: tcp://localhost:2375 image: docker:18.09.7-dind
DOCKER_DRIVER: overlay2 services:
#IMAGE_TAG: erichardson/py-eagle-mqtt:$CI_COMMIT_TAG - docker:18.09.7-dind
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG variables:
DOCKER_DRIVER: overlay
before_script: DOCKER_HOST: tcp://localhost:2375/
- docker version IMAGE_TAG: "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
- docker info FF_GITLAB_REGISTRY_HELPER_IMAGE: 1
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY before_script:
- docker version
- docker info
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
build: build:
only: extends:
- tags - .docker_base
stage: build stage: build
script: script:
- docker build -t $IMAGE_TAG -t $CI_COMMIT_TAG ./Docker/ - docker pull $CI_REGISTRY_IMAGE:latest || true
- docker push $IMAGE_TAG $CI_COMMIT_TAG - >
docker build
--pull
--cache-from $CI_REGISTRY_IMAGE:latest
--tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
--build-arg VCS_REF=$CI_COMMIT_SHORT_SHA
./Docker/
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
#build: push local:
# stage: build extends:
# script: - .docker_base
# - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . stage: push_local
# - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" variables:
# except: GIT_STRATEGY: none
# - master only:
- master
script:
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest
- docker push $CI_REGISTRY_IMAGE:latest
push dockerhub:
extends:
- .docker_base
stage: push_dockerhub
variables:
GIT_STRATEGY: none
CI_DOCKERHUB_IMAGE: index.docker.io/evanrich/py-eagle-mqtt
CI_DOCKERHUB_REGISTRY: docker.io
only:
- tags
script:
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_DOCKERHUB_IMAGE:$CI_COMMIT_REF_NAME
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_DOCKERHUB_IMAGE:latest
- docker login -u "$CI_DOCKERHUB_USER" -p "$CI_DOCKERHUB_PASSWORD" $CI_DOCKERHUB_REGISTRY
- docker push $CI_DOCKERHUB_IMAGE
release:
image: node:13
stage: release
only:
refs:
- master
- alpha
# This matches maintenance branches
- /^(([0-9]+)\.)?([0-9]+)\.x/
# This matches pre-releases
- /^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/
script:
- touch CHANGELOG.md
- npm install @semantic-release/gitlab @semantic-release/changelog @semantic-release/git
- npx semantic-release
artifacts:
paths:
- CHANGELOG.md
sast:
stage: test
include:
- template: Security/SAST.gitlab-ci.yml
sonarqube-check:
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- sonar-scanner
allow_failure: true
only:
- master # or the name of your main branch

View File

@@ -0,0 +1,6 @@
[bandit]
[[bandit.ruleset]]
disable = true
[bandit.ruleset.identifier]
type = "bandit_test_id"
value = "B101"

13
.releaserc.yml Normal file
View File

@@ -0,0 +1,13 @@
plugins:
- "@semantic-release/commit-analyzer"
- "@semantic-release/release-notes-generator"
- - "@semantic-release/changelog"
- changelogFile: CHANGELOG.md
- "@semantic-release/gitlab"
- - "@semantic-release/git"
- assets: CHANGELOG.md
branches:
- "master"
- "+([0-9])?(.{+([0-9]),x}).x"
- name: "alpha"
prerelease: "alpha"

75
CHANGELOG.md Normal file
View File

@@ -0,0 +1,75 @@
## [1.7.3](https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt/compare/v1.7.2...v1.7.3) (2021-04-12)
### Bug Fixes
* Empty commit to get recent changes into build (last commit should've been labeled this) ([e513752](https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt/commit/e513752c46cc0b3beb93530f6549661d67196905))
## [1.7.2](https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt/compare/v1.7.1...v1.7.2) (2021-04-08)
### Bug Fixes
* Cleanup CHANGELOG.md since using new semantic-release format ([a72ac7a](https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt/commit/a72ac7a1df91cb2231e38e8bbceb5ccf9c93328a))
* fix asset info for git commit ([00c95c4](https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt/commit/00c95c42ea98921a1b2da9d2069d41e8e32f34f5))
## [1.7.1](https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt/compare/v1.7.0...v1.7.1) (2021-04-08)
### Bug Fixes
* refactor Dockerfile to improve build ([40ac8c5](https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt/commit/40ac8c5ada9b993f53b72dcc14b2d9b7cd183e2f))
## [1.6.10] - 2021-04-06
### Fixed
- Fix docker tagging issue
## [1.6.9] - 2021-04-06
### Fixed
- Remove release-cli section of CI file
- Add updated README.md
## [1.6.8] - 2021-04-06
### Changed
- Fixed slight issue with tagging
## [1.6.7] - 2021-04-06
### Changed
- Updated base image to Python 3.9.4-alpine3.13
- Moved changes to this file
### Removed
- Changelog from README.md
## [1.6.6] - 2021-04-03
### Added
- Added CI/CD pipeline to project
### Changed
- Moved project to my own personal Gitlab server for CI/CD pipelines as well as to run security scans on the container image and code
- Updated base image to Python 3.9.3-alpine3.12
## [Unversioned history]
- 2019-07-24: Rebase to python 3.7.4-alpine3.10, update bottle to 0.12.17
- 2019-04-12: Rebase to python 3.7.3-alpine3.9
- 2019-03-08: Rebase to python 3.7.2-alpine3.9, update bottle and astral versions to latest
- 2019-01-03: Rebase to python 3.7.2-alpine3.8, changed logging level to Info (should output to /var/log/tHome/eagle.log)
- 2018-09-10: Ported to Python3, Added pricing info. Merged into master branch

View File

@@ -1,17 +1,26 @@
FROM python:3.7.4-alpine3.10 FROM python:3.9.4-alpine3.13
LABEL maintainer="Evan Richardson (evanrich81[at]gmail.com)" LABEL maintainer="Evan Richardson (evanrich81[at]gmail.com)"
LABEL version="1.5.1"
ARG BUILD_DATE
ARG VCS_REF
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.build-date=$BUILD_DATE
LABEL org.label-schema.name="evanrich/py-eagle-mqtt"
LABEL org.label-schema.description="Python Rainforest Eagle to MQTT Application"
LABEL org.label-schema.vcs-url="https://github.com/evanrich/py-eagle-mqtt"
LABEL org.label-schema.vcs-ref=$VCS_REF
LABEL org.label-schema.vendor="Evan Richardson"
LABEL org.label-schema.docker.cmd="docker run --name=py-eagle-mqtt -e MQTT_BROKER_IP=<IP> -e MQTT_BROKER_PORT=1883 -p 22042:22042 -d evanrich/py-eagle-mqtt"
WORKDIR /app WORKDIR /app
COPY . /app COPY requirements.txt /app
COPY ./src/conf/logrotate/tHome /etc/logrotate.d/ COPY ./src/conf/logrotate/tHome /etc/logrotate.d/
ENV PYTHONPATH=/app/src/python ENV PYTHONPATH=/app/src/python
RUN apk --update add --no-cache logrotate \ RUN apk --update add --no-cache logrotate \
&& pip3 install --no-cache-dir --upgrade pip \ && pip3 install --no-cache-dir --upgrade pip \
&& pip3 install --no-cache-dir -r requirements.txt && pip3 install --no-cache-dir -r requirements.txt
#RUN rm -rf /var/cache/apk COPY . /app
CMD ["/app/src/bin/tHome-eagle.py", "-c", "/app/src/conf"] CMD ["/app/src/bin/tHome-eagle.py", "-c", "/app/src/conf"]
EXPOSE 22042 EXPOSE 22042

View File

@@ -1,4 +1,3 @@
astral==1.10.1 paho-mqtt==1.5.1
paho-mqtt==1.4.0 bottle==0.12.19
bottle==0.12.17 defusedxml==0.7.1

View File

@@ -1,10 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
#=========================================================================== # ===========================================================================
# #
# Eagle posting server # Eagle posting server
# #
#=========================================================================== # ===========================================================================
__doc__ = """ __doc__ = """
Starts a small web server. The Rain Forest Eagle is configured with Starts a small web server. The Rain Forest Eagle is configured with
@@ -22,100 +22,116 @@ import json
import bottle as B import bottle as B
import tHome as T import tHome as T
#===========================================================================
def meter( client, data, cfg ):
msg = {
"time" : data.TimeUnix,
"consumed" : data.Consumed, # kWh
"produced" : data.Produced, # kWh
}
return ( cfg.mqttEnergy, msg ) # ===========================================================================
def meter(client, data, cfg):
msg = {
"time": data.TimeUnix,
"consumed": data.Consumed, # kWh
"produced": data.Produced, # kWh
}
#=========================================================================== return cfg.mqttEnergy, msg
def instant( client, data, cfg ):
msg = {
"time" : data.TimeUnix,
"power" : data.Power * 1000, # W
}
return ( cfg.mqttPower, msg )
#===========================================================================
def price( client, data, cfg ):
msg = {
"time" : data.TimeUnix,
"price" : data.Price,
"tier" : data.Tier,
}
return ( cfg.mqttPrice, msg )
#=========================================================================== # ===========================================================================
def instant(client, data, cfg):
msg = {
"time": data.TimeUnix,
"power": data.Power * 1000, # W
}
return cfg.mqttPower, msg
# ===========================================================================
def price(client, data, cfg):
msg = {
"time": data.TimeUnix,
"price": data.Price,
"tier": data.Tier,
}
return cfg.mqttPrice, msg
# ===========================================================================
def network(client, data, cfg):
msg = {
"status": data.Status,
"description": data.Description,
"linkstrength": data.LinkStrength
}
return cfg.mqttNetwork, msg
# ===========================================================================
handlers = { handlers = {
#"BlockPriceDetail" : # "BlockPriceDetail" :
"CurrentSummation" : meter, "CurrentSummation": meter,
#"DeviceInfo" : # "DeviceInfo" :
#"FastPollStatus" : # "FastPollStatus" :
"InstantaneousDemand" : instant, "InstantaneousDemand": instant,
#"MessageCluster" : # "MessageCluster" :
#"MeterInfo" : # "MeterInfo" :
#"NetworkInfo" : "NetworkInfo": network,
"PriceCluster" : price, "PriceCluster": price,
#"Reading" : # "Reading" :
#"ScheduleInfo" : # "ScheduleInfo" :
#"TimeCluster" : # "TimeCluster" :
} }
#===========================================================================
@B.post( '/' ) # ===========================================================================
@B.post('/')
def root_post(): def root_post():
data = B.request.body.read( B.request.content_length ) data = B.request.body.read(B.request.content_length)
try: try:
obj = T.eagle.parse( data ) obj = T.eagle.parse(data)
except: except:
log.exception( "Error parsing Eagle posted data" ) log.exception("Error parsing Eagle posted data")
return "ERROR" return "ERROR"
log.info( "Read packet: %s" % obj.name ) log.info("Read packet: %s" % obj.name)
func = handlers.get( obj.name, None )
if func:
topic, msg = func( client, obj, cfg )
if msg:
log.info( "Publish: %s: %s" % ( topic, msg ) )
payload = json.dumps( msg )
client.publish( topic, payload )
return "ok" func = handlers.get(obj.name, None)
if func:
topic, msg = func(client, obj, cfg)
if msg:
log.info("Publish: %s: %s" % (topic, msg))
#=========================================================================== payload = json.dumps(msg)
client.publish(topic, payload)
return "ok"
# ===========================================================================
# #
# Main applications script # Main applications script
# #
#=========================================================================== # ===========================================================================
p = argparse.ArgumentParser( prog=sys.argv[0], p = argparse.ArgumentParser(prog=sys.argv[0],
description="T-Home Eagle Server" ) description="T-Home Eagle Server")
p.add_argument( "-c", "--configDir", metavar="configDir", p.add_argument("-c", "--configDir", metavar="configDir",
default="/etc/tHome", default="/etc/tHome",
help="Configuration file directory." ) help="Configuration file directory.")
p.add_argument( "-l", "--log", metavar="logFile", p.add_argument("-l", "--log", metavar="logFile",
default=None, help="Logging file to use. Input 'stdout' " default=None, help="Logging file to use. Input 'stdout' "
"to log to the screen." ) "to log to the screen.")
c = p.parse_args( sys.argv[1:] ) c = p.parse_args(sys.argv[1:])
# Parse the eagle config file. # Parse the eagle config file.
cfg = T.eagle.config.parse( c.configDir ) cfg = T.eagle.config.parse(c.configDir)
log = T.eagle.config.log( cfg, c.log ) log = T.eagle.config.log(cfg, c.log)
# Create the MQTT client and connect it to the broker. # Create the MQTT client and connect it to the broker.
client = T.broker.connect( c.configDir, log ) client = T.broker.connect(c.configDir, log)
# Start the MQTT as a background thread. This way we can run the web # Start the MQTT as a background thread. This way we can run the web
# server as the main thread here. # server as the main thread here.
client.loop_start() client.loop_start()
log.info( "Starting web server at port %d" % cfg.httpPort ) log.info("Starting web server at port %d" % cfg.httpPort)
B.run( host='0.0.0.0', port=cfg.httpPort, quiet=True ) B.run(host='0.0.0.0', port=cfg.httpPort, quiet=True)

View File

@@ -18,7 +18,7 @@ keepAlive = os.getenv('KEEPALIVE', 60)
# #
#=========================================================================== #===========================================================================
user = os.getenv('MQTT_USER', None) user = os.getenv('MQTT_USER', None)
password = os.getenv('MQTT_PASS', None) password = os.getenv('MQTT_PASSWORD', None)
#=========================================================================== #===========================================================================
# #
@@ -31,5 +31,3 @@ ca_certs = [
certFile = None certFile = None
keyFile = None keyFile = None

View File

@@ -23,6 +23,9 @@ mqttPrice = 'power/elec/Home/price'
#Current rate label (returns rate label from meter) #Current rate label (returns rate label from meter)
mqttRateLabel = 'power/elec/Home/ratelabel' mqttRateLabel = 'power/elec/Home/ratelabel'
#Network Info Topic (returns status, description and link strength from meter)
mqttNetwork = 'power/elec/Home/network'
#=========================================================================== #===========================================================================
# #
# Logging configuration. Env variables are allowed in the file name. # Logging configuration. Env variables are allowed in the file name.

View File

@@ -6,7 +6,7 @@ from . import messages as msg
#from .InstantDemand import InstantDemand #from .InstantDemand import InstantDemand
#from .Reading import Reading #from .Reading import Reading
#from .Total import Total #from .Total import Total
import xml.etree.ElementTree as ET import defusedxml.ElementTree as ET
import socket import socket
#========================================================================== #==========================================================================

View File

@@ -3,7 +3,7 @@
# Parse XML messages into an object. # Parse XML messages into an object.
# #
#=========================================================================== #===========================================================================
import xml.etree.ElementTree as ET import defusedxml.ElementTree as ET
from . import messages from . import messages
#========================================================================== #==========================================================================

View File

@@ -1,19 +1,20 @@
# py-eagle-mqtt # py-eagle-mqtt
Python3 based Docker for Eagle to MQTT reader Python3 based Docker for Eagle to MQTT reader
I have only ported this into a dockerfile, All Original code (with one minor modification for XML root tag) is credit to [Ted Drain - TD22057](https://github.com/TD22057/T-Home). I have only ported this into a dockerfile, as well as made some changes to code for security or other purposes. All Original code is credit to [Ted Drain - TD22057](https://github.com/TD22057/T-Home).
This project utilizes the following tools:
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Libraries.io dependency status for GitHub repo](https://img.shields.io/librariesio/github/evanrich/py-eagle-mqtt)]()
[![Gitlab pipeline status (self-hosted)](https://img.shields.io/gitlab/pipeline/erichardson/py-eagle-mqtt/master?gitlab_url=https%3A%2F%2Fgitlab.evanrichardsonphotography.com)]()
[![Docker Pulls](https://img.shields.io/docker/pulls/evanrich/py-eagle-mqtt)]()
[![Docker Image Version (latest by date)](https://img.shields.io/docker/v/evanrich/py-eagle-mqtt)]()
## UPDATES: ## UPDATES:
2019-07-24: Rebase to python 3.7.4-alpine3.10, update bottle to 0.12.17
2019-04-12: Rebase to python 3.7.3-alpine3.9
2019-03-08: Rebase to python 3.7.2-alpine3.9, update bottle and astral versions to latest
2019-01-03: Rebase to python 3.7.2-alpine3.8, changed logging level to Info (should output to /var/log/tHome/eagle.log)
2018-09-10: Ported to Python3, Added pricing info. Merged into master branch
2020-04-06: Moved Updates to a CHANGELOG.md file to clean this up.
## Usage ## Usage

View File

@@ -1,4 +1,4 @@
apiVersion: extensions/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: py-eagle-mqtt name: py-eagle-mqtt

3
sonar-project.properties Normal file
View File

@@ -0,0 +1,3 @@
sonar.projectKey=erichardson_py-eagle-mqtt_AXkgI9tRLcemhRz3NCjo
sonar.qualitygate.wait=true
sonar.projectBaseDir=Docker/src