I’m new to Home Assistant and I have hass.io running on a Raspberry Pi 3. I have a Arduino MQTT Client connected to my private Mosquito Broker that subscribes to a topic “rftx” and publishes to “rfrx” The “rftx” topic takes a rf code and transmits it to control my Etekcity RF Outlets. The “rfrx” topic publishes any codes picked up by a receiver. I want to use the “rfrx” topic as state control for a switch. The current YAML for my switch is below:
switch:
- platform: mqtt
command_topic: “rftx”
payload_on: “333107”
payload_off: “333116”
I would like to integrate a state topic so I could use the existing remote that came with the outlet to turn it on and off, and have the state of the outlet change in Home Assistant. In order to integrate a state topic, if I understand the docs correctly, I need to have a topic that has either ON or OFF published to it. The easiest solution I can think of is to make a python program that listens to the “rfrx” MQTT topic and the “rftx” MQTT topic and determines the state from both of those. Is this the proper way to tackle this, and if so, how do I setup the script within Home Assistant so that it starts on boot, etc.
Thanks,
KK6AXQ