Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save willwhui/c45f09a54a52dc3d9cd839b10aef3338 to your computer and use it in GitHub Desktop.
Save willwhui/c45f09a54a52dc3d9cd839b10aef3338 to your computer and use it in GitHub Desktop.
在hass上检测通过Google Home生成的Google Calendar Event
@willwhui
Copy link
Author

设置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'

不能用 "-"那种模式

@willwhui
Copy link
Author

willwhui commented Nov 29, 2017

最终完成重复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"
################################################################

@willwhui
Copy link
Author

willwhui commented Dec 1, 2017

不足的地方:

  • 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