Very new to HA, got Tasmota switch devices flashed, networked and discovered, and on the dashboard, and the switches work which is great.
Also got a working Tasmota RF-Bridge, which sends MQTT messages when it receives an RF code from 433MHz device.
Now I have some RF433 lightswitches which generate a code, and the RF-Bridge sends an MQTT message when it receives it to:
topic = Dragon/Switches/RESULT
message =
type: toggle
device_id: cb4825a585ed4309a0b89267cb643fe6
entity_id: switch.sonoff_3
domain: switch
mode: single
The execute button on the configuration page works, but the MQTT messages don’t trigger the automation.
As its a sub-string in the mqtt message, I think I’m probably looking for a “contains” sort of selection, (if such a thing exists), as some of those other values in the string change from time to tims (due to rf variations). But it’s always presented as “Data”:“AF9694” within the message.
Clearly I’m missing something, any suggestions welcome.
Thanks in advance
Lee
P.S. This is a WAY better mechanism than my web-based response to an Amazon Dash Button!
The biggest issue with this sort of thing is not finding the answer you want, but maybe some kind of workaround because it kinda works…not what I wanted but…
Anyway, I’ve found two possible answers, neither of which works, based on ignoring the optional “MQTT Payload” (which seemed the obvious way to me, but I know nothing of HA).
Remove the (optional) payload & it activates the target as hoped, but does do for all the switches!
So Add a condition, which looks for a condition in the payload. Two methods I’ve found:
Look for a variable in the MQTT message -or-
Just look for any string within the MQTT message which matches the unique string for each lightswitch.
Option1 - specific variable in the string:
I’ve found any number of variations on this theme, one of which is this:
value_template: “{{ trigger.payload_json.RfReceived.Data == AF9694 }}”
Please suggest if I have the syntax wrong, I’vetried half a dozen variations, but happy to be told.
Option2 - find anything in the string which matches:
value_template: “{{ ‘AF9694’ in trigger.payload }}”
Again, tried lots of variations, please suggest if there’s a right one!
Thanks in advance for the nudge
Lee
PS - any ideas on where I can find some kind of debug log to tell me what’s actually going on?
It’s a black box currently.
(btw - Isn’t it fussy about indentations?)(I’m pleased it stopped showing red errors!)
Tried “ON” and “TOGGLE” and a few others, but not getting it.
Also can’t see what that “binary_sensor.xxxx” variable should be.
Article is great but assuming I know more than I do…
I really don’t think Strategy 2 is an option for someone as neophyte as me yet.
The other two methods I left earlier were also taken from found examples, but they don’t work either.
Normally when coding, there are methods to debug your code, such as a debug window, log, or in less helpful cases using “print” and break points to show values while the program is running, just to help understand what’s going on.
Is there any such approach in HA?
I really want to become self-sufficient in this.
Any further suggestions (pref with a wider level of context please) very gratefuly received.
TIA
“Strategy 1” describes how to create a value_template for a Template Binary Sensor. What you have posted above shows it is being used in a condition. That’s not the intended way to use it so it’s no surprise that it’s “not working”.
Follow the instructions, described in Strategy 1, to define a Template Binary Sensor.
Thanks but I don’t know what file that is supposed to be in, configuration, automations, scenes, scripts or something else?
I’m new to this, so maybe it’s obvious to a seasoned user, but I can’t tell.
TIA
It sounds like you need to review some of Home Assistant’s core concepts. If you’re planning to implement Strategy 1, you will need to learn about creating Template Binary Sensors. The very first page of the documentation for Template Binary Sensors indicates which file is used. It’s configuration.yaml. It can be in a different file but if only if you have split your configuration. However, I doubt you’ve done that.