Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## https://github.com/rogro82/hass-variables
- variable:
- last_arrive_dwmip:
- value: 'Never'
- restore: true
- last_depart_dwmip:
- value: 'Never'
- restore: true
- last_arrive_jlwip:
- value: 'Never'
- restore: true
- last_depart_jlwip:
- value: 'Never'
- restore: true
- last_motion_location:
- value: 'None'
- restore: true
- last_door_location:
- value: 'None'
- restore: true
- last_motion_time:
- value: 'None'
- restore: true
- last_alarm_location:
- value: 'None'
- restore: true
- last_alarm_time:
- value: 'None'
- restore: true
- last_living_room_51_20:
- value: 'Never'
- restore: true
- last_kitchen_52_20:
- value: 'Never'
- restore: true
- last_bedroom_53_20:
- value: 'Never'
- restore: true
- last_office_56_20:
- value: 'Never'
- restore: true
- last_garage_57_20:
- value: 'Never'
- restore: true
- last_porch_54_20:
- value: 'Never'
- restore: true
- last_guestroom_55_20:
- value: 'Never'
- restore: true
- last_baby_58_20:
- value: 'Never'
- restore: true
- last_living_room_occupancy:
- value: 'Never'
- restore: true
- last_kitchen_occupancy:
- value: 'Never'
- restore: true
- last_bedroom_occupancy:
- value: 'Never'
- restore: true
- last_guest_room_occupancy:
- value: 'Never'
- restore: true
- last_office_occupancy:
- value: 'Never'
- restore: true
- last_dining_occupancy:
- value: 'Never'
- restore: true
- last_door_81_1:
- value: 'Never'
- restore: true
- last_door_82_1:
- value: 'Never'
- restore: true
- last_porch_54_44:
- value: 'Never'
- restore: true
- last_garage_57_25:
- value: 'Never'
- restore: true
- automation:
- - alias: "Motion Update"
- trigger:
- - platform: state
- entity_id: binary_sensor.living_room_51_20
- to: 'on'
- - platform: state
- entity_id: binary_sensor.kitchen_52_20
- to: 'on'
- - platform: state
- entity_id: binary_sensor.bedroom_53_20
- to: 'on'
- - platform: state
- entity_id: binary_sensor.porch_54_20
- to: 'on'
- - platform: state
- entity_id: binary_sensor.guestroom_55_20
- to: 'on'
- - platform: state
- entity_id: binary_sensor.office_56_20
- to: 'on'
- - platform: state
- entity_id: binary_sensor.garage_57_20
- to: 'on'
- - platform: state
- entity_id: binary_sensor.baby_58_20
- to: 'on'
- - platform: state
- entity_id: binary_sensor.living_room_occupancy
- to: 'on'
- - platform: state
- entity_id: binary_sensor.bedroom_occupancy
- to: 'on'
- - platform: state
- entity_id: binary_sensor.kitchen_occupancy
- to: 'on'
- - platform: state
- entity_id: binary_sensor.guest_room_occupancy
- to: 'on'
- - platform: state
- entity_id: binary_sensor.office_occupancy
- to: 'on'
- - platform: state
- entity_id: binary_sensor.dining_occupancy
- to: 'on'
- # - platform: state
- # entity_id: binary_sensor.door_81_1
- # to: 'on'
- # - platform: state
- # entity_id: binary_sensor.door_82_1
- # to: 'on'
- # - platform: state
- # entity_id: binary_sensor.porch_54_44
- # to: 'on'
- action:
- - service: variable.set_variable
- data_template:
- variable: '{{ "last_" + trigger.entity_id.split(".")[1] }}'
- value: '{{ as_timestamp(now()) | timestamp_custom("%b %d %-I:%M %p") }}'
- attributes_template: >
- {
- "history_1": "{{ states('variable.last_' + trigger.entity_id.split('.')[1]) }}",
- "history_2": "{{ state_attr('variable.last_' + trigger.entity_id.split('.')[1],'history_1') }}",
- "history_3": "{{ state_attr('variable.last_' + trigger.entity_id.split('.')[1],'history_2') }}"
- }
- - service: variable.set_variable
- data_template:
- variable: 'last_motion_location'
- value: '{{ trigger.to_state.attributes.friendly_name }} @ {{ as_timestamp(now()) | timestamp_custom("%b %d %-I:%M %p") }}'
- attributes_template: >
- {
- "entity_id": "{{ trigger.entity_id }}",
- "friendly_name": "{{ trigger.to_state.attributes.friendly_name }}",
- "time": "{{ as_timestamp(now()) | timestamp_custom('%b %d %-I:%M %p') }}",
- "history_1": "{{ states('variable.last_motion_location') }}",
- "history_2": "{{ state_attr('variable.last_motion_location','history_1') }}",
- "history_3": "{{ state_attr('variable.last_motion_location','history_2') }}"
- }
- ### Add alarm condition update here
- - alias: "Door Update"
- trigger:
- - platform: state
- entity_id: binary_sensor.door_81_1
- to: 'on'
- - platform: state
- entity_id: binary_sensor.door_82_1
- to: 'on'
- - platform: state
- entity_id: binary_sensor.porch_54_44
- to: 'on'
- - platform: state
- entity_id: cover.garage_57_25
- to: 'open'
- action:
- - service: variable.set_variable
- data_template:
- variable: '{{ "last_" + trigger.entity_id.split(".")[1] }}'
- value: '{{ as_timestamp(now()) | timestamp_custom("%b %d %-I:%M %p") }}'
- attributes_template: >
- {
- "history_1": "{{ states('variable.last_' + trigger.entity_id.split('.')[1]) }}",
- "history_2": "{{ state_attr('variable.last_' + trigger.entity_id.split('.')[1],'history_1') }}",
- "history_3": "{{ state_attr('variable.last_' + trigger.entity_id.split('.')[1],'history_2') }}"
- }
- - service: variable.set_variable
- data_template:
- variable: 'last_door_location'
- value: '{{ trigger.to_state.attributes.friendly_name }} @ {{ as_timestamp(now()) | timestamp_custom("%b %d %-I:%M %p") }}'
- attributes_template: >
- {
- "entity_id": "{{ trigger.entity_id }}",
- "friendly_name": "{{ trigger.to_state.attributes.friendly_name }}",
- "time": "{{ as_timestamp(now()) | timestamp_custom('%b %d %-I:%M %p') }}",
- "history_1": "{{ states('variable.last_door_location') }} @ {{ state_attr('variable.last_door_location','at') }}",
- "history_2": "{{ state_attr('variable.last_door_location','history_1') }}",
- "history_3": "{{ state_attr('variable.last_door_location','history_2') }}"
- }
- ### Add alarm condition update here
- - service: notify.pushbullet
- data_template:
- title: >
- {{trigger.to_state.attributes.friendly_name }} door opened at house.
- message: >
- {{ trigger.entity_id }} opened at
- {{ as_timestamp(now()) |timestamp_custom("%b %d %-I:%M %p") }} last opened at
- {{ states('variable.last_' + trigger.entity_id.split('.')[1]) }}.
- homeassistant:
- customize_glob:
- "variable.last_*":
- friendly_name: "Last"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement