#AND/OR Logic over alot of entities to activate heating pump

1 messages · Page 1 of 1 (latest)

mental stratus
#

Hello there
ive had this topic in the templates channel but cant find it anymore 😭 As it looks like it doesnt work anymore (since an update maybe), id like to request help again

The template should check several entities (all start with Name FBH_) if any of them is bigger than 0
if yes, a switch entity should be set true which will then start the heating pump

vice versa if all are 0 switch off

Is there any change during last months that would cause my logic to not work anymore? it says the switch-entity used in the template isnt available anymore but i didnt delete 🙈

sacred bough
#

What's the template you use?

mental stratus
#

{% set ns = namespace(knx=[]) %}
{% for knx in states.climate|map(attribute="entity_id")|list %}
{% if knx.startswith("climate.fbh_") %}
{% set ns.knx = ns.knx + [state_attr(knx, "command_value")] %}
{% endif %}
{% endfor %}
{{ (ns.knx | max) > 0 }}

#

Thats inside the helper
binary_sensor.fbh_anforderung

#

which is "not available" anymore

#

sorry "unavailable"

finite oracle
#

How sure are you that all of those climate thingies have an attribute "command_value"? Any one of them not having that would throw unavailable
I personally would just label all your "fbh" climates with something (maybe fbh) and then use:
{{ label_entities('fbh') | map("state_attr", "command_value") | reject('none') | select('gt', 0) | list | length > 0 }}
Where this selects all entities labelled fbh, gets their command_value attribute, culls any that are none or 0, and if there are more than 0 of those, returns true

sacred bough
#

Also without the label there is no need for a namespace:

{{
  states.climate
    | selectattr('object_id', 'search', '^fbh')
    | selectattr('attributes.command_value', 'defined')
    | map(attribute='attributes.command_value')
    | map('float', 0)
    | select('>', 0)
    | list
    | count > 0
}}