Compare commits
28 Commits
1.6.8
...
add-networ
| Author | SHA1 | Date | |
|---|---|---|---|
| 26b955a1e8 | |||
| bb17ad6135 | |||
| 40c7d020d2 | |||
| 9b5adba3ed | |||
|
|
73740ffa39 | ||
|
|
e513752c46 | ||
|
|
cfb392dc6a | ||
| f3f78c4ad5 | |||
| d1723db798 | |||
| ba8486017a | |||
| 37d8b17076 | |||
|
|
da83d88229 | ||
|
|
00c95c42ea | ||
|
|
a72ac7a1df | ||
|
|
ffbde1eff5 | ||
| 1e58da7572 | |||
|
|
40ac8c5ada | ||
|
|
2c49af0f32 | ||
|
|
a4c715068d | ||
| 91b6464e8c | |||
| b9ad4e8ec1 | |||
|
|
ac8c039b33 | ||
|
|
46cc86ed0b | ||
|
|
3db668ff98 | ||
|
|
99661058bd | ||
|
|
575e2fe6ce | ||
|
|
10c5443914 | ||
|
|
058638eb83 |
@@ -7,6 +7,7 @@ stages:
|
|||||||
- test
|
- test
|
||||||
- build
|
- build
|
||||||
- push_local
|
- push_local
|
||||||
|
- release
|
||||||
- push_dockerhub
|
- push_dockerhub
|
||||||
|
|
||||||
.docker_base:
|
.docker_base:
|
||||||
@@ -34,6 +35,8 @@ build:
|
|||||||
--pull
|
--pull
|
||||||
--cache-from $CI_REGISTRY_IMAGE:latest
|
--cache-from $CI_REGISTRY_IMAGE:latest
|
||||||
--tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
--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/
|
||||||
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
||||||
|
|
||||||
@@ -50,19 +53,6 @@ push local:
|
|||||||
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest
|
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest
|
||||||
- docker push $CI_REGISTRY_IMAGE:latest
|
- docker push $CI_REGISTRY_IMAGE:latest
|
||||||
|
|
||||||
release_job:
|
|
||||||
stage: release
|
|
||||||
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
|
||||||
rules:
|
|
||||||
- if: $CI_COMMIT_TAG
|
|
||||||
script:
|
|
||||||
- echo 'running release_job'
|
|
||||||
release:
|
|
||||||
name: 'Release $CI_COMMIT_TAG'
|
|
||||||
description: 'Created using the release-cli'
|
|
||||||
tag_name: '$CI_COMMIT_TAG'
|
|
||||||
ref: '$CI_COMMIT_TAG'
|
|
||||||
|
|
||||||
push dockerhub:
|
push dockerhub:
|
||||||
extends:
|
extends:
|
||||||
- .docker_base
|
- .docker_base
|
||||||
@@ -75,11 +65,48 @@ push dockerhub:
|
|||||||
- tags
|
- tags
|
||||||
script:
|
script:
|
||||||
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
||||||
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_DOCKERHUB_IMAGE:$CI_COMMIT_REF_NAME $CI_DOCKERHUB_IMAGE:latest
|
- 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 login -u "$CI_DOCKERHUB_USER" -p "$CI_DOCKERHUB_PASSWORD" $CI_DOCKERHUB_REGISTRY
|
||||||
- docker push $CI_DOCKERHUB_IMAGE:$CI_COMMIT_REF_NAME $CI_DOCKERHUB_IMAGE:latest
|
- 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:
|
sast:
|
||||||
stage: test
|
stage: test
|
||||||
include:
|
include:
|
||||||
- template: Security/SAST.gitlab-ci.yml
|
- 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
|
||||||
|
|||||||
13
.releaserc.yml
Normal file
13
.releaserc.yml
Normal 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"
|
||||||
36
CHANGELOG.md
36
CHANGELOG.md
@@ -1,9 +1,37 @@
|
|||||||
# Changelog
|
## [1.7.3](https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt/compare/v1.7.2...v1.7.3) (2021-04-12)
|
||||||
|
|
||||||
All notable changes to this project will be documented in this file.
|
|
||||||
|
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
### Bug Fixes
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
||||||
|
* 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
|
## [1.6.8] - 2021-04-06
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,26 @@
|
|||||||
FROM python:3.9.3-alpine3.12
|
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.6.6"
|
|
||||||
|
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
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
astral==2.2
|
|
||||||
paho-mqtt==1.5.1
|
paho-mqtt==1.5.1
|
||||||
bottle==0.12.19
|
bottle==0.12.19
|
||||||
defusedxml==0.7.1
|
defusedxml==0.7.1
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import json
|
|||||||
import bottle as B
|
import bottle as B
|
||||||
import tHome as T
|
import tHome as T
|
||||||
|
|
||||||
|
|
||||||
# ===========================================================================
|
# ===========================================================================
|
||||||
def meter(client, data, cfg):
|
def meter(client, data, cfg):
|
||||||
msg = {
|
msg = {
|
||||||
@@ -30,7 +31,8 @@ def meter( client, data, cfg ):
|
|||||||
"produced": data.Produced, # kWh
|
"produced": data.Produced, # kWh
|
||||||
}
|
}
|
||||||
|
|
||||||
return ( cfg.mqttEnergy, msg )
|
return cfg.mqttEnergy, msg
|
||||||
|
|
||||||
|
|
||||||
# ===========================================================================
|
# ===========================================================================
|
||||||
def instant(client, data, cfg):
|
def instant(client, data, cfg):
|
||||||
@@ -39,7 +41,8 @@ def instant( client, data, cfg ):
|
|||||||
"power": data.Power * 1000, # W
|
"power": data.Power * 1000, # W
|
||||||
}
|
}
|
||||||
|
|
||||||
return ( cfg.mqttPower, msg )
|
return cfg.mqttPower, msg
|
||||||
|
|
||||||
|
|
||||||
# ===========================================================================
|
# ===========================================================================
|
||||||
def price(client, data, cfg):
|
def price(client, data, cfg):
|
||||||
@@ -48,7 +51,18 @@ def price( client, data, cfg ):
|
|||||||
"price": data.Price,
|
"price": data.Price,
|
||||||
"tier": data.Tier,
|
"tier": data.Tier,
|
||||||
}
|
}
|
||||||
return ( cfg.mqttPrice, msg )
|
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 = {
|
||||||
@@ -59,13 +73,14 @@ handlers = {
|
|||||||
"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('/')
|
||||||
@@ -90,6 +105,7 @@ def root_post():
|
|||||||
|
|
||||||
return "ok"
|
return "ok"
|
||||||
|
|
||||||
|
|
||||||
# ===========================================================================
|
# ===========================================================================
|
||||||
#
|
#
|
||||||
# Main applications script
|
# Main applications script
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
24
README.md
24
README.md
@@ -1,22 +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:
|
||||||
|
|
||||||
|
[](https://github.com/semantic-release/semantic-release)
|
||||||
|
[]()
|
||||||
|
[]()
|
||||||
|
[]()
|
||||||
|
[]()
|
||||||
|
|
||||||
## UPDATES:
|
## UPDATES:
|
||||||
|
|
||||||
2020-04-03: I've moved the repo to my private Gitlab server, with a mirror set up to github. I did this so that I could easily integrate a CI/CD pipeline to build this image, as well as run some Security tools against the image to improve it's code quality. Please continue to open bug reports/issues/pull requests here in Github. Also swapped to defusedxml python module due to security issues around xmltree. Forgot to incrememnt the build number, but docker container latest is up-to-date.
|
2020-04-06: Moved Updates to a CHANGELOG.md file to clean this up.
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
|||||||
3
sonar-project.properties
Normal file
3
sonar-project.properties
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
sonar.projectKey=erichardson_py-eagle-mqtt_AXkgI9tRLcemhRz3NCjo
|
||||||
|
sonar.qualitygate.wait=true
|
||||||
|
sonar.projectBaseDir=Docker/src
|
||||||
Reference in New Issue
Block a user