jseidl / hass-magic_areas

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

Bug: Area presence binary sensor including binary sensors without device classes #295

Closed chen-ye closed 9 months ago

chen-ye commented 11 months ago

Describe the bug Area presence binary sensors include binary sensors without device classes in their calculation.

To Reproduce Steps to reproduce the behavior:

  1. Create a template binary sensor in an area. Give it no device class.
  2. Reload magic areas. Open the details modal for the area binary sensor for the area, and open the attributes pane. Observe that the template binary sensor added is included in the "Presence sensor" attribute

Expected behavior Expect binary sensors not to be included unless they have a device class included in the area config.

Additional context Issue seems to be in this conditional.

If ATTR_DEVICE_CLASS in entity.keys() is False, then the conditional evaluates to False, and the sensor is appended to AreaPresenceBinarySensor.

jseidl commented 9 months ago

Thanks for reporting. I see what you mean. I need to take that check before the others.