Skip to content

Instantly share code, notes, and snippets.

@willwhui
Created December 21, 2017 01:40
Show Gist options
  • Save willwhui/5ecb123e9b1b327012a5c77f2ae86776 to your computer and use it in GitHub Desktop.
Save willwhui/5ecb123e9b1b327012a5c77f2ae86776 to your computer and use it in GitHub Desktop.
利用hass汇报空气质量
@willwhui
Copy link
Author

通过alexa召唤(mediaplayer发声)

先设置一个开关:

air_checker:
  name: "air checker"
  initial: off
  icon: mdi:weather-fog

然后设定一个automation规则

- alias: "TTS on Air Quality Index"
  trigger:
    - platform: state
      entity_id: input_boolean.air_checker 
      to: 'on'
  action:
    - service: input_boolean.turn_off
      entity_id: input_boolean.air_checker
    - service: tts.google_say
      entity_id: media_player.living_room_home
      data_template: 
        message: >
          Wait a second.
    - delay: '00:00:05' # left some time for tts data transporting
    - service: tts.google_say
      entity_id: media_player.living_room_home
      data_template: 
        message: >
          Air Quality Index of Zhuhai now: {{states.sensor.waqi_zhuhai.state}}

然后对alexa说:
Alexa, turn on Air Checker
就会导致开关被打开,触发自动化规则,报出指数。

注意:
Alexa识别新设定的开关没那么及时,要等好一阵子,不知道为什么。
所以平时预先设定一个名为“test”的开关,可以用于调试。
避免Alexa迟迟不识别导致调试困难。

@willwhui
Copy link
Author

和空气净化器结合的策略:

没有什么好策略,不处理。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment