After the update to 2022.09, this no longer works, I noticed that dozens of unrelated entities now get selected by “selectattr”, they seem to now have a device_class of “battery” (could be a zwavejs2mqtt problem), and their value is 0% (hence, they trigger my template sensor and I am getting useless notifications), for example:
Anyways - I thought that instead of selecting the “sensors” based on device_class, a workaround could be to select based on entity_id string matching, I’d like to select all the sensors whose entity_id ends with “_battery_level”. It seems this would cover all sensors I’m interested on (zwave door sensors, PIRs, sirens, flood sensors). This is what I do in the UI, where I use a “batter-state-card” that matches based on “*_battery_level”
is there a way to re-write the selectattr based on partial string matching?
I edited the orignal post to show more details of the problem I’m having
Device Class indeed seems to be defined and set to “battery” in a bunch of unrelated entities. They are all zwave entities. This might be a problem of zwavejs2mqtt which I also had to upgrade (I am now using 7.1 - docker container)
Is there a way to do the “selection” based on sub string matching with the entity_id?
BUT… I would like to also include in the logic devices reporting ‘low’ (instead of a %).
I have tried several methods without success. Any guidance is appreciated.