Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.02 KB | None | 0 0
  1. light:
  2.   - platform: mqtt_json
  3.     name: "bathroom_plant"
  4.     state_topic: "home/whitestrip1"
  5.     command_topic: "home/whitestrip1/set"
  6.     brightness: true
  7.     rgb: false
  8.     optimistic: false
  9.     qos: 0
  10.    
  11. sensor:
  12.   - platform: mqtt
  13.     name: "Light_Sensor_Bathroom"
  14.     state_topic: "home/whitestrip1/sensor"
  15.     qos: 0
  16. #No unit, raw value
  17.     unit_of_measurement: "Raw"
  18.    
  19. binary_sensor:
  20.   - platform: template
  21.     sensors:
  22.       bathroom_light_is_on:
  23.         value_template: '{{ float(states.sensor.light_sensor_bathroom.state) > 26 }}'
  24.         friendly_name: 'Main light status'
  25.         device_class: light
  26. automation:
  27.   - alias: Turn on bathroom lights when there is movement
  28.     trigger:
  29.       - platform: mqtt
  30.         topic: home/433toMQTT
  31.         payload: 9316106
  32.       - platform: mqtt
  33.         topic: homesense/433toMQTT
  34.         payload: 9316106
  35.     condition:
  36.       condition: and
  37.       conditions:
  38.         - condition: or
  39.           conditions:
  40.           - condition: state
  41.             entity_id: device_tracker.me
  42.             state: 'home'
  43.           - condition: state
  44.             entity_id: device_tracker.not_me
  45.             state: 'home'
  46.     action:
  47.       - service: timer.start
  48.         entity_id: timer.timer_bathroom
  49.         data_template:
  50.           entity_id: timer.timer_bathroom
  51.           duration: '00:{% if now().hour < 6 %} 3 {% else %} 30 {% endif %}:00'
  52.       - service: light.turn_on
  53.         data_template:
  54.           entity_id: light.bathroom_plant
  55.           transition: '{% if now().hour < 6 %} 30 {% else %} 10 {% endif %}'
  56.           brightness: '{% if now().hour < 6 %} 60 {% else %} 230 {% endif %}'
  57.   - alias: Turn off bathroom lights at end of timer
  58.     trigger:
  59.       - platform: event
  60.         event_type: timer.finished
  61.         event_data:
  62.           entity_id: timer.timer_bathroom
  63.     action:
  64.       - service: light.turn_off
  65.         data:
  66.           entity_id: light.bathroom_plant
  67.           transition: 50
  68.  
  69. timer:
  70.   timer_bathroom:
  71.     duration: '00:30:00'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement