本帖最后由 aktifin 于 2018-3-2 14:43 编辑
【参考了各位大神的代码】通过device_tracker判断回家状态,通过门口的感应器判断有人活动,通过tts播放室内温湿度,并通过L大的讯飞随机语句播放随机祝福
目前感觉判断还是有误报的可能,最好能判断not home半小时以上切换到home再播放就好了,还需要大神的指点帮助
- alias: welcomeback
initial_state: true
hide_entity: True
trigger:
- platform: state
entity_id: device_tracker.xxxxxx
from: 'not_home'
to: 'home'
condition:
condition: and
conditions:
- condition: time
after: '16:00:00'
before: '22:30:00'
- condition: state
entity_id: binary_sensor.motion_sensor_xxxxxxx
state: 'on'
action:
- service: tts.clear_cache
- wait_template: '{{ states("media_player.mpd") == "stop" or states("media_player.mpd") == "off"}}'
- delay: 00:00:10
- service: tts.iflytek_say
data_template:
entity_id: media_player.mpd
message: >
"欢迎主人回家!当前室内温度为{{states('sensor.temperature_xxxxxxxx')}}度,湿度为百分之{{states('sensor.humidity_xxxxxx')}},#晚上好#。"
cache: false
|