Skip to content

Commit c892969

Browse files
committed
REF: entity detection with offset keyword ADD: external switch support
1 parent a9fb097 commit c892969

1 file changed

Lines changed: 32 additions & 8 deletions

File tree

blueprints/automation/panhans/advanced_heating_control.yaml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,8 @@ blueprint:
10391039
As a rule, the entities with the word *offset*, *calibration* or *external* are marked by the integrations. Just have a look into your [device overview](https://my.home-assistant.io/redirect/devices/), select your thermostat and check the naming of the *entity_ids* - not the entity name - for the calibration.
10401040
10411041
The logic detects automatically if the selected entity is an offset entity or a entity which holds an external temperature value. Keep in mind to set the offset entity to *0* if you switch to an external temperature entity or set the temperature source to internal if you switch to an offset entity.
1042+
1043+
📝: If you using offset calibration, make sure the entity id contains the keyword `offset`.
10421044
default: "calibration"
10431045
selector:
10441046
text:
@@ -2210,7 +2212,7 @@ trigger:
22102212
22112213
{% set calibration_entity_min = state_attr(calibration_entity,'min') | float(fallback_min) %}
22122214
{% set calibration_entity_max = state_attr(calibration_entity,'max') | float(fallback_max) %}
2213-
{% set is_offset_entity = (calibration_entity_min + calibration_entity_max) == 0 and calibration_entity_max < 30 %}
2215+
{% set is_offset_entity = 'offset' in calibration_entity %}
22142216
22152217
{% set has_external_sensor_configured.r = iif(not is_offset_entity, true, has_external_sensor_configured.r) %}
22162218
{% endif %}
@@ -3434,7 +3436,7 @@ variables:
34343436
{% set calibration_entity_value_old = states(calibration_entity) | float(0) %}
34353437
{% set local_temperature = value_temperature_sensor | float %}
34363438
{% set calibration_entity_value_new = local_temperature %}
3437-
{% set is_offset_entity = (calibration_entity_min | int + calibration_entity_max | int) == 0 and calibration_entity_max < 30 %}
3439+
{% set is_offset_entity = 'offset' in calibration_entity %}
34383440
{% set calibration_select = none %}
34393441
34403442
{% if is_offset_entity %}
@@ -3446,6 +3448,14 @@ variables:
34463448
| selectattr('domain','in','select')
34473449
| selectattr('attributes.options', 'contains', 'external')
34483450
| map(attribute='entity_id') | list | first | default(none) %}
3451+
3452+
{% if calibration_select is none%}
3453+
{% set calibration_select = device_entities(device_id(valve))
3454+
| expand
3455+
| selectattr('domain','in','switch')
3456+
| selectattr('entity_id', 'search', 'external_temperature_sensor')
3457+
| map(attribute='entity_id') | list | first | default(none) %}
3458+
{% endif %}
34493459
{% endif %}
34503460
34513461
{% set step = state_attr(calibration_entity, 'step') | float(1) %}
@@ -3663,7 +3673,13 @@ actions:
36633673
calibration_entity: "{{ (((calibration_changes.values() | list) [index]) | first) ['calibration_entity'] }}"
36643674
calibration_value: "{{ (((calibration_changes.values() | list) [index]) | first) ['value'] }}"
36653675
select_entity: "{{ (((calibration_changes.values() | list) [index]) | first) ['select'] }}"
3666-
is_external: "{{ select_entity != none and not is_state(select_entity, 'external') }}"
3676+
is_external: "{{ select_entity != none and (not is_state(select_entity, 'external') or not is_state(select_entity, 'on')) }}"
3677+
is_switch: >
3678+
{% if select_entity == none %}
3679+
{{ false }}
3680+
{% else %}
3681+
{{ states[select_entity].domain == 'switch' }}
3682+
{% endif %}
36673683
36683684
- action: system_log.write
36693685
data:
@@ -3678,11 +3694,19 @@ actions:
36783694
- condition: template
36793695
value_template: "{{ is_external }}"
36803696
then:
3681-
- action: select.select_option
3682-
target:
3683-
entity_id: "{{ select_entity }}"
3684-
data:
3685-
option: external
3697+
- if:
3698+
- condition: template
3699+
value_template: "{{ is_switch }}"
3700+
then:
3701+
- action: switch.turn_on
3702+
target:
3703+
entity_id: "{{ select_entity }}"
3704+
else:
3705+
- action: select.select_option
3706+
target:
3707+
entity_id: "{{ select_entity }}"
3708+
data:
3709+
option: external
36863710
- delay: !input input_action_call_delay
36873711

36883712
- action: number.set_value

0 commit comments

Comments
 (0)