Hello, I have an IP relay with four relays and I want to query the port status and store it in Home Assistant. Using the MQTT Explorer, I can retrieve the port status after activating the relays once using the topic:
de/gudesystems/enc/00:19:32:01:8e:b1/switch. How can I query this in my YAML configuration?
Wow, that’s a really good answer to my question.
Maybe I have misunderstood your requirements but the switch you created uses
de/gudesystems/enc/00:19:32:01:8e:b1/switch
as the source for reporting its state.
Therefore the state of switch.gude_switch_4_gartenhuette already reports the state of port 4. Nothing else is needed to report the state of port 4.
Copy-paste this template into the Template Editor and it will report the switch’s state.
{{ states('switch.gude_switch_4_gartenhuette') }}
If you prefer to see the value reported as 1 or 0 instead of on or off then you can do this:
{{ states('switch.gude_switch_4_gartenhuette') | bool | int(0) }}

