a_on (need a “on” signal for switching on - simply sending the RF “on” command thru the Sonoff bridge)
a_off (need a “on” signal for switching off - simply sending the RF “off” command thru the Sonoff bridge)
The push buttons work well seperately. Now I started to use the HA template:
The new switch.skylight turns on by toggling. But the toggle switches back automaticallyso I’m not able to switch the light off anymore.
Could you tell my why the toggle is switching back and why am I not able to toggle the switch.a_off “on” command? Where is the mistake in the switch-config?
Here is my YAML-Configuration:
switch:
- platform: template
switches:
skylight:
value_template: "{{ is_state('sensor.skylight', 'on') }}"
turn_on:
service: switch.turn_on
target:
entity_id: switch.a_on
turn_off:
service: switch.turn_on #turn on because the a_off needs an on signal for sending the RF-Signal
target:
entity_id: switch.a_off
honestly I’ve no idea. I just took it over from the template.
By deleting this line I get:
This works fine but I’d like to have a toggle. If I get your question right, on a_on and a_off sending states: yes they do have states but just a short signal when sending the RF-Signal (the toggles finally switches also back fast). So do I need a line to hold the state?
You have no idea if your sensor is changing state?
Is this a contact sensor on the skylight?
This sensor state is the only thing that determines the switch “toggle” state. It is the feedback to home assistant that tells it the state of the skylight switch .
now I got you. There is no sensor.skylight with status “on/off” at the moment. Finally I need to create one based on trigger event
a_on → sensor.skylight (Status: on)
a_off → sensor.skylight (Status: off)
I’m a newbee in creating my own sensors. I found this:
Stop trying to use entities that you don’t have. You have no binary_sensor.skylight
They won’t just magically appear because you make them up. You have to define them.
This might work:
template binary sensor
template:
- trigger:
- platform: state
entity_id: switch.a_on
to: 'on'
id: 'true'
- platform: state
entity_id: switch.a_off
to: 'on'
id: 'false'
binary_sensor:
- name: "skylight"
state: "{{ trigger.id }}"
template switch
switch:
- platform: template
switches:
skylight:
value_template: "{{ is_state('binary_sensor.skylight', 'on') }}"
turn_on:
service: switch.turn_on
target:
entity_id: switch.a_on
turn_off:
service: switch.turn_on #turn on because the a_off needs an on signal for sending the RF-Signal
target:
entity_id: switch.a_off
Thank you for your reply and your approach @tom_l. The switch works but the switch still jump back instantly. I’ll take my time for it tomorrow whats going on there and need to be changed.