mqtt:
light:
#第二个mqtt
- name: "N_wl1"
command_topic: "CMD1"
state_topic: "STATUS1"
icon: mdi:lightbulb
qos: 1
retain: true
optimistic: false
payload_on: '{"A01":110000}'
payload_off: '{"A01":100000}'
state_value_template: >
{% if value_json.A01 == 1 %}
{"A01":110000}
{% else %}
{"A01":100000}
{% endif %}
- name: "N_wl2"
command_topic: "CMD1"
state_topic: "STATUS1"
icon: mdi:lightbulb
qos: 1
retain: true
optimistic: false
payload_on: '{"A02":110000}'
payload_off: '{"A02":100000}'
state_value_template: >
{% if value_json.A02 == 1 %}
{"A02":110000}
{% else %}
{"A02":100000}
{% endif %}
- name: "N_wl3"
command_topic: "CMD1"
state_topic: "STATUS1"
icon: mdi:lightbulb
qos: 1
retain: true
optimistic: false
payload_on: '{"A03":110000}'
payload_off: '{"A03":100000}'
state_value_template: >
{% if value_json.A03 == 1 %}
{"A03":110000}
{% else %}
{"A03":100000}
{% endif %}
- name: "N_wl4"
command_topic: "CMD1"
state_topic: "STATUS1"
qos: 1
retain: true
optimistic: false
icon: mdi:lightbulb
payload_on: '{"A04":110000}'
payload_off: '{"A04":100000}'
state_value_template: >
{% if value_json.A04 == 1 %}
{"A04":110000}
{% else %}
{"A04":100000}
{% endif %}
上面的代码,在ha界面里,手动一个一个点击都正常,因为手动操作时每一个动作有时间空隙。 当在脚本或自动化时执行全开或全关时,只有第一个靠前的执行。这个如何解决呀?
alias: light all on
sequence:
- service: light.turn_on
data: {}
target:
entity_id:
- light.n_wl1
- light.n_wl2
- light.n_wl3
- light.n_wl4
mode: single
|