jseidl / hass-magic_areas

Areas with batteries included for Home Assistant
MIT License
254 stars 28 forks source link

Bug: connectivity sensor should return off if at least one sensor is not connected #271

Closed klatka closed 7 months ago

klatka commented 1 year ago

Describe the bug Not sure if it's a bug but the connectivity sensor should return off if at least one sensor is not connected. Currently, the sensor is always on until all sensors are off.

Expected behavior If attributes.active_sensors count != attributes.sensors then return off

Magic Areas version 3.0.1

jseidl commented 1 year ago

Current all binary sensor groups are using this behavior but good point, will take a look onto that

jseidl commented 1 year ago

This should be an easy fix similar to what I did for regular sensor aggregates that should be sum instead of avg.

Can you take a look at the binary sensor device classes and compile a list of possible candidates for that same behavior (only if all are on, be on)?

klatka commented 1 year ago

The connectivity sensor is currently the only one.

klatka commented 1 year ago

Looks like only binary_sensor is considered. This should also be included:

{{ states.sensor
  | selectattr('attributes.device_class', 'defined')
  | selectattr('attributes.device_class', 'eq', 'connectivity')
  | selectattr('attributes.state_class', 'defined')
  | selectattr('attributes.state_class', 'eq', 'measurement')
  | map(attribute='entity_id')
  | list }}
jseidl commented 11 months ago

@klatka binary_sensors and sensors are not aggregated together, there's no inference of connectivity due presence of value.

This could be a good addition to the Area Health Sensors tho