先创建一个二元选择器: input_boolean.enable_morning
下面是自动化代码,我一直在用。
alias: "[定时]开启早安播报"
description: ""
trigger:
- platform: time
at: "07:20:00"
condition: []
action:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.enable_morning
mode: single
alias: "[定时]关闭早安播报"
description: ""
trigger:
- platform: time
at: "09:00:00"
condition: []
action:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.enable_morning
mode: single
alias: "[播报]早安播报"
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.motion_sensor_158d00010b22fc
to: "on"
- platform: state
entity_id:
- binary_sensor.motion_sensor_158d0003cf4f4a
to: "on"
condition:
- condition: state
entity_id: input_boolean.enable_morning
state: "on"
action:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.enable_morning
- service: media_player.volume_set
data:
volume_level: 30
target:
entity_id: media_player.xiaomi_s12_6ed3_play_control
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- service: xiaomi_miot.intelligent_speaker
data:
entity_id: media_player.xiaomi_s12_6ed3_play_control
text: >-
亲爱的主人,早上好!现在是 {{ now().strftime('%Y-%m-%d %H:%M') }} 。今天 {{
states("sensor.caiyun_realtime_weather") }} ,温度 {{
states("sensor.caiyun_forecast_low_temperature").replace("-", "零下") }} 到
{{ states("sensor.caiyun_forecast_high_temperature").replace("-", "零下")
}} 摄氏度。当前 {{ states("sensor.caiyun_realtime_temperature").replace("-",
"零下") }} 摄氏度,空气质量 {{ states("sensor.caiyun_realtime_aqi") }}。今天 {{
states("sensor.caiyun_forecast_weather_hourly_des") }}。当前 {{
states("sensor.caiyun_forecast_weather_minutely_des") }}。{{
state_attr("sensor.heweather_comf","txt") }}。{{
state_attr("sensor.heweather_sport","txt") }}。
mode: single
|