automations.yaml


#     First two are automations that kick off writes   
#     to the html file to sparemove (spareha)
#    write to tomup.txt when tom passes motion detector
- id: tom_moving
  alias: Update tom moving
  trigger:
    platform: state
    entity_id: binary_sensor.ecolink_motion_detector_sensor
    from: 'off'
    to: 'on'
  action:
    - service: notify.tom_moving
      data:
        message: M
#    write to coffee.txt when coffee pot is on
- id: coffee_pot
  alias: Coffee pot
  trigger:
    platform: numeric_state
    entity_id: sensor.aeotec_zw096_smart_switch_6_power
    above: 800
  action:
    - service: notify.coffee_cooking
      data:
        message: C

#    send text message if tom hasn't
#    moved in a couple of days
- id: is_tom_moving
  alias: Has tom moved
  trigger:
    platform: event
    event_type: folder_watcher
    event_data:
      event_type: created
  action:
    - service: notify.no_move
      data:
        message: Has tom moved lately?

#    turn living room on in morning
#    then off after 23/33 minutes
# https://www.reddit.com/r/homeassistant/comments/7vot1w/switch_in_automation_uses_turn_on_turn_off_but/
- id: morning_light_x_tue
  alias: AM light ex-tue
  trigger:
    platform: time
    at: '06:12:00'
  condition:
    condition: time
    weekday:
      - mon
      - wed
      - thu
      - fri
      - sat
      - sun
  action:
    - service: switch.turn_on
      entity_id: switch.vision_plugin_switch_switch
    - delay: 0:33
    - service: switch.turn_off
      entity_id: switch.vision_plugin_switch_switch

- id: morning_light_tue
  alias: AM light tue
  trigger:
    platform: time
    at: '06:00:00'
  condition:
    condition: time
    weekday:
      - tue
  action:
    - service: switch.turn_on
      entity_id: switch.vision_plugin_switch_switch
    - delay: 0:33
    - service: switch.turn_off
      entity_id: switch.vision_plugin_switch_switch
#    end lights

#    water leaks
#    send text message if water leak
#    in corner of living room 
- id: Flood_2_wet
  alias: LR flood
  trigger:
    platform: state
    entity_id:  binary_sensor.fibaro_system_fgfs101_flood_sensor_flood
    from: 'off'
    to: 'on'
  action:
    - service: notify.flood_wet
      data:
        message: Living room corner is wet

#    send text message if water heater leaks
- id: Flood_3_wet
  alias: Heater flood
  trigger:
    platform: state
    entity_id:  binary_sensor.fibaro_system_fgfs101_flood_sensor_flood_2
    from: 'off'
    to: 'on'
  action:
    - service: notify.flood_wet
      data:
        message: Heater house is wet

#    Turn this on when travelling, off when home
# https://github.com/CCOSTAN/Home-AssistantConfig/blob/
# master/config/automation/dash_buttons.yaml
- id: who_walked_in
  alias: who_walked_in 
  trigger:
    platform: state
    entity_id: sensor.vision_zp3102_pir_motion_sensor_burglar
    from: '0'
    to: '8'
  action:
    - service: notify.walk_in
      data:
        message: Who walked in?
    - service: automation.turn_off
      entity_id: automation.who_walked_in
    - service: switch.turn_on
      entity_id: switch.vision_plugin_switch_switch
    - delay: 0:10
    - service: switch.turn_off
      entity_id: switch.vision_plugin_switch_switch
    - delay: 0:20
    - service: automation.turn_on
      entity_id: automation.who_walked_in

#    Message phone if power lost
#    This isn't working 11/1/2018 switch isn't polled often enough
- id: Power_lost
  alias: Power lost
  trigger:
    platform: numeric_state
    entity_id: sensor.aeotec_zw096_smart_switch_6_voltage
    below: 50
  action:
    - service: notify.power_off
      data:
        message: Switch lost power
#