|
无意中搜到个老外写的,感觉他的思路不错,不是简单的0或1判断,增加了过渡的状态,对自动化判断很有帮助.
https://philhawthorne.com/making-home-assistants-presence-detection-not-so-binary/
自动化的话就from 'just arrived' to 'home' 来触发到家的事件.
home状态手机离线了一会,就会变just left ,10分钟以内(自己设置)重新连wifi马上变home状态不会触发just arrived 状态.
#######################################################################################
修改自老外
#########################################################################################
input_select:
real_status_dropdown:
options:
- Home
- Just Arrived
- Just Left
- Away
- Extended Away
initial: Home
sensor:
- platform: template
sensors:
real_status:
value_template: "{{ states.input_select.real_status_dropdown.state }}"
friendly_name: 'xxx'
group:
- people_status:
view: no
name: 家庭成员
entities:
- sensor.real_status
automation:
- alias: Mark real as just arrived
trigger:
- platform: state
entity_id: device_tracker.real
from: 'not_home'
to: 'home'
condition:
condition: or
conditions:
- condition: state
entity_id: sensor.real_status
state: 'Away'
- condition: state
entity_id: sensor.real_status
state: 'Extended Away'
action:
- service: input_select.select_option
data:
entity_id: input_select.real_status_dropdown
option: Just Arrived
- alias: Mark real as home
trigger:
- platform: state
entity_id: input_select.real_status_dropdown
to: 'Just Arrived'
for:
seconds: 10
- platform: state
entity_id: input_select.real_status_dropdown
from: 'Just Left'
to: 'Just Arrived'
action:
- service: input_select.select_option
data:
entity_id: input_select.real_status_dropdown
option: Home
- alias: Mark real as just left
trigger:
- platform: state
entity_id: device_tracker.real
from: 'home'
to: 'not_home'
action:
- service: input_select.select_option
data:
entity_id: input_select.real_status_dropdown
option: Just Left
- alias: Mark real as away
trigger:
- platform: state
entity_id: input_select.real_status_dropdown
to: 'Just Left'
for:
minutes: 10
action:
- service: input_select.select_option
data:
entity_id: input_select.real_status_dropdown
option: Away
- alias: Mark real as away2
trigger:
- platform: homeassistant
event: start
condition:
condition: state
entity_id: device_tracker.real
state: 'not_home'
action:
- service: input_select.select_option
data:
entity_id: input_select.real_status_dropdown
option: Away
- alias: Mark real as extended away
trigger:
- platform: state
entity_id: input_select.real_status_dropdown
to: 'Away'
for:
hours: 24
action:
- service: input_select.select_option
data_template:
entity_id: input_select.real_status_dropdown
option: Extended Away
|
评分
-
查看全部评分
|