{"id":23157219,"url":"https://github.com/antonijn/mqtt4dsmr","last_synced_at":"2025-05-09T00:55:06.252Z","repository":{"id":218397862,"uuid":"746308590","full_name":"antonijn/mqtt4dsmr","owner":"antonijn","description":"Yet another DSMR to MQTT daemon, with Home Assistant support","archived":false,"fork":false,"pushed_at":"2024-09-04T00:07:23.000Z","size":82,"stargazers_count":4,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-09T00:54:59.941Z","etag":null,"topics":["docker-compose","dsmr","home-assistant","mqtt","quadlet"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antonijn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-21T17:25:49.000Z","updated_at":"2024-10-18T14:47:07.000Z","dependencies_parsed_at":"2024-06-11T21:27:29.456Z","dependency_job_id":null,"html_url":"https://github.com/antonijn/mqtt4dsmr","commit_stats":null,"previous_names":["antonijn/mqtt4dsmr"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonijn%2Fmqtt4dsmr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonijn%2Fmqtt4dsmr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonijn%2Fmqtt4dsmr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonijn%2Fmqtt4dsmr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antonijn","download_url":"https://codeload.github.com/antonijn/mqtt4dsmr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253171250,"owners_count":21865290,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker-compose","dsmr","home-assistant","mqtt","quadlet"],"created_at":"2024-12-17T21:16:37.612Z","updated_at":"2025-05-09T00:55:06.229Z","avatar_url":"https://github.com/antonijn.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DSMR Smart Meter MQTT Client\n\nLightweight containerized Dutch Smart Meter (_Slimme Meter_) to MQTT\ndaemon, with automatic Home Assistant integration.\n\nUses [paho-mqtt](https://pypi.org/project/paho-mqtt/) and\n[ndokter/dsmr_parser](https://github.com/ndokter/dsmr_parser) to do the\nheavy lifting.\n\n![Automatic Home Assistant Discovery Demo](./sensor.png)\n\n## Is this you?\nYou've been running Home Assistant on a Raspberry Pi in the _meterkast_\nfor a while. You've hooked it up directly to your Smart Meter's P1 port\nwith a USB cable, and you're happily using the built-in [DSMR Slimme\nMeter](https://www.home-assistant.io/integrations/dsmr/) integration.\n\nBut now you want to move Home Assistant to a server in the attic, without\nphysical access to your Smart Meter. You want to keep using your Raspberry\nPi to read the Smart Meter, and want to use the MQTT protocol to send the\ndata upstairs. You want a turn-key, easy to configure, well-engineered\napplication for the job.\n\nIn that case mqtt4dsmr is right for you!\n\n## Usage\n### Trying it out\nThe example uses `podman` since I'm more familiar with it than `docker`,\nbut they should be relatively interchangeable.\n\nWhen using rootless containers, make sure your user has the right group\nmembership to access serial ports (this is why the `--group-add` option\nis there). On Fedora Linux this group is called `dialout`.\n\n```\npodman run -d                                             \\\n    --name mqtt4dsmr                                      \\\n    --group-add keep-groups                               \\\n    --tz=local                                            \\\n    --env MQTT_HOST=mqtt.home.example.org                 \\\n    --env MQTT_PORT=1883                                  \\\n    --env MQTT_USERNAME=my_user                           \\\n    --env MQTT_PASSWORD=my_password                       \\\n    --device /dev/serial/by-id/usb-MY_DEVICE:/dev/ttyDSMR \\\n    ghcr.io/antonijn/mqtt4dsmr\n```\n\n### Automated execution (docker-compose)\nIf you have little experience with containers and/or are running on\nRaspberry Pi OS, this is the recommended method.\n\nExample `compose.yaml`:\n\n```yaml\nversion: \"3\"\n\nservices:\n  mqtt4dsmr:\n    image: \"ghcr.io/antonijn/mqtt4dsmr:latest\"\n    environment:\n      MQTT_HOST: \"mqtt.home.example.org\"\n      MQTT_PORT: \"1883\"\n      MQTT_USERNAME: \"my_user\"\n      MQTT_PASSWORD: \"my_password\"\n    devices:\n      - \"/dev/serial/by-id/usb-MY_DEVICE:/dev/ttyDSMR\"\n    restart: always\n```\n\nUse additional environment variables as required, per the documentation\nbelow.\n\nRun `docker compose up -d` to start the application. There are multiple\nways to enable docker compose at system start-up. One method is to place\nthe above configuration in `/etc/docker/compose/mqtt4dsmr/docker-compose.yml`,\nand follow [this guide](https://gist.github.com/mosquito/b23e1c1e5723a7fd9e6568e5cf91180f/18a4efee062cda1a5b6807e440f891fd6bfb4f78).\nRunning `systemctl enable --now docker-compose@mqtt4dsmr` should then\ndo the trick.\n\n### Automated execution (Quadlet)\nPut the following in `~/.config/containers/systemd/mqtt4dsmr.container`:\n\n```\n[Unit]\nDescription=De Slimme Meter MQTT Client\nAfter=network-online.target\n\n[Container]\nContainerName=mqtt4dsmr\nImage=ghcr.io/antonijn/mqtt4dsmr:latest\nAnnotation=run.oci.keep_original_groups=1\nEnvironment=MQTT_HOST=mqtt.home.example.org\nEnvironment=MQTT_PORT=1883\nEnvironment=MQTT_USERNAME=my_user\nEnvironment=MQTT_PASSWORD=my_password\nAddDevice=/dev/serial/by-id/usb-MY_DEVICE:/dev/ttyDSMR\nTimezone=local\n\n[Service]\nRestart=always\n\n[Install]\nWantedBy=default.target\n```\n\nUse additional environment variables as required, per the documentation\nbelow.\n\nEnable the container using `systemctl --user start mqtt4dsmr`. To\nautomatically start the daemon at system start-up while using rootless\ncontainers, enable lingering for your user: `loginctl enable-linger \u003cmy-user\u003e`.\n\n## Options\nOptions must be given to the container as environment variables.\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003eOption\u003c/td\u003e\n\u003ctd\u003eDescription\u003c/td\u003e\n\u003ctd\u003eDefault\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n`MQTT_HOST`\n\n\u003c/td\u003e\n\u003ctd\u003e\n\nIP address or URL for MQTT broker.\n\n\u003c/td\u003e\n\u003ctd\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n`MQTT_PORT`\n\n\u003c/td\u003e\n\u003ctd\u003e\n\nBroker MQTT port. If set to 8883 and `MQTT_TLS` is not\nexplicitly defined, then `MQTT_TLS` defaults to `true`. (Optional)\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n1883\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n`MQTT_USERNAME`\n\n\u003c/td\u003e\n\u003ctd\u003e\n\nMQTT username. (Optional)\n\n\u003c/td\u003e\n\u003ctd\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n`MQTT_PASSWORD`\n\n\u003c/td\u003e\n\u003ctd\u003e\n\nMQTT password. (Optional if `MQTT_USERNAME` is not set)\n\n\u003c/td\u003e\n\u003ctd\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n`MQTT_TLS`\n\n\u003c/td\u003e\n\u003ctd\u003e\n\nUse MQTT over TLS. If set to `true` and `MQTT_PORT` is not\nexplicitly defined, then `MQTT_PORT` defaults to 8883. (Optional)\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n`false`\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n`MQTT_TLS_INSECURE`\n\n\u003c/td\u003e\n\u003ctd\u003e\n\nDisable hostname verification for MQTT over TLS. (Optional)\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n`false`\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n`MQTT_CA_CERTS`\n\n\u003c/td\u003e\n\u003ctd\u003e\n\nCA bundle file for broker verification. Only relevant for MQTT\nover TLS. (Optional)\n\n\u003c/td\u003e\n\u003ctd\u003e\n\nsystem CA bundle\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n`MQTT_CERTFILE`\n\n\u003c/td\u003e\n\u003ctd\u003e\n\nClient certificate for authentication. (Optional)\n\n\u003c/td\u003e\n\u003ctd\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n`MQTT_KEYFILE`\n\n\u003c/td\u003e\n\u003ctd\u003e\n\nClient keyfile for authentication. (Optional)\n\n\u003c/td\u003e\n\u003ctd\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n`MQTT_TOPIC_PREFIX`\n\n\u003c/td\u003e\n\u003ctd\u003e\n\nTopic prefix for application MQTT traffic. You should probably\nnot change the default values unless you know it will conflict.\n(Optional)\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n`dsmr`\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n`HA_DEVICE_ID`\n\n\u003c/td\u003e\n\u003ctd\u003e\n\nHome Assistant internal device ID. You should probably not\nchange the default values unless you know it will conflict.\n(Optional)\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n`dsmr`\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n`HA_DISCOVERY_PREFIX`\n\n\u003c/td\u003e\n\u003ctd\u003e\n\nHome Assistant discovery prefix. This should match the value\nyou have configured in your Home Assistant MQTT integration.\nIf you have not configured such a value, then don't change this\noption. (Optional)\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n`homeassistant`\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n`DSMR_VERSION`\n\n\u003c/td\u003e\n\u003ctd\u003e\n\nDutch Smart Meter Specification version. Can be one of\n`AUSTRIA_ENERGIENETZE_STEIERMARK`, `BELGIUM_FLUVIUS`,\n`EON_HUNGARY`, `ISKRA_IE`, `LUXEMBOURG_SMARTY`, `Q3D`,\n`SAGEMCOM_T210_D_R`, `SWEDEN`, `V2_2`, `V3`, `V4`, `V5`. See\n[ndokter/dsmr_parser](https://github.com/ndokter/dsmr_parser)\nfor more information. (Optional)\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n`V4`\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n`SERIAL_SETTINGS`\n\n\u003c/td\u003e\n\u003ctd\u003e\n\nSerial settings. Is probably related to your `DSMR_VERSION`\nsetting. Worth playing around with if things don't work\ninitially. Can be one of `V2_2`, `V4`, `V5`. See\n[ndokter/dsmr_parser](https://github.com/ndokter/dsmr_parser)\nfor more information. (Optional)\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n`V4`\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n`SERIAL_DEVICE`\n\n\u003c/td\u003e\n\u003ctd\u003e\n\nPath to serial device file.\n\n**NOTE:** This option is for testing purposes only. When running in a\ncontainer, `SERIAL_DEVICE` always has the value `/dev/ttyDSMR` and\ncannot be overridden. Make sure to map the host device accordingly.\n\n\u003c/td\u003e\n\u003ctd\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n`MESSAGE_INTERVAL`\n\n\u003c/td\u003e\n\u003ctd\u003e\n\nMinimum average interval between messages in seconds. Set to positive\nvalue to enable rate limiting. (Optional)\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n0\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n`LOG_LEVEL`\n\n\u003c/td\u003e\n\u003ctd\u003e\n\nLogging level. Must be `DEBUG`, `INFO`, `WARNING`, `ERROR` or\n`CRITICAL`. (Optional)\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n`INFO`\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n## Hardware support\nAutomated builds are available for AMD64, ARM64 and ARMv7. This means\nmqtt4dsmr should run on any x86-based personal computer, all\nsecond generation (or newer) Raspberry Pis and all second generation\n(or newer) Raspberry Pi Zeros.\n\nFirst generation Raspberry Pis are not supported at the moment, since\nARMv6 builds are currently not possible. This is because recent versions\nof the `cryptography` package (required by `dlms-cosem`, in turn\nrequired by `dsmr-parser`) are\n[broken on ARMv6](https://github.com/antonijn/mqtt4dsmr/issues/2#issuecomment-1937367419).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonijn%2Fmqtt4dsmr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantonijn%2Fmqtt4dsmr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonijn%2Fmqtt4dsmr/lists"}