本帖最后由 ghostist 于 2019-7-31 17:31 编辑
#新的编辑器好难用啊 还是我不会用?想在代码编辑框前加入文字,光标无法定位~
复制代码
已解决(自挖自填系列):
自动化加入 initial_state: true
AUTOMATION INITIAL STATE
When you create a new automation, it will be enabled unless you explicitly add initial_state: false to it or turn it off manually via UI/another automation/developer tools. In case automations need to be always enabled or disabled when Home Assistant starts, then you can set the initial_state in your automations. Otherwise, the previous state will be restored.
Please note that if for some reason Home Assistant cannot restore the previous state, it will result in the automation being enabled.
以前自动化正常过,不知道啥时候我手动关闭过?后来怎么重启HA都是disable状态 。一直以为重启HA 所有automation默认都是enable状态的说....
------------以下为原贴---------------------
input_boolean:
# 客厅空调锁
remote_livingroom_ac_lock:
name: 客厅空调锁
initial: off
input_number:
# 空调温度选择
remote_temp_livingroom:
min: 16
max: 32
initial: 24
step: 2
name: 空调温度
unit_of_measurement: "℃"
icon: mdi:thermometer
input_select:
# 空调风速
remote_fanspeed_livingroom:
name: 风速
icon: mdi:weather-windy
options:
- "自动"
- "小"
- "中"
- "大"
# 空调模式
remote_mode_livingroom:
name: 模式
icon: mdi:air-conditioner
options:
- "制热"
- "制冷"
# - "除湿"
sensor:
- platform: template
sensors:
remote_speed_livingroom:
value_template: >
{% set speed = 0 %}
{% if states.input_select.remote_fanspeed_livingroom.state == "自动" %}
{% set speed = 0 %}
{% elif states.input_select.remote_fanspeed_livingroom.state == "小" %}
{% set speed = 1 %}
{% elif states.input_select.remote_fanspeed_livingroom.state == "中" %}
{% set speed = 2 %}
{% elif states.input_select.remote_fanspeed_livingroom.state == "大" %}
{% set speed = 3 %}
{% endif %}
{{speed}}
remote_mode_livingroom:
value_template: >
{% set mode = 0 %}
{% if states.input_select.remote_mode_livingroom.state == "制热" %}
{% set mode = 0 %}
{% elif states.input_select.remote_mode_livingroom.state == "制冷" %}
{% set mode = 1 %}
{% endif %}
{{mode}}
script:
# 空调关闭
remote_konke_turnoff_ac:
alias: 关空调
sequence:
- service: remote.send_command
data:
entity_id: remote.konkeir
command: ir_10000
num_repeats: 2
automation:
# slot学习码 前导码1+温度+风速+模式
#0自动 1~3风速 0制热 1制冷
#eg:12431 24度大风制冷
- alias: "控客miniK Pro自动发送空调遥控信号"
trigger:
- platform: state
entity_id: input_number.remote_temp_livingroom
- platform: state
entity_id: input_select.remote_mode_livingroom
- platform: state
entity_id: input_select.remote_fanspeed_livingroom
condition:
- condition: state
entity_id: input_boolean.remote_livingroom_ac_lock
state: 'on'
action:
- service: remote.send_command
data_template:
entity_id: remote.konkeir
command: >
ir_1{{ states('input_number.remote_temp_livingroom') | int }}{{ states('sensor.remote_speed_livingroom') | int }}{{ states('sensor.remote_mode_livingroom') | int }}
num_repeats: 2
- delay: '00:00:05'
- service: input_boolean.turn_off
entity_id: input_boolean.remote_livingroom_ac_lock
homeassistant:
customize:
input_boolean.remote_livingroom_ac_lock:
friendly_name: '空调控制锁'
icon: mdi:lock
script.remote_konke_turnoff_ac:
friendly_name: '关空调'
icon: mdi:power
复制代码
描述:
1、建立了1个input_number和2个 input_select分别用于输入温度、风速和模式
2、 建立了2个sensor: template,同步2个 input_select,并转为数字
3、 建立了1个input_boolean,防止误触发
自动化:
当 input_number或 input_select变化时,判断 input_boolean是否为on,是的话组成ir_1xxxx的编码发送出去并设置 input_boolean为off
现象:
HA界面调整input_number或 input_select变化,空调无响应。 input_boolean仍旧为on
猜测自动化没执行
另外关机脚本是正常的,所有按键都已学码,通过手动调用remote.send_command服务填写相关参数,测试学码是可用的
现求助各位大神~