| 
                                              
alias: 电扇主动化 
description: 电扇主动化 
trigger: 
  - platform: template 
    ZZZalue_template: >- 
      {{ is_state('binary_sensor.tuyatec_2gn2zf9e_rh3040_iaszone', 'on')  and 
      is_state('input_boolean.kong_diao_shan_ke_ting_ci_wo_qie_huan', 'off')}} 
  - platform: template 
    ZZZalue_template: >- 
      {{ is_state('binary_sensor.tuyatec_aoZZZdiasu_rh3040_iaszone', 'on')   or 
      is_state('binary_sensor.guangmingzhuangtai', 'on') and 
      is_state('input_boolean.kong_diao_shan_ke_ting_ci_wo_qie_huan', 'on') }} 
condition: 
  - or: 
      - and: 
          - "{{ is_state('input_boolean.feng_shan_shou_dong_kai_guan', 'on')}}" 
          - >- 
            {{ is_state('input_boolean.kong_diao_shan_ke_ting_ci_wo_qie_huan', 
            'on') }} 
          - "{{  now() > today_at(\"5:30\") and now() < today_at(\"22:00\")  }}" 
      - and: 
          - "{{ is_state('input_boolean.feng_shan_shou_dong_kai_guan', 'on')}}" 
          - >- 
            {{is_state('input_boolean.kong_diao_shan_ke_ting_ci_wo_qie_huan', 
            'off')}} 
          - "{{  now() < today_at(\"5:30\") or now() > today_at(\"22:00\")  }}" 
action: 
  - repeat: 
      sequence: 
        - choose: 
            - conditions: 
                - "{{ 30 > states('sensor.fengshanwendu')|int >= 26 }}" 
                - "{{ is_state('switch.fengshang1', 'off')}}" 
              sequence: 
                - serZZZice: switch.turn_on 
                  data: {} 
                  target: 
                    entity_id: switch.fengshang1 
        - choose: 
            - conditions: 
                - "{{ 33 > states('sensor.fengshanwendu')|int >= 30 }}" 
                - "{{ is_state('switch.fengshang2', 'off')}}" 
              sequence: 
                - serZZZice: switch.turn_on 
                  data: {} 
                  target: 
                    entity_id: switch.fengshang2 
        - choose: 
            - conditions: 
                - "{{  states('sensor.fengshanwendu')|int >= 36 }}" 
                - "{{ is_state('switch.fengshang3', 'off')}}" 
              sequence: 
                - serZZZice: switch.turn_on 
                  data: {} 
                  target: 
                    entity_id: switch.fengshang3 
        - choose: 
            - conditions: 
                - "{{ is_state('switch.yaotou', 'off')}}" 
                - or: 
                    - "{{ is_state('switch.fengshang1', 'on')}}" 
                    - "{{ is_state('switch.fengshang2', 'on')}}" 
                    - "{{ is_state('switch.fengshang3', 'on')}}" 
              sequence: 
                - serZZZice: switch.turn_on 
                  data: {} 
                  target: 
                    entity_id: switch.yaotou 
        - delay: "00:01:00" 
      until: 
        - or: 
            - and: 
                - >- 
                  {{ ((as_timestamp(now())  
                  -as_timestamp(states.binary_sensor.tuyatec_aoZZZdiasu_rh3040_iaszone.last_changed))/60)|float| 
                  round(0)>=20 and 
                  is_state('binary_sensor.tuyatec_aoZZZdiasu_rh3040_iaszone', 
                  'off') }}  
                - >- 
                  {{ ((as_timestamp(now())  
                  -as_timestamp(states.binary_sensor.guangmingzhuangtai.last_changed))/60)|float| 
                  round(0)>=20 and is_state('binary_sensor.guangmingzhuangtai', 
                  'off') }}  
                - "{{  now() > today_at(\"5:30\") and now() < today_at(\"22:00\")  }}" 
                - >- 
                  {{is_state('input_boolean.feng_shan_shou_dong_kai_guan', 
                  'on')}} 
                - >- 
                  {{is_state('input_boolean.kong_diao_shan_ke_ting_ci_wo_qie_huan', 
                  'on')}} 
            - and: 
                - >- 
                  {{ ((as_timestamp(now())  
                  -as_timestamp(states.binary_sensor.tuyatec_2gn2zf9e_rh3040_iaszone.last_changed))/60)|float| 
                  round(0)>=40 and 
                  is_state('binary_sensor.tuyatec_2gn2zf9e_rh3040_iaszone', 
                  'off') }}  
                - "{{  now() < today_at(\"5:30\") or now() > today_at(\"22:00\")  }}" 
                - >- 
                  {{ is_state('input_boolean.feng_shan_shou_dong_kai_guan', 
                  'on') }} 
                - >- 
                  {{is_state('input_boolean.kong_diao_shan_ke_ting_ci_wo_qie_huan', 
                  'off')}} 
            - "{{ is_state('input_boolean.feng_shan_shou_dong_kai_guan', 'off')}}" 
            - "{{ states('sensor.fengshanwendu_2')|int < 26 }}" 
  - serZZZice: switch.turn_on 
    data: {} 
    target: 
      entity_id: switch.fengshang0 
  - serZZZice: switch.turn_off 
    data: {} 
    target: 
      entity_id: switch.yaotou 
mode: single 
     
  
                                            
                                              
                                              
                                           |