I am trying to use some of the relays in a Shelly 4PRO in “detached mode”, i.e., to use the GPIO switches as sensors whose status is not related with that of the relays.
I can control all relays pretty easily via mqtt, but haven’t figured out how to get switch status yet.
My tentative sensor setup is:
Thanks @gpbenton - I’ve removed the availability topic and now I can get the switch status.
However, the sensor now shows “Unknown” value since HA is started and until the first switch status change.
Is there a way HA can poll the initial switch status too?
There are actually two possible ways, either or both may work depending on the capabilities of the shelly, of which I know nothing.
Tell the Shelly to send the state message with the retain flag set. This causes the MQTT broker to save the message and send it to any client that subscribes to that topic, such as when HA starts up.
Configure a script that runs when HA starts up to send an mqtt message to the shelly to send its status. I’m afraid I don’t know what that command might be.