Setting switch state automatically

Hi All,

I have a TV that when she is off she doesn’t answer to ping (her NIC is off to)

now i have a standard switch that turn on or off the TV (using broadlink and IR)

what i want to achieve is to do a ping every 5 seconds and change the state of the switch

is this possible ? if so how do i do that (i am new and i have no idea how to achieve that

Thanks in advance :smile:

You can use this custom component, or use the ping binary sensor.
I prefer the first, because you could also control the volume and channels.

1 Like

Thanks but i still don’t understand how can i combine them (i thing the ping binary is good enough)
this is my switch

switch:
  • platform: broadlink
    host: 10.0.0.1
    mac: ‘00:00:00:00:00:00’
    switches:
    tv_lg:
    command_on: ‘JgBQAAABJpMTDxQOETYREhEQFA4RERERGTQUMxERETcSNBQzETYRNxIPFA4RNhESEg8UDhE2ETYSNhE2Ew8UMxE2ETYTDxQOGQAFkQABJEkRAA0FAAAAAAAAAAA=’
    command_off: ‘JgBQAAABJJISEhEQFDMREREREhATDxERETYRNhMPFDMRNhE2EzgTNBQzERERNxIPFA4RERE2EzQUDhE2ERISNBQzETYREhIPFAAFjwABJ0YRAA0FAAAAAAAAAAA=’

how do i use the ping binary sensor in that ?

You have to create a Template Switch.
For example:

switch:
  - platform: template
    switches:
      tv_templated:
        value_template: "{{ is_state('binary_sensor.ping_your_tv', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.tv_lg
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.tv_lg