自定义智能处理过程(3)-与HomeAssistant互动
ha_api调用
get_state
获得HomeAssistant中某个实体的状态或者某个属性值
post_service
调用HomeAssistant的服务
play_tts
调用HomeAssistant的服务,播放文本的音频
play_audio_file
调用HomeAssistant的服务,播放www目录下的音频媒体文件
fire_event
触发HomeAssistant的事件
intent_process
HomeAssistant API调用: conversation/process
fire_event
voice_assistant触发HomeAssistant中的事件;在HomeAssistant中使用自动化定义事件对应的处理。
intent_process
利用HomeAssistant的conversation和intent_script组件完成智能处理过程
conversation和intent_script组件配置样例:
# Example configuration.yaml entry
conversation:
intents:
RoomTemperature:
- "现在多热"
- "现在[室外]几度"
- "[需][要]开空调吗"
- ".*(?:温度|冷).*"
OpenLight:
- "打开(?:小米|小米网关|过道)?灯"
- "把(?:小米|小米网关|过道)?灯打开"
CloseLight:
- "关闭(?:小米|小米网关|过道)?灯"
- "把(?:小米|小米网关|过道)?灯关闭"
intent_script:
RoomTemperature:
speech:
text: 当前室外{{state_attr('weather.wo_de_jia','temperature')}}度
OpenLight:
speech:
text: 正在打开小米灯
action:
service: light.turn_on
data:
entity_id: light.entity_id
CloseLight:
async_action: true
speech:
text: 正在关闭小米灯
action:
service: light.turn_off
data:
entity_id: light.entity_id
- conversation组件的配置
https://www.home-assistant.io/integrations/conversation/
- intent_script组件的配置
https://www.home-assistant.io/integrations/intent_script/