enhancements to mqtt reporting script

44 views
Skip to first unread message

Greg Troxel

unread,
Apr 17, 2022, 7:33:17 PM4/17/22
to rtl...@googlegroups.com

(I have paged rtl_433 back in after an absence due to hardware issues.)

I have been using rtl_433_mqtt_relay.py to send data to Home Assistant,
and there are some things I wish were different. I realize I can do
whatever I want locally, so this messages is

- asking for advice if you think I'm confused

- seeing which of these changes are likely to be acceptable for
merging upstream.

My proposed list of changes:

1) Use a config file instead of having parameters hard-coded in the
file.
- listening IP address
- listening port
- mqtt IP address
- mqtt port
- mqtt topic prefix

I wrote a program (not yet published, but I intend to), to poll ups-nut
and send UPS status to mqtt. Rather than hard-code, it reads a json
dictionary from ~/.ups2mqtt with config names and values. That's a
nerd-writable format, easy to implement in very few lines of python, and
meets the goal of separating config from code that's checked in.

2) Add config variables for
- mqtt username
- mqtt password
- whether to use TLS or not

Right now one has to add two lines for code for this, and in my world
authentication and transport encryption are normal.

3) Rationalize the json vs not somehow. Perhaps just send json, perhaps
have a config variable "data_style" (?) that is an array of
- json
- individual
where it's an error to have an empty array and the default is json (or
both; I don't really care as long as I can have only json).

4) Change the topic to also include the id, at least more often. I am
seeing
rtl_433/Acurite-Tower/A/battery
which is missing the id, and two of them cannot be separated. This is
not backwards compat but I view this as experimental and would expect
almost everyone that would be affected would prefer this change. But
tell me if I'm confused.

and probably I'll think of more. I'm inclined to do the ones y'all like
first and submit a PR, and I can keep the others privately.



signature.asc

Greg Troxel

unread,
Apr 18, 2022, 9:14:07 AM4/18/22
to rtl...@googlegroups.com

Greg Troxel <g...@lexort.com> writes:

> My proposed list of changes:

5) Document as for python3 only. Change env lines to python3. I don't
see any reason anyone would actually want to use python2.7 with these --
they don't need to be included in a larger python program that's stuck
on 2.7, and surely nobody has computers that can't run python3 but
somehow work with built-in-2022 rtl_433.

6) Create python subdir, setup.py, and migrate scripts to it, so if you
build that (as could be done by a packaging system, or by hand), these
get properly installed. Implies dropping contrib label.


51) very maybe, think about how the mqtt hass script relates, and
perhaps merge it making the hass discovery topics an option, figuring
out what else is different and why.
signature.asc
Reply all
Reply to author
Forward
0 new messages