Last active
December 8, 2017 02:50
-
-
Save willwhui/c45f09a54a52dc3d9cd839b10aef3338 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
在hass上检测通过Google Home生成的Google Calendar Event |
设置timer
timer的配置文件和常见的书写方式略有不同:
设置多个timer,必须得这样:
timer_for_repeat_tts_on_google_calender_event:
duration: '00:01:00'
timer_for_repeat_tts_on_google_calender_event_2:
duration: '00:01:00'
不能用 "-"那种模式
最终完成重复TTS配置如下
timer:
timer_for_repeat_tts_take_a_walk:
duration: '00:00:10'
automation:
################################################################
# begin : automation for "stop working, take a walk"
- alias: "TTS on event (speak and start timer): stop working, take a walk"
trigger:
platform: state
entity_id: calendar.start_work
from: 'on'
to: 'off' # stop working
action:
- service: tts.google_say
entity_id: media_player.living_room_home
data:
message: "Time to take a walk, human!"
- service: switch.turn_on # set the signal on
entity_id: switch.orange_orvibo_wifi_socket
- service: timer.start # start the timer for repeat
entity_id: timer.timer_for_repeat_tts_take_a_walk
- alias: "TTS on timer (speak and start timer again): stop working, take a walk"
trigger:
platform: state
entity_id: timer.timer_for_repeat_tts_take_a_walk
to: 'idle' # time up
condition:
condition: state
entity_id: switch.orange_orvibo_wifi_socket
state: 'on' # repeat if signal is on
action:
- service: tts.google_say
entity_id: media_player.living_room_home
data:
# message: "Time to take a walk, human!"
message: "喂!够了够了,必须站起来走走了!"
language: "zh"
- service: timer.start # start this timer again
entity_id: timer.timer_for_repeat_tts_take_a_walk
# end : automation for "stop working, take a walk"
################################################################
不足的地方:
- event 下发不及时
说检查状态的间隔时间是15分钟 - event 无法在通过google home设定时间周期,总是默认1小时长度
最终发现,在这个案例中,可以通过设置开始时间为 "20 minutes ago"来控制总时长 - event 状态有时候不更新
原因未知。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
利用timer组件达到TTS重复发声的目的
timer官方文档: https://home-assistant.io/components/timer/
设计思路:
trigger: 当日历事件
action:
触发automation之后发声,
并触发一个timer: timer_for_repeat_tts_on_google_calender_event
并设定一个标记为on
trigger: timer_for_repeat_tts_on_google_calender_event
condition: 标记是否已经off
action:
发声
并重启timer_for_repeat_tts_on_google_calender_event
那么,如何设定一个可以on/off的标记呢?
设计思路:
在automation1中设定一个标记,比如一个智能插座(或灯)。
这个标记将成为automation2的执行条件
手动关闭这个插座或灯,就可以结束automation2导致的循环