daily pastebin goal
37%
SHARE
TWEET

Untitled

a guest May 21st, 2018 127 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # This creates a sensor that detects if the TV is on, if the Chromecast is powered and pingable
  2.  
  3. binary_sensor: #goes in configuration.yaml
  4.   - platform: ping
  5.     count: 5
  6.     scan_interval: 10
  7.     name: chromecast_status
  8.     host: your_chromecast_host
  9.  
  10. # 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
  11.  
  12. - platform: template
  13.   switches:
  14.     tv:
  15.       friendly_name: TV
  16.       value_template: "{{ is_state('binary_sensor.chromecast_status', 'on') }}"
  17.       turn_on:
  18.         service: script.turn_on
  19.         entity_id: script.tv_on_script
  20.       turn_off:
  21.         service: script.turn_on
  22.         entity_id: script.tv_off_script
  23.        
  24. # Now create the on and off scripts for the TV in scripts.yaml
  25. # This 'on' script will only work if the TV is off, that way it won't accidently turn the TV off.
  26. # 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.
  27. # You can adjust these depending on what hardware you have available.
  28.  
  29. tv_on_script:
  30.   alias: TV On Script
  31.   sequence:
  32.     - condition: state
  33.       entity_id: switch.tv
  34.       state: 'off'
  35.     - service: media_player.select_source
  36.       data:
  37.         entity_id: media_player.living_room
  38.         source: Home
  39.  
  40. # 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.
  41.  
  42. tv_off_script:
  43.   alias: TV Off Script
  44.   sequence:
  45.     - condition: state
  46.       entity_id: switch.tv
  47.       state: 'on'
  48.     - service: media_player.select_source
  49.       data:
  50.         entity_id: media_player.living_room
  51.         source: Home  
  52.     - service: switch.broadlink_send_packet_192_168_0_4
  53.       data:
  54.         packet:
  55.           - "JgBQAAABKZIUERQ1FDUUEBUQFRAVEBU0FTQVEBQ1FBEUERQRFBAVEBU0FTQVNBQ1FBEUERQRFBAVEBUQFRAVEBU0FTQUNRQ1FAAFigABKUcVAA0FAAAAAAAAAAA"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top