Advertisement
Bart274

example restart HA when wemo isn't found

Jan 29th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.91 KB | None | 0 0
  1. mqtt:
  2.   broker: ***
  3.   port: 1883
  4.   client_id: home-assistant-1
  5.   keepalive: 60
  6.   username: ***
  7.   password: ***
  8.  
  9. device_tracker:
  10.   - platform: nmap_tracker
  11.     hosts: 192.168.0.1-255
  12.     home_interval: 1
  13.     interval_seconds: 30
  14.     consider_home: 900
  15.    
  16. ifttt:
  17.   key: ***
  18.  
  19. notify:
  20.   - platform: pushbullet
  21.     api_key: ***
  22.     name: pushbullet
  23.  
  24. switch:
  25.   - platform: wemo
  26.   - platform: mqtt
  27.     state_topic: "home/killhass"
  28.     command_topic: "home/killhass"
  29.     name: "KillHass"
  30.     qos: 0
  31.     payload_on: "ON"
  32.     payload_of: "OFF"
  33.     optimistic: false
  34.     state_format:
  35. script:
  36.   restarthawemo:
  37.     alias: "Restart HA if WeMo isn't found after 15 minutes"
  38.     sequence:
  39.       - delay:
  40.           minutes: 15
  41.       - execute_service: notify.pushbullet
  42.         service_data:
  43.           message: 'WeMo not found, restarting HA'
  44.       - execute_service: switch.turn_on
  45.         service_data:
  46.           entity_id: switch.killhass
  47.  
  48. automation:
  49.   - alias: "Restart HA if WeMo switch isn't found after 15 minutes"
  50.   trigger:
  51.     platform: state
  52.     entity_id: device_tracker.wemo
  53.     from: 'not_home'
  54.     to: 'home'
  55.   condition:
  56.     - platform: template
  57.       value_template: '{% if states.switch.wemo %}false{% else %}true{% endif %}'
  58.     - platform: state
  59.       entity_id: script.restarthawemo
  60.       state: 'off'
  61.   action:
  62.     service: homeassistant.turn_on
  63.     entity_id: script.restarthawemo
  64.   - alias: 'Stop HA'
  65.   trigger:
  66.     - platform: state
  67.       entity_id: switch.KillHass
  68.       state: 'on'
  69.   action:
  70.     service: homeassistant.stop
  71.   - alias: 'Stop restarting HA is WeMo is found'
  72.   trigger:
  73.     platform: template
  74.     value_template: '{% if states.switch.wemo %}true{% else %}false{% endif %}'
  75.   condition:
  76.     platform: state
  77.     entity_id: script.restarthawemo
  78.     state: 'on'
  79.   action:
  80.     service: homeassistant.turn_off
  81.     entity_id: script.restarthawemo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement