Last active
July 19, 2022 14:47
-
-
Save nao-pon/120f7cd8ff19cbac11d82d3dba0e13b7 to your computer and use it in GitHub Desktop.
[HomeAssistant] 電流計付きスマートプラグとスマートIRによる家電コントロール
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sensor.xiao_fei_dian_liu_3: 電流センサー | |
# input_number.living_sen_on_current: オンと判定する最低電流(ヘルパー) | |
# input_number.living_sen_off_current: オフと判定する最高電流(ヘルパー) | |
- platform: template | |
switches: | |
living_fan: | |
unique_id: living_fan | |
value_template: >- | |
{%- if (is_state('sensor.xiao_fei_dian_liu_3', 'unavailable')) -%} | |
{{states('switch.living_fan')}} | |
{%- else -%} | |
{{states('sensor.xiao_fei_dian_liu_3')|int > (states('input_number.living_sen_off_current') if states('switch.living_fan') == "on" else states('input_number.living_sen_on_current'))|int}} | |
{%- endif -%} | |
availability_template: >- | |
{%- if not is_state("remote.living_ir_remote", "unavailable") %} | |
true | |
{%- endif %} | |
turn_on: | |
- wait_template: "{{ is_state('switch.living_fan', 'off') }}" | |
timeout: 10 | |
continue_on_timeout: false | |
- repeat: # 失敗に備えて繰り返す | |
while: "{{ is_state('switch.living_fan', 'off') and repeat.index < 5 }}" | |
sequence: | |
- service: remote.send_command | |
data: | |
entity_id: remote.ribingu_remote | |
device: hitachi fan rm2 | |
command: power | |
- delay: 00:00:06 # 電流センサーのタイムラグ対策で待つ | |
turn_off: | |
- wait_template: "{{ is_state('switch.living_fan', 'on') }}" | |
timeout: 10 | |
continue_on_timeout: false | |
- repeat: # 失敗に備えて繰り返す | |
while: "{{ is_state('switch.living_fan', 'on') and repeat.index < 5 }}" | |
sequence: | |
- service: remote.send_command | |
data: | |
entity_id: remote.ribingu_remote | |
device: hitachi fan rm2 | |
command: power | |
- delay: 00:00:10 # 電流センサーのタイムラグ対策で待つ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment