Skip to content

Commit

Permalink
Merge pull request #131 from allangood/dev
Browse files Browse the repository at this point in the history
Version 2.1.0
  • Loading branch information
allangood authored May 17, 2022
2 parents 635d4aa + 92eabaf commit 20bf0a5
Show file tree
Hide file tree
Showing 7 changed files with 470 additions and 361 deletions.
24 changes: 24 additions & 0 deletions .devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "Example devcontainer for add-on repositories",
"image": "ghcr.io/home-assistant/devcontainer:addons",
"appPort": ["7123:8123", "7357:4357"],
"postStartCommand": "bash devcontainer_bootstrap",
"runArgs": ["-e", "GIT_EDITOR=code --wait", "--privileged"],
"containerEnv": {
"WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}"
},
"extensions": ["timonwong.shellcheck", "esbenp.prettier-vscode"],
"mounts": [ "type=volume,target=/var/lib/docker" ],
"settings": {
"terminal.integrated.profiles.linux": {
"zsh": {
"path": "/usr/bin/zsh"
}
},
"terminal.integrated.defaultProfile.linux": "zsh",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true
}
}
20 changes: 20 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Start Home Assistant",
"type": "shell",
"command": "supervisor_run",
"group": {
"kind": "test",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
}
]
}

98 changes: 58 additions & 40 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,63 +1,81 @@
### 2022-05-17

- Bug fixes for remote rtl_tcp and usb_reset logic #123
- Code changes to load config file and merge defaults
- Added vscode files to test the Addon development (finally!)

### 2022-04-12
- **REMOVED PARAMETER** usb_reset
- **ADDED PARAMETER** device_id
- **Changed Dockerfile**: Much smaller docker container
- Deprecated Anomaly detection (looks like no one is using it and it's not very reliable)

- **REMOVED PARAMETER** usb_reset
- **ADDED PARAMETER** device_id
- **Changed Dockerfile**: Much smaller docker container
- Deprecated Anomaly detection (looks like no one is using it and it's not very reliable)

### 2022-04-12
- New `tls_enabled` parameter to avoid confusions
- Some fixes for the Add-On regarding the TLS configuration

- New `tls_enabled` parameter to avoid confusions
- Some fixes for the Add-On regarding the TLS configuration

### 2022-04-04
- New TLS parameters to MQTT connection
- New parameter: USB_RESET to address problem mentioned on #98

- New TLS parameters to MQTT connection
- New parameter: USB_RESET to address problem mentioned on #98

### 2022-02-11
- New configuration parameter: `state_class` (thanks to @JeffreyFalgout)
- Automatic MQTT configuration when using the Addon (thanks to @JeffreyFalgout)
- Fixed 255 characters limit for state value #86

- New configuration parameter: `state_class` (thanks to @JeffreyFalgout)
- Automatic MQTT configuration when using the Addon (thanks to @JeffreyFalgout)
- Fixed 255 characters limit for state value #86

### 2022-01-11
- Happy new year! :)
- Added "tickle_rtl_tcp" parameter to enable/disable the feature (explained below)
- Added date/time to the log output
- Added device_class configuration option #66 (thanks to @phidauex)
- Some clean up in the README file!
- Machine Learning to detect leaks still experimental and needs a lot of love to work properly

- Happy new year! :)
- Added "tickle_rtl_tcp" parameter to enable/disable the feature (explained below)
- Added date/time to the log output
- Added device_class configuration option #66 (thanks to @phidauex)
- Some clean up in the README file!
- Machine Learning to detect leaks still experimental and needs a lot of love to work properly

