blueprint: name: Sonoff TRVZB + External Temp AUTO description: Auto sync external temperature for all Sonoff TRVZB devices domain: automation trigger: - platform: time_pattern minutes: "/2" - platform: homeassistant event: start variables: sensors: > {{ states.sensor | map(attribute='entity_id') | select('match','sensor\\..*_temperature.*') | list }} action: - repeat: for_each: "{{ sensors }}" sequence: - variables: sensor_entity: "{{ repeat.item }}" prefix: > {{ sensor_entity.split('.')[1] | regex_replace('_temperature.*','') }} number_entity: "number.{{ prefix }}_temperature_input" select_entity: "select.{{ prefix }}_temperature_sensor_select" # sprawdź czy encje istnieją - condition: template value_template: > {{ number_entity in states and select_entity in states and states(sensor_entity) not in ['unknown','unavailable'] }} # ustaw external tylko gdy potrzeba - if: - condition: template value_template: "{{ states(select_entity) != 'external' }}" then: - service: select.select_option target: entity_id: "{{ select_entity }}" data: option: external - delay: "00:00:05" - service: number.set_value target: entity_id: "{{ number_entity }}" data: value: "{{ states(sensor_entity) | float }}" mode: single