Comments (8)
OK you're on to something here.
I started with adding two echos, the first being at the top of run.sh
#!/usr/bin/with-contenv bashio
echo "DEVICE_TOPIC_SUFFIX: $DEVICE_TOPIC_SUFFIX"
echo "OTHER_ARGS: $OTHER_ARGS"
And right at the end:
echo "Starting rtl_433_mqtt_hass.py..."
echo "DEVICE_TOPIC_SUFFIX: $DEVICE_TOPIC_SUFFIX"
echo "OTHER_ARGS: $OTHER_ARGS"
python3 -u /rtl_433_mqtt_hass.py -H $MQTT_HOST -p $MQTT_PORT -R "$RTL_TOPIC" -D "$DISCOVERY_PREFIX" -i $DISCOVERY_INTERVAL $OTHER_ARGS
When I run the script, it does not include our suffix in the OTHER_ARGS:
/ # bash run.sh
DEVICE_TOPIC_SUFFIX: devices[/type][/model][/subtype]/C[channel:0]
OTHER_ARGS:
Running in stand-alone docker mode
Starting rtl_433_mqtt_hass.py...
DEVICE_TOPIC_SUFFIX: devices[/type][/model][/subtype]/C[channel:0]
OTHER_ARGS: --debug
INFO:root:Enabling debug logging```
What caught my eye was the "Running in stand-alone docker mode" which I think means it is skipping the section around [row 44](https://github.com/pbkhrv/rtl_433-hass-addons/blob/main/rtl_433_mqtt_autodiscovery/run.sh#L44-L48C4) where the DEVICE_TOPIC_SUFFIX is set!
So I added the following to the bottom of the first if:
```bash
DEVICE_TOPIC_SUFFIX="${DEVICE_TOPIC_SUFFIX}"
echo "DEVICE_TOPIC_SUFFIX: $DEVICE_TOPIC_SUFFIX"
echo "OTHER_ARGS: $OTHER_ARGS"
if [ ! -z $DEVICE_TOPIC_SUFFIX ]; then
OTHER_ARGS="${OTHER_ARGS} -T ${DEVICE_TOPIC_SUFFIX}"
fi
echo "DEVICE_TOPIC_SUFFIX: $DEVICE_TOPIC_SUFFIX"
echo "OTHER_ARGS: $OTHER_ARGS"
Which got us to this, which I think is progress.
/ # bash run.sh
DEVICE_TOPIC_SUFFIX: devices[/type][/model][/subtype]/C[channel:0]
OTHER_ARGS:
Running in stand-alone docker mode
DEVICE_TOPIC_SUFFIX: devices[/type][/model][/subtype]/C[channel:0]
OTHER_ARGS: --debug
DEVICE_TOPIC_SUFFIX: devices[/type][/model][/subtype]/C[channel:0]
OTHER_ARGS: --debug -T devices[/type][/model][/subtype]/C[channel:0]
Starting rtl_433_mqtt_hass.py...
DEVICE_TOPIC_SUFFIX: devices[/type][/model][/subtype]/C[channel:0]
OTHER_ARGS: --debug -T devices[/type][/model][/subtype]/C[channel:0]
usage: rtl_433_mqtt_hass.py [-h] [-d] [-q] [-u USER] [-P PASSWORD] [-H HOST] [-p PORT] [-c CA_CERT] [-r] [-f] [-R RTL_TOPIC] [-D DISCOVERY_PREFIX] [-i DISCOVERY_INTERVAL] [-x EXPIRE_AFTER] [-I IDS [IDS ...]]
rtl_433_mqtt_hass.py: error: unrecognized arguments: -T devices[/type][/model][/subtype]/C[channel:0]
If I'm reading it right, the updated code is now trying to pass the -T <suffix>
along, but the rtl_433_mqtt_hass.py
script is saying it doesn't take that variable?
Skimming rtl_433_mqtt_hass.py
, I don't see anything to process -T
, and the header is missing the chunk about how to use -T
, and the script overall is 100ln+ shorter than what is over at the rtl_433 project hyperlink to row 20 from merbanan/rtl_433/, which is similar but different from the script below (but is the same as what is in 22.11 which...I can't see how that handles anything with regards to the suffix, but, I'm so far from a developer, I could easily be missing it!)
AP_EPILOG="""
It is strongly recommended to run rtl_433 with "-C si" and "-M newmodel".
This script requires rtl_433 to publish both event messages and device
messages.
MQTT Username and Password can be set via the cmdline or passed in the
environment: MQTT_USERNAME and MQTT_PASSWORD.
I feel like the run.sh
and rtl_433_mqtt_hass.py
scripts can't actually consume the suffix, but I'm really not a programmer and might be missing something extremely obvious. I'm happy to keep poking at whatever might help, and I hope the tests today were helpful!
from rtl_433-hass-addons.
@SiGmAX666 thanks for your detailed notes. They got me on the right direction.
It turns out this is actually pretty simple. I thought merbanan/rtl_433@128755c was in the prior stable release, but it wasn't. It was only included in a tag last month. So, this feature is only working with the next version of the addon.
I updated the CHANGELOG to clarify this, and the next stable release of this addon will resolve this for you. Thanks!
from rtl_433-hass-addons.
If you exec into the addon's docker container, do you see the -T
argument in the python arguments if you run ps auxww
? The relevant code that passes it in is at https://github.com/pbkhrv/rtl_433-hass-addons/blob/main/rtl_433_mqtt_autodiscovery/run.sh#L44-L48C4.
from rtl_433-hass-addons.
Ah, interesting, that explains it. No -T
. When I look at the container in
$ docker exec -it rtl433_autodiscovery_test2 sh
/ # ps auxww
PID USER TIME COMMAND
1 root 0:00 /package/admin/s6/command/s6-svscan -d4 -- /run/service
14 root 0:00 {rc.init} /bin/sh -e /run/s6/basedir/scripts/rc.init top /run.sh
15 root 0:00 s6-supervise s6-linux-init-shutdownd
16 root 0:00 /package/admin/s6-linux-init/command/s6-linux-init-shutdownd -c /run/s6/basedir -g 3000 -C -B
24 root 0:00 s6-supervise s6rc-fdholder
25 root 0:00 s6-supervise s6rc-oneshot-runner
33 root 0:00 /package/admin/s6/command/s6-ipcserverd -1 -- /package/admin/s6/command/s6-ipcserver-access -v0 -E -l0 -i data/rules -- /package/admin/s6/command/s6-sudod -t 30000 -- /package/admin/s6-rc/command/s6-rc-oneshot-run -l ../.. --
78 root 0:00 bash /usr/bin/bashio /run.sh
83 root 0:00 python3 -u /rtl_433_mqtt_hass.py -H mosquitto -p 1883 -R rtl_433_2/+/events -D homeassistant -i 600 --debug
85 root 0:00 sh
91 root 0:00 ps auxww
When doing a docker inspect
, I think that things look fine regarding the suffix (passwords removed):
$ docker inspect --format='{{range .Config.Env}}{{println .}}{{end}}' rtl433_autodiscovery_test2
LOG_LEVEL=debug
MQTT_PORT=1883
MQTT_USERNAME=rtl433
DEVICE_TOPIC_SUFFIX=devices[/type][/model][/subtype]/C[channel:0]
MQTT_RETAIN=true
DISCOVERY_PREFIX=homeassistant
MQTT_PASSWORD=
RTL_TOPIC=rtl_433_2/+/events
MQTT_HOST=mosquitto
DISCOVERY_INTERVAL=600
FORCE_UPDATE=true
PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
LANG=C.UTF-8
S6_BEHAVIOUR_IF_STAGE2_FAILS=2
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0
S6_CMD_WAIT_FOR_SERVICES=1
S6_SERVICES_READYTIME=50
And I checked the run.sh
script for good measure, it includes the section in the linked blob, of course:
# This is an optional parameter and we don't want to overwrite the defaults
DEVICE_TOPIC_SUFFIX=$(bashio::config "device_topic_suffix")
if [ ! -z $DEVICE_TOPIC_SUFFIX ]; then
OTHER_ARGS="${OTHER_ARGS} -T ${DEVICE_TOPIC_SUFFIX}"
fi
from rtl_433-hass-addons.
I had a moment where I thought the issue was using [
vs [[
but that’s not it.
Can you add in a few echo’s on the DEVICE_TOPIC_SUFFIX variable, OTHER_ARGS, and so on? That should at least tell us which line is breaking. My guess is that the call to the config is returning an empty string.
from rtl_433-hass-addons.
OK I tried one more thing before calling it a night.
- I rebuilt the container using my original
docker compose
(in the first post here), but changing the HA topic tohomeassistant2
- I did a fresh
wget
for the latest rtl_433_mqtt_hass.py file, and saved it to my docker project folder. - I started the container, and then ran the following to pull the "stock"
run.sh
:
docker cp rtl433_autodiscovery_test2:/run.sh run-aarch64-0_7_0-20231228.sh
- I added the following at row 19:
echo "DEVICE_TOPIC_SUFFIX: $DEVICE_TOPIC_SUFFIX"
echo "OTHER_ARGS: $OTHER_ARGS"
echo ""
# This is an optional parameter and we don't want to overwrite the defaults
# DEVICE_TOPIC_SUFFIX=${DEVICE_TOPIC_SUFFIX}
if [ ! -z $DEVICE_TOPIC_SUFFIX ]; then
OTHER_ARGS="${OTHER_ARGS} -T ${DEVICE_TOPIC_SUFFIX}"
fi
echo "DEVICE_TOPIC_SUFFIX: $DEVICE_TOPIC_SUFFIX"
echo "OTHER_ARGS: $OTHER_ARGS"
echo ""
- I then added two volumes to the
docker-compose.yml
volumes:
- ./rtl_433_mqtt_hass-master-20231228.py:/rtl_433_mqtt_hass.py:ro
- ./run-aarch64-0_7_0-20231228.sh:/run.sh:ro
I then ran the container and the resulting MQTT messages were in the correct format, eg:
{"device_class": "timestamp", "name": "Timestamp", "entity_category": "diagnostic", "enabled_by_default": false, "icon": "mdi:clock-in", "state_topic": "rtl_433_2/localhost/devices/LaCrosse-TX141W/C0/time", "unique_id": "LaCrosse-TX141W-0-UTC", "device": {"identifiers": ["LaCrosse-TX141W-0"], "name": "LaCrosse-TX141W-0", "model": "LaCrosse-TX141W", "manufacturer": "rtl_433"}}
I'm moderately sure its a problem with the 0.7.0 aarch64 build - but I'm not clear how it all goes together when building the images, etc... This dockerfile looks wrong to me, as 22.11 doesn't seem to contain the right variables to handle the suffix. But I'm really in too deep with this, I'm not a dev and can get my wires crossed pretty easily, I might be chasing shadows! (It's also really late, which never helps matters, lol.)
Thanks in advance!
from rtl_433-hass-addons.
@SiGmAX666 This is great work, do you mind helping contribute to my other repo? since this project is abandoned and unmaintained? https://github.com/catduckgnaf/rtl_433_haos_addon
from rtl_433-hass-addons.
Related Issues (20)
- rtl_433 MQTT Auto Discovery (next) does not start HOT 12
- How can you tell which version of rtl_433 you're actively using? HOT 6
- How to install in HA Core? HOT 4
- 0.4.1 Stopped receiving HOT 66
- Is it possible to Filter devices and add fields to data to InfluxDB ? HOT 3
- Auto Discovery publishes SCMPlus time value, skips the rest such as gas meter consumption. Case sensitive? HOT 3
- Device added by Auto Discovery doesn't persist across reboots. "This entity is no longer being provided by the mqtt integration" HOT 2
- on AmbientWeather-TX8300 report Battery statur from rtl_433 MQTT Auto Discovery (next) HOT 6
- Enable devices disabled by default in config?
- New repository HOT 2
- New version 0.8.0 not working HOT 5
- rtl_433 MQTT Auto Discovery will not run after update HOT 6
- Support RTL-SDR Blog V4 Dongle HOT 3
- No MQTT topic visible HOT 2
- Latest version says rtl_433: option requires an argument: F
- Getting started HOT 4
- Config for device trigger conflicts with existing device trigger HOT 3
- rtl_433 does not start anymore HOT 4
- No MQTT topics created - No error in logs HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rtl_433-hass-addons.