diff --git a/enedisGateway2MQTT/Dockerfile b/enedisGateway2MQTT/Dockerfile new file mode 100644 index 000000000..8baf4ad10 --- /dev/null +++ b/enedisGateway2MQTT/Dockerfile @@ -0,0 +1,59 @@ +FROM m4dm4rtig4n/enedisgateway2mqtt:latest + +# Base system +ARG BASHIO_VERSION=0.13.1 + +RUN \ + ################ + # Install apps # + ################ + apt-get clean \ + && apt-get update \ + && apt-get install -y \ + jq \ + curl \ + && apt-get clean \ + \ + ################## + # Install bashio # + ################## + && mkdir -p /tmp/bashio \ + && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ + | tar -xzf - --strip 1 -C /tmp/bashio \ + && mv /tmp/bashio/lib /usr/lib/bashio \ + && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ + && rm -rf /tmp/bashio + +# Copy root filesystem +COPY rootfs / +RUN chmod 777 /run.sh +ENTRYPOINT [ "/usr/bin/env" ] +CMD ["/run.sh"] +VOLUME [ "/data" ] + +### LABELS +ARG BUILD_ARCH +ARG BUILD_DATE +ARG BUILD_DESCRIPTION +ARG BUILD_NAME +ARG BUILD_REF +ARG BUILD_REPOSITORY +ARG BUILD_VERSION +LABEL \ + io.hass.name="${BUILD_NAME}" \ + io.hass.description="${BUILD_DESCRIPTION}" \ + io.hass.arch="${BUILD_ARCH}" \ + io.hass.type="addon" \ + io.hass.version=${BUILD_VERSION} \ + maintainer="alexbelgium (https://github.com/alexbelgium)" \ + org.opencontainers.image.title="${BUILD_NAME}" \ + org.opencontainers.image.description="${BUILD_DESCRIPTION}" \ + org.opencontainers.image.vendor="Home Assistant Add-ons" \ + org.opencontainers.image.authors="alexbelgium (https://github.com/alexbelgium)" \ + org.opencontainers.image.licenses="MIT" \ + org.opencontainers.image.url="https://github.com/alexbelgium" \ + org.opencontainers.image.source="https://github.com/${BUILD_REPOSITORY}" \ + org.opencontainers.image.documentation="https://github.com/${BUILD_REPOSITORY}/blob/main/README.md" \ + org.opencontainers.image.created=${BUILD_DATE} \ + org.opencontainers.image.revision=${BUILD_REF} \ + org.opencontainers.image.version=${BUILD_VERSION} diff --git a/enedisGateway2MQTT/README.md b/enedisGateway2MQTT/README.md new file mode 100644 index 000000000..1ed5fef6c --- /dev/null +++ b/enedisGateway2MQTT/README.md @@ -0,0 +1,37 @@ +# Home assistant add-on: Enedisgateway2mqtt + +[![Donate][donation-badge]](https://www.buymeacoffee.com/alexbelgium) + +[donation-badge]: https://img.shields.io/badge/Buy%20me%20a%20coffee-%23d32f2f?logo=buy-me-a-coffee&style=flat&logoColor=white + +![Supports + Architecture][aarch64-shield] ![Supports amd64 Architecture][amd64-shield] ![Supports armhf Architecture][armhf-shield] ![Supports armv7 Architecture][armv7-shield] + +## About + +Enedisgateway2mqtt use Enedis Gateway API to send data in your MQTT Broker. +See its github for all informations : https://github.com/m4dm4rtig4n/enedisgateway2mqtt/blob/master/README.md + +## Installation + +The installation of this add-on is pretty straightforward and not different in +comparison to installing any other Hass.io add-on. + +1. [Add my Hass.io add-ons repository][repository] to your Hass.io instance. +1. Install this add-on. +1. Click the `Save` button to store your configuration. +1. Start the add-on. +1. Check the logs of the add-on to see if everything went well. +1. Carefully configure the add-on to your preferences, see the official documentation for for that. + +### Configuration + +Configure the addon through its options page. +See this page for configuration : https://hub.docker.com/r/m4dm4rtig4n/enedisgateway2mqtt + +[smb-shield]: https://img.shields.io/badge/SMB--green?style=plastic.svg +[repository]: https://github.com/alexbelgium/hassio-addons +[aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg +[amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg +[armhf-shield]: https://img.shields.io/badge/armhf-yes-green.svg +[armv7-shield]: https://img.shields.io/badge/armv7-yes-green.svg diff --git a/enedisGateway2MQTT/apparmor.txt b/enedisGateway2MQTT/apparmor.txt new file mode 100644 index 000000000..4b9ced9e4 --- /dev/null +++ b/enedisGateway2MQTT/apparmor.txt @@ -0,0 +1,38 @@ +#include + +profile inadyn_addon flags=(attach_disconnected,mediate_deleted) { + #include + + capability, + file, + mount, + umount, + remount, + capability setgid, + capability setuid, + + +# S6-Overlay + /bin/** ix, + /usr/bin/** ix, + /usr/lib/bashio/** ix, + /etc/s6/** rix, + /run/s6/** rix, + /etc/services.d/** rwix, + /etc/cont-init.d/** rwix, + /etc/cont-finish.d/** rwix, + /init rix, + /var/run/** mrwkl, + /var/run/ mrwkl, + /dev/i2c-1 mrwkl, + + # Data access + /data/** rw, + + # suppress ptrace denials when using 'docker ps' or using 'ps' inside a container + ptrace (trace,read) peer=docker-default, + + # docker daemon confinement requires explict allow rule for signal + signal (receive) set=(kill,term) peer=/usr/bin/docker, + +} diff --git a/enedisGateway2MQTT/config.json b/enedisGateway2MQTT/config.json new file mode 100644 index 000000000..cb0b4caa5 --- /dev/null +++ b/enedisGateway2MQTT/config.json @@ -0,0 +1,34 @@ +{ + "arch": ["aarch64", "amd64", "armv7", "armhf"], + "description": "use Enedis Gateway API to send data in your MQTT Broker", + "name": "Enedisgateway2mqtt DO NOT USE", + "options": { + "ACCESS_TOKEN": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + "PDL": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + "MQTT_HOST": "" + }, + "schema": { + "ACCESS_TOKEN": "str", + "PDL": "str", + "MQTT_HOST": "str", + "MQTT_PORT": "str?", + "MQTT_PREFIX": "str?", + "MQTT_CLIENT_ID": "str?", + "MQTT_USERNAME": "str?", + "MQTT_PASSWORD": "str?", + "RETAIN": "str?", + "QOS": "str?", + "GET_CONSUMPTION": "str?", + "GET_PRODUCTION": "str?", + "HA_AUTODISCOVERY": "str?", + "HA_AUTODISCOVERY_PREFIX": "str?", + "CONSUMPTION_PRICE_BASE": "str?", + "CONSUMPTION_PRICE_HC": "str?", + "CONSUMPTION_PRICE_HP": "str?", + "CARD_MYENEDIS": "str?" + }, + "slug": "enedisgateway2mqtt", + "upstream": "0.5.6", + "url": "https://github.com/alexbelgium/hassio-addons", + "version": "0.5.6" +} diff --git a/enedisGateway2MQTT/icon.png b/enedisGateway2MQTT/icon.png new file mode 100644 index 000000000..d4cb77ea5 Binary files /dev/null and b/enedisGateway2MQTT/icon.png differ diff --git a/enedisGateway2MQTT/logo.png b/enedisGateway2MQTT/logo.png new file mode 100644 index 000000000..d4cb77ea5 Binary files /dev/null and b/enedisGateway2MQTT/logo.png differ diff --git a/enedisGateway2MQTT/rootfs/run.sh b/enedisGateway2MQTT/rootfs/run.sh new file mode 100644 index 000000000..754240dde --- /dev/null +++ b/enedisGateway2MQTT/rootfs/run.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bashio + +# ============================================================================== +# Home Assistant Community Add-on: Base Images +# Displays a simple add-on banner on startup +# ============================================================================== +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums or the Discord chat.' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi + +################# +# Create config # +################# +echo "Setting variables" +echo "................." + +for VARIABLES in "ACCESS_TOKEN" "PDL" "MQTT_HOST" "MQTT_PORT" "MQTT_PREFIX" "MQTT_CLIENT_ID" "MQTT_USERNAME" "MQTT_PASSWORD" "RETAIN" "QOS" "GET_CONSUMPTION" "GET_PRODUCTION" "HA_AUTODISCOVERY" "HA_AUTODISCOVERY_PREFIX" "CONSUMPTION_PRICE_BASE" "CONSUMPTION_PRICE_HC" "CONSUMPTION_PRICE_HP" "CARD_MYENEDIS"; do + [ bashio::config.has_value "$VARIABLES" ] && export $VARIABLES=$(bashio::config "$VARIABLES") && echo "$VARIABLES set to $(bashio::config "$VARIABLES")" +done + +bashio::log.info "Starting the app" + +############## +# Launch App # +############## +python -u /app/main.py