Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # For this to work properly, your MQTT broker must be setup to handle persistence
- binary_sensor:
- - platform: mqtt
- state_topic: home-assistant/sunrise-lighting
- name: Sunrise Lighting
- payload_on: 'on'
- payload_off: 'off'
- input_boolean:
- sunrise_lighting:
- name: Sunrise Lighting
- initial: on
- automation:
- - alias: Update Sunrise Lighting Binary Sensor
- trigger:
- - platform: state
- entity_id: input_boolean.sunrise_lighting
- condition:
- - condition: template
- value_template: "{{ not is_state('input_boolean.sunrise_lighting', states('binary_sensor.sunrise_lighting')) }}"
- action:
- service: mqtt.publish
- data_template:
- topic: home-assistant/sunrise-lighting
- payload: "{{ states('input_boolean.sunrise_lighting') }}"
- retain: true
- - alias: Update Sunrise Lighting Input Boolean
- trigger:
- - platform: state
- entity_id: binary_sensor.sunrise_lighting
- - platform: event
- event_type: homeassistant_start
- condition:
- - condition: template
- value_template: "{{ not is_state('input_boolean.sunrise_lighting', states('binary_sensor.sunrise_lighting')) }}"
- action:
- service_template: "input_boolean.turn_{{ 'on' if is_state('binary_sensor.sunrise_lighting', 'on') else 'off' }}"
- entity_id: input_boolean.sunrise_lighting
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement