Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This creates a sensor that detects if the TV is on, if the Chromecast is powered and pingable
- binary_sensor: #goes in configuration.yaml
- - platform: ping
- count: 5
- scan_interval: 10
- name: chromecast_status
- host: your_chromecast_host
- # In your switches.yaml file you can create a switch template. This one will show the TV as 'ON' if the Chromecast is found by the ping component
- - platform: template
- switches:
- tv:
- friendly_name: TV
- value_template: "{{ is_state('binary_sensor.chromecast_status', 'on') }}"
- turn_on:
- service: script.turn_on
- entity_id: script.tv_on_script
- turn_off:
- service: script.turn_on
- entity_id: script.tv_off_script
- # Now create the on and off scripts for the TV in scripts.yaml
- # This 'on' script will only work if the TV is off, that way it won't accidently turn the TV off.
- # The 'on' script uses my Roku to turn the TV on, while my 'off' script uses the Broadlink RM Pro to turn the TV off.
- # You can adjust these depending on what hardware you have available.
- tv_on_script:
- alias: TV On Script
- sequence:
- - condition: state
- entity_id: switch.tv
- state: 'off'
- - service: media_player.select_source
- data:
- entity_id: media_player.living_room
- source: Home
- # This 'off' scripts will only work if the TV is on, that way I won't accidentally turn on a TV that's already off.
- tv_off_script:
- alias: TV Off Script
- sequence:
- - condition: state
- entity_id: switch.tv
- state: 'on'
- - service: media_player.select_source
- data:
- entity_id: media_player.living_room
- source: Home
- - service: switch.broadlink_send_packet_192_168_0_4
- data:
- packet:
- - "JgBQAAABKZIUERQ1FDUUEBUQFRAVEBU0FTQVEBQ1FBEUERQRFBAVEBU0FTQVNBQ1FBEUERQRFBAVEBUQFRAVEBU0FTQUNRQ1FAAFigABKUcVAA0FAAAAAAAAAAA"
Add Comment
Please, Sign In to add comment