From f6d21bc52cbe469958f02c1312cbf1ec64e2ea09 Mon Sep 17 00:00:00 2001 From: Mike Degatano Date: Thu, 18 Nov 2021 00:33:43 -0500 Subject: [PATCH 1/2] Addon name change to amr2mqtt --- .github/dependabot.yaml | 2 +- README.md | 38 +++++++++++-------- {amridm2mqtt => amr2mqtt}/.README.j2 | 0 {amridm2mqtt => amr2mqtt}/DOCS.md | 15 ++++---- {amridm2mqtt => amr2mqtt}/Dockerfile | 0 {amridm2mqtt => amr2mqtt}/build.yaml | 0 {amridm2mqtt => amr2mqtt}/config.yaml | 8 ++-- .../rootfs/amr2mqtt/amr2mqtt.py | 2 +- .../rootfs/amr2mqtt}/settings.py | 0 .../rootfs/etc/cont-init.d/30-config.sh | 2 +- amr2mqtt/rootfs/etc/fix-attrs.d/permissions | 2 + .../rootfs/etc/modprobe.d/rtl-sdr.conf | 0 .../rootfs/etc/services.d/amr2mqtt}/finish | 4 +- .../rootfs/etc/services.d/amr2mqtt}/run | 8 ++-- .../rootfs/etc/udev/rules.d/rtl-sdr.rules | 0 .../rootfs/etc/fix-attrs.d/permissions | 2 - 16 files changed, 45 insertions(+), 38 deletions(-) rename {amridm2mqtt => amr2mqtt}/.README.j2 (100%) rename {amridm2mqtt => amr2mqtt}/DOCS.md (90%) rename {amridm2mqtt => amr2mqtt}/Dockerfile (100%) rename {amridm2mqtt => amr2mqtt}/build.yaml (100%) rename {amridm2mqtt => amr2mqtt}/config.yaml (81%) rename amridm2mqtt/rootfs/amridm2mqtt/amridm2mqtt.py => amr2mqtt/rootfs/amr2mqtt/amr2mqtt.py (98%) rename {amridm2mqtt/rootfs/amridm2mqtt => amr2mqtt/rootfs/amr2mqtt}/settings.py (100%) rename {amridm2mqtt => amr2mqtt}/rootfs/etc/cont-init.d/30-config.sh (98%) create mode 100644 amr2mqtt/rootfs/etc/fix-attrs.d/permissions rename {amridm2mqtt => amr2mqtt}/rootfs/etc/modprobe.d/rtl-sdr.conf (100%) rename {amridm2mqtt/rootfs/etc/services.d/amridm2mqtt => amr2mqtt/rootfs/etc/services.d/amr2mqtt}/finish (74%) rename {amridm2mqtt/rootfs/etc/services.d/amridm2mqtt => amr2mqtt/rootfs/etc/services.d/amr2mqtt}/run (93%) rename {amridm2mqtt => amr2mqtt}/rootfs/etc/udev/rules.d/rtl-sdr.rules (100%) delete mode 100644 amridm2mqtt/rootfs/etc/fix-attrs.d/permissions diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml index d519b7c..d5992e3 100644 --- a/.github/dependabot.yaml +++ b/.github/dependabot.yaml @@ -6,6 +6,6 @@ updates: schedule: interval: daily - package-ecosystem: docker - directory: "/amridm2mqtt" + directory: "/amr2mqtt" schedule: interval: daily diff --git a/README.md b/README.md index 101526f..a9e3b10 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Home Assistant Add-on: AMRIDM2MQTT +# Home Assistant Add-on: AMR2MQTT [![GitHub Release][releases-shield]][releases] ![Project Stage][project-stage-shield] @@ -23,9 +23,16 @@ with a specific repository URL pre-filled.][add-repo-shield]][add-repo] ## About -Port of ragingcomputer's [amridm2mqtt][amridm2mqtt] to a Home Assistant add-on -in order to make it easier to install and use in supervised and HAOS setups. Allows -you to use an rtl-sdr dongle to listen for signals from compatible smart meters. +Allows you to use an rtl-sdr dongle to listen for signals from ERT compatible +smart meters using [rtlamr][rtlamr]. This runs as a daemon by launching rtl-tcp +and rtlamr, parsing the output and pushing it into MQTT so Home Assistant can +consume it. + +This began as a port of ragingcomputer's [amridm2mqtt][amridm2mqtt] to a Home +Assistant add-on in order to make it easier to use in HAOS and supervised setups. +There are a number of other modifications as well such as support for other formats +like `scm` and a wider variety of MQTT configurations. Big thanks to ragingcomputer's +for their work as well as all the info in the `rtlamr` repo. ## Support @@ -44,7 +51,7 @@ You could also [open an issue here][issue] on GitHub. The original setup of this repository is by [Mike Degatano][mdegat01]. -The amridm2mqtt service ported here was created by [ragingcomputer][ragingcomputer]. +The amridm2mqtt service this was built off of was created by [ragingcomputer][ragingcomputer]. For a full list of all authors and contributors, check [the contributor's page][contributors]. @@ -75,28 +82,29 @@ SOFTWARE. [aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg [add-addon-shield]: https://my.home-assistant.io/badges/supervisor_addon.svg -[add-addon]: https://my.home-assistant.io/redirect/supervisor_addon/?addon=39bd2704_amridm2mqtt +[add-addon]: https://my.home-assistant.io/redirect/supervisor_addon/?addon=39bd2704_amr2mqtt [add-repo-shield]: https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg [add-repo]: https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2Fmdegat01%2Fhassio-addons [amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg [amridm2mqtt]: https://github.com/ragingcomputer/amridm2mqtt [armhf-shield]: https://img.shields.io/badge/armhf-yes-green.svg [armv7-shield]: https://img.shields.io/badge/armv7-yes-green.svg -[commits-shield]: https://img.shields.io/github/commit-activity/y/mdegat01/addon-amridm2mqtt.svg -[commits]: https://github.com/mdegat01/addon-amridm2mqtt/commits/main -[contributors]: https://github.com/mdegat01/addon-amridm2mqtt/graphs/contributors +[commits-shield]: https://img.shields.io/github/commit-activity/y/mdegat01/addon-amr2mqtt.svg +[commits]: https://github.com/mdegat01/addon-amr2mqtt/commits/main +[contributors]: https://github.com/mdegat01/addon-amr2mqtt/graphs/contributors [discord-ha]: https://discord.gg/c5DvZ4e [forum-centralcommand]: https://community.home-assistant.io/u/CentralCommand/?u=CentralCommand [forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg [forum]: https://community.home-assistant.io [mdegat01]: https://github.com/mdegat01 -[github-actions-shield]: https://github.com/mdegat01/addon-amridm2mqtt/workflows/CI/badge.svg -[github-actions]: https://github.com/mdegat01/addon-amridm2mqtt/actions +[github-actions-shield]: https://github.com/mdegat01/addon-amr2mqtt/workflows/CI/badge.svg +[github-actions]: https://github.com/mdegat01/addon-amr2mqtt/actions [i386-shield]: https://img.shields.io/badge/i386-no-red.svg -[issue]: https://github.com/mdegat01/addon-amridm2mqtt/issues -[license-shield]: https://img.shields.io/github/license/mdegat01/addon-amridm2mqtt.svg +[issue]: https://github.com/mdegat01/addon-amr2mqtt/issues +[license-shield]: https://img.shields.io/github/license/mdegat01/addon-amr2mqtt.svg [maintenance-shield]: https://img.shields.io/maintenance/yes/2021.svg [project-stage-shield]: https://img.shields.io/badge/project%20stage-experimental-yellow.svg [ragingcomputer]: https://github.com/ragingcomputer -[releases-shield]: https://img.shields.io/github/release/mdegat01/addon-amridm2mqtt.svg -[releases]: https://github.com/mdegat01/addon-amridm2mqtt/releases +[releases-shield]: https://img.shields.io/github/release/mdegat01/addon-amr2mqtt.svg +[releases]: https://github.com/mdegat01/addon-amr2mqtt/releases +[rtlamr]: https://github.com/bemasher/rtlamr diff --git a/amridm2mqtt/.README.j2 b/amr2mqtt/.README.j2 similarity index 100% rename from amridm2mqtt/.README.j2 rename to amr2mqtt/.README.j2 diff --git a/amridm2mqtt/DOCS.md b/amr2mqtt/DOCS.md similarity index 90% rename from amridm2mqtt/DOCS.md rename to amr2mqtt/DOCS.md index 3a42ee1..292cfa7 100644 --- a/amridm2mqtt/DOCS.md +++ b/amr2mqtt/DOCS.md @@ -1,4 +1,4 @@ -# Home Assistant Add-on: HedgeDoc +# Home Assistant Add-on: AMR2MQTT ## Install @@ -127,7 +127,7 @@ You could also [open an issue here][issue] on GitHub. The original setup of this repository is by [Mike Degatano][mdegat01]. -The amridm2mqtt service ported here was created by [ragingcomputer][ragingcomputer]. +The amridm2mqtt service this was built off of was created by [ragingcomputer][ragingcomputer]. For a full list of all authors and contributors, check [the contributor's page][contributors]. @@ -157,18 +157,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. [add-addon-shield]: https://my.home-assistant.io/badges/supervisor_addon.svg -[add-addon]: https://my.home-assistant.io/redirect/supervisor_addon/?addon=39bd2704_amridm2mqtt +[add-addon]: https://my.home-assistant.io/redirect/supervisor_addon/?addon=39bd2704_amr2mqtt [add-addon-mosquitto]: https://my.home-assistant.io/redirect/supervisor_addon/?addon=core_mosquitto [add-repo-shield]: https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg [add-repo]: https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2Fmdegat01%2Fhassio-addons [addon-mosquitto]: https://github.com/home-assistant/addons/tree/master/mosquitto -[amridm2mqtt]: https://github.com/ragingcomputer/amridm2mqtt -[contributors]: https://github.com/mdegat01/addon-hedgedoc/graphs/contributors +[contributors]: https://github.com/mdegat01/addon-amr2mqtt/graphs/contributors [discord-ha]: https://discord.gg/c5DvZ4e [forum-centralcommand]: https://community.home-assistant.io/u/CentralCommand/?u=CentralCommand -[forum]: https://community.home-assistant.io/t/home-assistant-add-on-hedgedoc/296809?u=CentralCommand -[issue]: https://github.com/mdegat01/addon-hedgedoc/issues +[forum]: https://community.home-assistant.io +[issue]: https://github.com/mdegat01/addon-amr2mqtt/issues [mdegat01]: https://github.com/mdegat01 [ragingcomputer]: https://github.com/ragingcomputer -[releases]: https://github.com/mdegat01/addon-hedgedoc/releases +[releases]: https://github.com/mdegat01/addon-amr2mqtt/releases [semver]: http://semver.org/spec/v2.0.0 diff --git a/amridm2mqtt/Dockerfile b/amr2mqtt/Dockerfile similarity index 100% rename from amridm2mqtt/Dockerfile rename to amr2mqtt/Dockerfile diff --git a/amridm2mqtt/build.yaml b/amr2mqtt/build.yaml similarity index 100% rename from amridm2mqtt/build.yaml rename to amr2mqtt/build.yaml diff --git a/amridm2mqtt/config.yaml b/amr2mqtt/config.yaml similarity index 81% rename from amridm2mqtt/config.yaml rename to amr2mqtt/config.yaml index a8c3c28..d58c7eb 100644 --- a/amridm2mqtt/config.yaml +++ b/amr2mqtt/config.yaml @@ -1,14 +1,14 @@ --- -name: AMRIDM2MQTT -url: https://github.com/mdegat01/addon-amridm2mqtt +name: AMR2MQTT +url: https://github.com/mdegat01/addon-amr2mqtt version: dev -slug: amridm2mqtt +slug: amr2mqtt arch: - aarch64 - amd64 - armv7 - armhf -description: AMRIDM2MQTT for Home Assistant +description: AMR2MQTT for Home Assistant uart: true udev: true usb: true diff --git a/amridm2mqtt/rootfs/amridm2mqtt/amridm2mqtt.py b/amr2mqtt/rootfs/amr2mqtt/amr2mqtt.py similarity index 98% rename from amridm2mqtt/rootfs/amridm2mqtt/amridm2mqtt.py rename to amr2mqtt/rootfs/amr2mqtt/amr2mqtt.py index 716b97e..d82bdcd 100644 --- a/amridm2mqtt/rootfs/amridm2mqtt/amridm2mqtt.py +++ b/amr2mqtt/rootfs/amr2mqtt/amr2mqtt.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 """ -Runs rtlamr to watch for IDM broadcasts from power meter. If meter id +Runs rtlamr to watch for broadcasts from power meter. If meter id is in the list, usage is sent to 'readings/{meter id}/meter_reading' topic on the MQTT broker specified in settings. diff --git a/amridm2mqtt/rootfs/amridm2mqtt/settings.py b/amr2mqtt/rootfs/amr2mqtt/settings.py similarity index 100% rename from amridm2mqtt/rootfs/amridm2mqtt/settings.py rename to amr2mqtt/rootfs/amr2mqtt/settings.py diff --git a/amridm2mqtt/rootfs/etc/cont-init.d/30-config.sh b/amr2mqtt/rootfs/etc/cont-init.d/30-config.sh similarity index 98% rename from amridm2mqtt/rootfs/etc/cont-init.d/30-config.sh rename to amr2mqtt/rootfs/etc/cont-init.d/30-config.sh index 439a7c6..c4be770 100644 --- a/amridm2mqtt/rootfs/etc/cont-init.d/30-config.sh +++ b/amr2mqtt/rootfs/etc/cont-init.d/30-config.sh @@ -1,7 +1,7 @@ #!/usr/bin/with-contenv bashio # shellcheck shell=bash # ============================================================================== -# Home Assistant Add-on: AMRIDM2MQTT +# Home Assistant Add-on: AMR2MQTT # This validates config and sets up app files/folders # ============================================================================== diff --git a/amr2mqtt/rootfs/etc/fix-attrs.d/permissions b/amr2mqtt/rootfs/etc/fix-attrs.d/permissions new file mode 100644 index 0000000..5aa0a9a --- /dev/null +++ b/amr2mqtt/rootfs/etc/fix-attrs.d/permissions @@ -0,0 +1,2 @@ +/data/amr2mqtt true abc 0755 0755 +/amr2mqtt true abc 0555 0555 \ No newline at end of file diff --git a/amridm2mqtt/rootfs/etc/modprobe.d/rtl-sdr.conf b/amr2mqtt/rootfs/etc/modprobe.d/rtl-sdr.conf similarity index 100% rename from amridm2mqtt/rootfs/etc/modprobe.d/rtl-sdr.conf rename to amr2mqtt/rootfs/etc/modprobe.d/rtl-sdr.conf diff --git a/amridm2mqtt/rootfs/etc/services.d/amridm2mqtt/finish b/amr2mqtt/rootfs/etc/services.d/amr2mqtt/finish similarity index 74% rename from amridm2mqtt/rootfs/etc/services.d/amridm2mqtt/finish rename to amr2mqtt/rootfs/etc/services.d/amr2mqtt/finish index 93e4ee0..740c1fd 100755 --- a/amridm2mqtt/rootfs/etc/services.d/amridm2mqtt/finish +++ b/amr2mqtt/rootfs/etc/services.d/amr2mqtt/finish @@ -1,7 +1,7 @@ #!/usr/bin/execlineb -S0 # ============================================================================== -# Home Assistant Add-on: AMRIDM2MQTT -# Take down the S6 supervision tree when AMRIDM2MQTT fails +# Home Assistant Add-on: AMR2MQTT +# Take down the S6 supervision tree when AMR2MQTT fails # ============================================================================== if { s6-test ${1} -ne 0 } if { s6-test ${1} -ne 256 } diff --git a/amridm2mqtt/rootfs/etc/services.d/amridm2mqtt/run b/amr2mqtt/rootfs/etc/services.d/amr2mqtt/run similarity index 93% rename from amridm2mqtt/rootfs/etc/services.d/amridm2mqtt/run rename to amr2mqtt/rootfs/etc/services.d/amr2mqtt/run index 878c7b3..917764a 100644 --- a/amridm2mqtt/rootfs/etc/services.d/amridm2mqtt/run +++ b/amr2mqtt/rootfs/etc/services.d/amr2mqtt/run @@ -1,8 +1,8 @@ #!/usr/bin/with-contenv bashio # shellcheck shell=bash # ============================================================================== -# Home Assistant Add-on: Hedgedoc -# Runs Hedgedoc +# Home Assistant Add-on: AMR2MQTT +# Runs AMR2MQTT # ============================================================================== declare host @@ -69,6 +69,6 @@ export LOG_LEVEL="${log_level}" bashio::log.info "Log level set to ${log_level}" -bashio::log.info 'Handing over control to AMRIDM2MQTT...' +bashio::log.info 'Handing over control to AMR2MQTT...' exec s6-setuidgid abc \ - /usr/bin/python3 /amridm2mqtt/amridm2mqtt.py + /usr/bin/python3 /amr2mqtt/amr2mqtt.py diff --git a/amridm2mqtt/rootfs/etc/udev/rules.d/rtl-sdr.rules b/amr2mqtt/rootfs/etc/udev/rules.d/rtl-sdr.rules similarity index 100% rename from amridm2mqtt/rootfs/etc/udev/rules.d/rtl-sdr.rules rename to amr2mqtt/rootfs/etc/udev/rules.d/rtl-sdr.rules diff --git a/amridm2mqtt/rootfs/etc/fix-attrs.d/permissions b/amridm2mqtt/rootfs/etc/fix-attrs.d/permissions deleted file mode 100644 index df8054a..0000000 --- a/amridm2mqtt/rootfs/etc/fix-attrs.d/permissions +++ /dev/null @@ -1,2 +0,0 @@ -/data/amridm2mqtt true abc 0755 0755 -/amridm2mqtt true abc 0555 0555 \ No newline at end of file From 8dae0f6b1431c6569abec9e7753f9dcb02761d7c Mon Sep 17 00:00:00 2001 From: Mike Degatano Date: Thu, 18 Nov 2021 00:34:59 -0500 Subject: [PATCH 2/2] Fix old name references in Dockerfile --- amr2mqtt/Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/amr2mqtt/Dockerfile b/amr2mqtt/Dockerfile index 4ce7451..02397fc 100644 --- a/amr2mqtt/Dockerfile +++ b/amr2mqtt/Dockerfile @@ -39,16 +39,16 @@ RUN set -eux; \ update-ca-certificates; \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*; \ \ - echo "Add user for AMRIDM2MQTT"; \ - mkdir -p /data/amridm2mqtt; \ - useradd -u 12345 -U -d /data/amridm2mqtt abc; + echo "Add user for AMR2MQTT"; \ + mkdir -p /data/amr2mqtt; \ + useradd -u 12345 -U -d /data/amr2mqtt abc; # Add rtlamr COPY --from=build_rtlamr /usr/bin/rtlamr /usr/bin/rtlamr RUN rtlamr --version COPY rootfs / -WORKDIR /data/amridm2mqtt +WORKDIR /data/amr2mqtt # Build arguments ARG BUILD_ARCH