Ok, but what to do after this check? I want to switch on if it is off and off if it is onâŚ
The entire switch i posted, is correct for doing this or not?
Also doing this i get:
the Value_template is there only to âdecideâ when the template switch is âonâ, in this case when the box is âonâ (the binary_sensor is âonâ).
with the turn_off and _on settings, you enter what the switch should do. if you turn it âoffâ the binary_sensor should turn false and hence put the switch in its Off position.
but, and this is something Ive been struggling with too, you have 3 entities with the same on/off state for this box:
an input_boolean, a template switch and a binary_sensor.
No sure on which template you have based the binary_sensor, but it might be a bit overcomplicated for you needs
The template switch has as advantage you can do other things than simply toggle between on and off i the turn_on and turn_off, and add other scripts and automations for example.
If you simply want to toggle on/off, you wouldnât need the switch perseâŚ
input_boolean and automation could read:
- alias: 'set tv box status'
id: 'set tv box status'
initial_state: 'on'
trigger:
platform: state
entity_id: input_boolean.tv_box_status
condition: []
action:
service_template: >
script.tv_box_{{ is_state('input_boolean.tv_box_status')}}
script.tv_box_on:
alias: Tv box on
sequence:
- service: switch.broadlink_send_packet_192_168_1_19
data:
packet:
- "JgAYAZOVEjgQOhE4EhMSExEUEBURFBE4ETkRORETERQSExITERQRFBE4EhMSExEUERQRFBETEjgSExE5ETgRORE5ETgSOBEABgWUlBI4EjgRORETEhMSExEUERQROBI4EjgRFBETEhMRFBITERQROBITERQRFBEUERQRFBE4EhMRORE4EjgRORE4EjgRAAYFk5URORE4EjgRFBEUERQRExEUEjgRORE4EhMSExEUERQRFBETEjgRFBEUERQRExITEhMSOBEUETgSOBE5ETgSOBE5EQAGBJSVETgSOBE5ERQRExITEhMSExE5ETgSOBEUERQRExITEhMSExE5EBQSExITEhMRFBEUETgSExI4ETgSOBI4ETgRORIADQU="
script.tv_box_off:
alias: Tv box off
sequence:
- service: switch.broadlink_send_packet_192_168_1_19
data:
packet:
- "JgCMAJSUFDYTNxI4EhITEhMSExITEhE5EjcTNxITEhMSEhMSExITEhI4ExETEhITExITEhITETgTEhM3EjgSNxM3EzcSNxQABgKTlRQ2EzcSNxQRFBETEhITEhITNxQ2EzYUERMSFBETEhMSEhITNxQRExITEhITEhIUERM3ExITNhQ2FDYTNhQ2FDYTAA0FAAAAAAAAAAAAAAAA="