|
本帖最后由 ABC 于 2017-8-12 16:51 编辑
一直想着要想六哥的帖子写那么多个自动化很麻烦,所以为了偷懒就写出了以下的写法
首先写一个虚拟开关input_boolean:input_boolean:
sensor_light:
initial: on
然后我是用和风天气的空气质量来做自动化的,用和风的照抄就可以
alias: "9"
trigger:
- platform: state
entity_id: input_boolean.sensor_light
to: 'on'
- platform: state
entity_id: sensor.aqi_qlty
action:
- service: light.turn_on
data_template:
entity_id: light.gateway_light_286c0788b403
brightness: 60
color_name: >-
{% if is_state("sensor.aqi_qlty", "优") %} green
{% elif is_state("sensor.aqi_qlty", "良") %} yellow
{% elif is_state("sensor.aqi_qlty", "中") %} orange
{% elif is_state("sensor.aqi_qlty", "差") %} red
{% elif is_state("sensor.aqi_qlty", "极差") %} brown
{% else %} maroon
{% endif %}
|
评分
-
查看全部评分
|