I managed to run Tasmota on an Sonoff RF Bridge and have a basic 433Mhz plug configured to turn on and off using 2 ‘keys’ in the Tasmota configuration.
To activate the plug, I use the following topic:
cmnd/ground_floor_rf_bridge/RfKey1
To disable the plug, I use another topic:
cmnd/ground_floor_rf_bridge/RfKey2
Both use an empty payload. Is there a way to combine these two topics into a single command_topic for an MQTT Switch or another way to achieve this?
The Sonoff RF Bridge in total supports 16 keys to learn.
After some searching and tinkering I came up with the following solution:
Create an input_boolean to act as the switch
christmas_tree_lights_switch:
name: Christmas Tree Lights Switch
initial: off
icon: mdi:pine-tree
Create an automation with a data_templateto decide which topic to use
#########################################
# Publish switch change via MQTT to RF #
#########################################
- id: mqtt_publish_switch_rf
alias: Publish switch change via MQTT to RF
initial_state: "on"
trigger:
- platform: state
entity_id: input_boolean.christmas_tree_lights_switch
action:
- service: mqtt.publish
data_template:
topic: >
{%- if trigger.entity_id == "input_boolean.christmas_tree_lights_switch" and states.input_boolean.christmas_tree_lights_switch.state == "on" -%}
cmnd/ground_floor_rf_bridge/RfKey1
{%- elif trigger.entity_id == "input_boolean.christmas_tree_lights_switch" and states.input_boolean.christmas_tree_lights_switch.state == "off" -%}
cmnd/ground_floor_rf_bridge/RfKey2
{% endif %}
payload: ''
The automation checks the trigger.entity_id in order to be able to extend it for multiple input_boolean switches instead of creating multiple automations for it.
Another possible solution I found was using a command_line switch as mentioned in the following posting, but I wanted to try to use only functionalitiy offered by Home Assistant: