I have a rflink connected via MQTT. Now I try to define the switches.
This is what I have now :
binary_sensor.yaml:
- platform: mqtt
name: sensorTVboven
state_topic: 'rflink/NewKaku-03a0b800'
value_template: >-
{% if value_json.SWITCH == "2" and value_json.CMD == "ON" %}
{{'ON'}}
{% elif value_json.SWITCH == "2" and value_json.CMD == "OFF" %}
{{'OFF'}}
{% else %}
{{states('binary_sensor.switchTVboven') | upper}}
{% endif %}
switch.yaml :
- platform: template
switches:
tvboven:
value_template: "{{ is_state('binary_sensor.sensorTVboven', 'on') }}"
turn_on:
- service: mqtt.publish
data:
payload: '10;newkaku;03a0b800;2;on;'
topic: rflink/cmd
- service: mqtt.publish
data:
payload: '{"SWITCH":"2","CMD":"ON"}'
topic: 'rflink/NewKaku-03a0b800'
turn_off:
- service: mqtt.publish
data:
payload: '10;newkaku;03a0b800;2;off;'
topic: rflink/cmd
- service: mqtt.publish
data:
payload: '{"SWITCH":"2","CMD":"OFF"}'
topic: 'rflink/NewKaku-03a0b800'
I wonder if it can be done without the binary_sensor ?