### 2021-12-01
- Lots of changes!
- Changed Docker container to use Debian Bullseye instead of Alpine
- Added TinyDB to store past readings
- Added Linear Regression to flag anomaly usage
- Problems with the official python docker base image :(

- Lots of changes!
- Changed Docker container to use Debian Bullseye instead of Alpine
- Added TinyDB to store past readings
- Added Linear Regression to flag anomaly usage
- Problems with the official python docker base image :(

### 2021-10-27
- Many fixes regarding error handling
- More comments inside the code
- Some code cleanup
- Fix a bug for MQTT anonymous message publishing discovered by @jeffeb3
- Using latest code for both rtl-sdr and rtamr in the Dockerfile

- Many fixes regarding error handling
- More comments inside the code
- Some code cleanup
- Fix a bug for MQTT anonymous message publishing discovered by @jeffeb3
- Using latest code for both rtl-sdr and rtamr in the Dockerfile

### 2021-10-12
- The HA-ADDON is working now! A shout-out to @AnthonyPluth for his hard work!!! \o/
- New feature to allow this container to run with a remote rtl_tcp. Thanks to @jonbloom
- A bug was introduced by #28 and has been fixed.

- The HA-ADDON is working now! A shout-out to @AnthonyPluth for his hard work!!! \o/
- New feature to allow this container to run with a remote rtl_tcp. Thanks to @jonbloom
- A bug was introduced by #28 and has been fixed.

### 2021-09-23:
- New images are based on Alpine 3.14 *** IMPORTANT ***
- If this container stops to work after you upgrade, please read this: [https://docs.linuxserver.io/faq](https://docs.linuxserver.io/faq)
- We are working in a new image: HA-ADDON! Thanks to @AnthonyPluth ! Stay tuned for news about it!

- New images are based on Alpine 3.14 **_ IMPORTANT _**
- If this container stops to work after you upgrade, please read this: [https://docs.linuxserver.io/faq](https://docs.linuxserver.io/faq)
- We are working in a new image: HA-ADDON! Thanks to @AnthonyPluth ! Stay tuned for news about it!

### 2021-09-13:
- A new configuration parameter has been added: *verbosity*
- Environment variable *DEBUG* has been renamed to *LISTEN_ONLY* to prevent confusion
- Better error handling and output (still work in progress)

- A new configuration parameter has been added: _verbosity_
- Environment variable _DEBUG_ has been renamed to _LISTEN_ONLY_ to prevent confusion
- Better error handling and output (still work in progress)

### 2021-09-09
- Added last Will and testment messages
- Added availability status topic
- Added RTL_MSGTYPE to debug mode

- Added last Will and testment messages
- Added availability status topic
- Added RTL_MSGTYPE to debug mode

### 2021-09-03
- Added DEBUG Mode

- Added DEBUG Mode
61 changes: 44 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@

### RTLAMR2MQTT

[![Build Status](https://app.travis-ci.com/allangood/rtlamr2mqtt.svg?branch=main)](https://app.travis-ci.com/allangood/rtlamr2mqtt)
[![Docker Pulls](https://img.shields.io/docker/pulls/allangood/rtlamr2mqtt)](https://hub.docker.com/r/allangood/rtlamr2mqtt)

This project was created to send readings made by RTLAMR + RTL_TCP to a MQTT broker.
My user case is to integrate it with Home Assistant.

### Noteworthy Updates

### 2022-05-17

- Bug fixes for remote rtl_tcp and usb_reset logic #123
- Code changes to load config file and merge defaults
- Added vscode files to test the Addon development (finally!)

### 2022-04-12

- **REMOVED PARAMETER** usb_reset
- **ADDED PARAMETER** device_id
- **DEPRECATED** Anomaly detection (looks like no one is using it and it's not very reliable)
- **Changed Dockerfile**: Much smaller docker container

### 2022-04-12
- **REMOVED PARAMETER** usb_reset
- **ADDED PARAMETER** device_id
- **DEPRECATED** Anomaly detection (looks like no one is using it and it's not very reliable)
- **Changed Dockerfile**: Much smaller docker container

*2022-04-12*
- New `tls_enabled` parameter to avoid confusions
- Some fixes for the Add-On regarding the TLS configuration
- New `tls_enabled` parameter to avoid confusions
- Some fixes for the Add-On regarding the TLS configuration

*2022-04-04*
- New TLS parameters to MQTT connection
- New parameter: USB_RESET to address problem mentioned on #98
### 2022-04-04

*2022-02-11*
- New configuration parameter: `state_class` (thanks to @JeffreyFalgout)
- Automatic MQTT configuration when using the Addon (thanks to @JeffreyFalgout)
- Fixed 255 characters limit for state value #86
- New TLS parameters to MQTT connection
- New parameter: USB_RESET to address problem mentioned on #98

# Readme starts here

### What do I need?

**1) You need a smart meter**
First and most important, you must have a "smart" water/gas/energy meter. You can find a list of compatible meters [here](https://github.com/bemasher/rtlamr/blob/master/meters.csv)

Expand All @@ -44,12 +50,15 @@ I am using this one: [NooElec NESDR Mini USB](https://www.amazon.ca/NooElec-NESD
![image](https://user-images.githubusercontent.com/757086/117556120-207bd200-b02b-11eb-9149-58eaf9c6c4ea.png)

### How to run and configure?

Docker and Docker-compose are the most indicated way.
If you are not [running the add-on](https://www.home-assistant.io/common-tasks/os#installing-third-party-add-ons), you must write the **rtlamr2mqtt.yaml** configuration file.

#### Configuration file sample

Create the config file on `/opt/rtlamr2mqtt/rtlamr2mqtt.yaml` for instance.
The configuration must looks like this:

```
# -- Configuration file starts here --
# (Optional section)
Expand Down Expand Up @@ -138,8 +147,11 @@ meters:
device_class: energy
# -- End of configuration file --
```

#### Run with docker

If you want to run with docker alone, run this command:

```
docker run --name rtlamr2mqtt \
-v /opt/rtlamr2mqtt/rtlamr2mqtt.yaml:/etc/rtlamr2mqtt.yaml \
Expand All @@ -148,8 +160,11 @@ docker run --name rtlamr2mqtt \
--restart unless-stopped \
allangood/rtlamr2mqtt
```

#### Run with docker-compose

If you use docker-compose (recommended), add this to your compose file:

```
version: "3"
services:
Expand All @@ -165,7 +180,9 @@ services:
```

### Home Assistant utility meter configuration (sample):

To add your meters to Home Assistant, add a section like this:

```
utility_meter:
hourly_water:
Expand All @@ -182,44 +199,54 @@ utility_meter:
#### Finding USB Device ID

Using lsusb to find USB Device ID:

```
$ lsusb
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 002: ID 0bda:2838 Realtek Semiconductor Corp. RTL2838 DVB-T
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
```

Device ID => **0bda:2838**

#### Manual HA configuration (if ha_autodiscovery = false)

If you have `ha_autodiscovery: false` in your configuration, you will need to manually add the sensors to your HA configuration.

This is a sample for a water meter using the configuration from the sample configuration file:

```
sensor:
- platform: mqtt
name: "My Utility Meter"
state_topic: rtlamr/meter_water/state
unit_of_measurement: "\u33A5"
```

You must change `meter_water` with the name you have configured in the configuration YAML file (below)

### I don't know my meters ID, what can I do?

**How to run the container in LISTEN ALL METERS Mode:**
If you don't know your Meter ID or the protocol to listen, you can run the container in DEBUG mode to listen for everything.

In this mode, rtlamr2mqtt will ***not read the configuration file***, this means that nothing is going to happen other than print all meter readings on screen!
In this mode, rtlamr2mqtt will **_not read the configuration file_**, this means that nothing is going to happen other than print all meter readings on screen!

```
docker run --rm -ti -e LISTEN_ONLY=yes -e RTL_MSGTYPE="all" --device=/dev/bus/usb:/dev/bus/usb allangood/rtlamr2mqtt
```

If you have multiple RTL-SDRs and wish to start the LISTEN ALL METERS mode on a specific device ID (or use other custom RTL_TCP arguments), add the argument: `-e RTL_TCP_ARGS="-d <serial-number>"`. For example:

```
docker run --rm -ti -e LISTEN_ONLY=yes -e RTL_MSGTYPE="all" -e RTL_TCP_ARGS="-d 777" --device=/dev/bus/usb:/dev/bus/usb allangood/rtlamr2mqtt
```


### Thanks to

A big thank you for all kind contributions! And a even bigger thanks to these kind contributors:

- [AnthonyPluth](https://github.com/AnthonyPluth)
- [jonbloom](https://github.com/jonbloom)
- [jeffeb3](https://github.com/jeffeb3)
Expand Down
14 changes: 6 additions & 8 deletions rtlamr2mqtt-addon/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rtlamr2mqtt",
"version": "2.0.1",
"version": "2.1.0",
"slug": "rtlamr2mqtt",
"panel_icon": "mdi:gauge",
"description": "RTLAMR to MQTT Bridge",
Expand Down Expand Up @@ -33,6 +33,7 @@
"mqtt": {
"ha_autodiscovery": true,
"ha_autodiscovery_topic": "homeassistant",
"base_topic": "rtlamr",
"tls_enabled": false,
"tls_ca": "/etc/ssl/certs/ca-certificates.crt",
"tls_cert": "/etc/ssl/my_self_signed_cert.crt",
Expand Down Expand Up @@ -63,17 +64,14 @@
"device_id": "match((^single|^(0[xX])?[A-Fa-f0-9]+:(0[xX])?[A-Fa-f0-9]+$))"
},
"mqtt": {
"host": "str?",
"port": "int?",
"ha_autodiscovery": "bool?",
"ha_autodiscovery_topic": "str?",
"base_topic": "str",
"tls_enabled": "bool?",
"tls_ca": "str?",
"tls_cert": "str?",
"tls_keyfile": "str?",
"tls_insecure": "bool?",
"user": "str?",
"password": "str?",
"ha_autodiscovery": "bool?",
"ha_autodiscovery_topic": "str?"
"tls_insecure": "bool?"
},
"custom_parameters": {
"rtltcp": "str?",
Expand Down
Loading

0 comments on commit 20bf0a5

Please sign in to comment.