jseidl / hass-magic_areas

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

Incorrect occupancy with two motion sensors #244

Closed hirsts closed 1 year ago

hirsts commented 2 years ago

I have 2 motion sensors in the garage and causes MA to get stuck thinking that the area is occupied with its not.

I use Zigbee and Philips hue sensors and there are no ZHA issues reported. I see both sensors detecting motion and clearing correctly. Default timeout value are used for clearing, missed events, extended and clearing extended.

If I restart HA the issue stops for a while and then come back after a yet to be determined period and or squence.

jseidl commented 2 years ago

I have many areas with more than one motion sensor working correctly. Will need more information to get to the cause.

Can you check the binary sensor for the area binary_sensor.$area_name and look if there are any active_sensors (attribute)?

hirsts commented 2 years ago

Whilst collecting the info I found that one of my sensors hadnt been renamed to my naming standards and so I renamed them. I then deleted the MA Garage config and reconfigured but its still using the old entity names. I think this this is the other bug mentioned around deleted entities.

The area seems to be working again but im struggling to determine if its using both motion senors (suppect not). Most likely its only using the first correctly named sensor, therefore there is only one sensor and thats why is working :-(

I'll monitor and keep investigating.

hirsts commented 2 years ago

Whilst collecting the info I found that one of my sensors hadnt been renamed to my naming standards and so I renamed them. I then deleted the MA Garage config and reconfigured but its still using the old entity names. I think this this is the other bug mentioned around deleted entities.

The area seems to be working again but im struggling to determine if its using both motion senors (suppect not). Most likely its only using the first correctly named sensor, therefore there is only one sensor and thats why is working :-(

I'll monitor and keep investigating.

Where is the configuration stored and will update the correct entity names manually?

jseidl commented 2 years ago

I think this this is the other bug mentioned around deleted entities.

Make sure you're on the latest release (3.0.1), that has been fixed there.

The area seems to be working again but im struggling to determine if its using both motion senors (suppect not). Most likely its only using the first correctly named sensor, therefore there is only one sensor and thats why is working :-(

Look at the presence_sensors attribute, shall list all sensors it is using for presence.

Where is the configuration stored and will update the correct entity names manually?

Configuration of integrations over the UI will be on the /config/.storage/ folder.

hirsts commented 2 years ago

Thanks for your response. It’s later here and so will explore more tomorrow.

Just an FYI that I’m using 3.0.1 and it’s deployed manually, not with HACS.

Kind regards,

Stuart

On 24 Jul 2022, at 6:53 pm, Jan Seidl @.***> wrote:

 I think this this is the other bug mentioned around deleted entities.

Make sure you're on the latest release (3.0.1), that has been fixed there.

The area seems to be working again but im struggling to determine if its using both motion senors (suppect not). Most likely its only using the first correctly named sensor, therefore there is only one sensor and thats why is working :-(

Look at the presence_sensors attribute, shall list all sensors it is using for presence.

Where is the configuration stored and will update the correct entity names manually?

Configuration of integrations over the UI will be on the /config/.storage/ folder.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

hirsts commented 2 years ago

Ive been trying to track down specifics but its difficult as there is more than one issue.

In the Garage there are two sensors that are working correctly however the area is always detected as occupied. Ive stopped using automations within MA to rule them out and the issues persist, its all to do with the area being detected as occupied regardless of how long I ensure that the two ZHA sensors are not triggered.

image

I have another area called "Cloak Room". This has a single Ikea ZHA sensor and a single light. It uses default settings with "Create light group" and was working and then just stopped. I can see when I enter that the ZHA sensor tiggers as does the "Area (Cloak Room" sensor but the light doesnt come on.

image

I Splunk both event updates and HA logs and dont see any issues related to MA or associated components.

I used MA v2 until the HA breaking changes to groups and moved to 3.0.0 beta, then 3.0.0 release and then 3.0.1.

I currently suppect the following:

1) There are some values stored in previous versions that dont get updated or corrected with either deletion and reconfiguraiton or version uplift of MA.

2) When entities get changed in HA they dont get updated in MA. This remains the case if the MA config for that area is deleted, HA Restarted and the config recreated. Something is being persisted somewhere.

3) Theres a state persistance issue with sensors setting the state of "Area ($area)" that gets locked somehow. This is either due to dual motion sensors or where one of the sensors gets renamed. MA persists the old sensor entity name and therefore fails to get the right variable to mark the <binary_sensor.area.$areaname> as unoccupied.

I didn't manage to find the config in .storage to manually update.

If I thought it would make a difference I would deleted the whole integration and start again with a fresh 3.0.1 but I'm not convinced that all of the old configuration would be removed and the issues would remain.

I'm currently at "its nearly brilliant" and keen to help resolve these issues.

jseidl commented 2 years ago

Got it. It's likely to be some leftover from previous releases. The 3.0-beta breaks backwards compat with 2.x and the 3.0 release breaks the 3.0-beta as well.

This was due the unique_id of MA's entities needing change to conform with HA's standards. You can check if you have any entities ending with _2 (which is the HA behavior when two entities have the same name. Might be the case that 3.0 created the entities with the new unique_id and now you have duplicated entities causing havoc.

Best for starting with 3.0 is to nuke'em all and re-configure, even if you're coming from the beta.

hirsts commented 2 years ago

Just to confirm the correct removal process:

1) Using "Settings" + "Devices & Services", delete the MA configuration for each area 2) Once each area is deleted then delete MA as a whole from "Devices & Services" 3) Remove "magic_areas:" from configuration.yaml 4) Delete /config/custom_components/magic_areas 4) Restart HA

Hopefully this will remove 100% of the MA configuration. If you could confirm this, that would be great.

jseidl commented 2 years ago

This is to fully remove the integration. If you're already on 3.0.1, you can just remove the areas (step 1) and restart to reset the configuration.

hirsts commented 2 years ago

Ok, so I removed everything including deleting the MA folder in "custom_integrations", restarted and installed manually from scratch using MA 3.0.1. When HA restarted, MA created config for most of the areas except 2. I have 24 areas and the 2 that were not created in MA havent been touched for months. Both "Pantry" and "Master Walkin", I dont see any issues in HA logs and this wasnt an issue before with any version of MA 2 or 3. Ive tried deleting and recreating the Pantry area in HA and restarting HA multiple times but this has not resolved this.

UPDATE (2 hours later): I just found that "Pantry" and "Master Walkin" were listed as being "disabled by the user". I havent disabled these but something thought they were for random some reason. I re-enabled them and they are now working the same as other areas if I specifiy the lights.

There also seems to be rooms working that had stopped working before and other that we working fine, that now dont work. Just to confirm, I have checked that "Area Light Control ($area)" switches are all turned on.

Cloak Room: This had stopped working previously but now after the reinstall and basic MA configuration, this room is working as expected currently.

Garage: Garage has two motion sensors and the issue of it being stuck as "detected" is resolved. I can see both sensors being activated and "Area (Garage)" going on and off as expected.

Pantry: This isnt working as the MA configuration has been created. UPDATE: Now working as expected

Laundry: This was working fine previously but now, with the same basic MA config as "Cloak Room", isnt working. I can see the motion sensor being triggered and "Laundry (Area)" triggering but no lights were turned on. I reconfigured Laundry in MA and the only change I made was to specify the Laundry Light entity in the Overhead Lights feild. This resolved the issue and even though both lights and motion sensor is correctly defined within the "Laundry" area in HA.

Lobby: This has the same issue as Laundry, it didnt work but did when I specified the light to turn on rather than leaving the option blank.

Summary: Everthing is working as it should after some work arounds re-enabing areas in MA and specifying specific lights to turn on. I'm hopeful that the currently deployment will remain working and I'll not change anything for a few days to make sure. Previous experience was that some things work work initially and they stop working. Fingers crossed.

jseidl commented 2 years ago

Thanks for the update. There was a behavior change between the last beta release and the final release that might explain the situation that previously if you haven't configured any lights it would turn on all lights. This behavior was changed to don't turn any lights if you don't have any defined, because there are situations where you may only want to have lights come up on the extended state. I do that to my entrance hall area and add the front door contact sensor as the accent entity so now lights only come on if I open the door or if there's activity in the area for a while.

Glad that so far everything is working. Nothing should change hopefully! Let me know if you have any other issues or if we can close this one.

Cheers!

hirsts commented 2 years ago

Thanks and keep it up, MA is great and simlifies automation greatly.

Just a couple of side notes: I find the options for when things should be triggered confusing such as "state" and "sleep" etc, some hover tips would be great. Also I dont use the automation options for some rooms as I want to send data options to specific lights such as {"effect": "Solid", "brightness":"150"}, maybe an option here would be to allow triggering a scene rather than a light?

Thanks again and well done, MA is one of the best addon's for HA.

hirsts commented 2 years ago

Closed but will monitor for issues

hirsts commented 2 years ago

Back to where this thread began, the garage has 2 motion sensors, was working fine but now is stuck with "Area (Garage)" showing as Detected regardless of how long the period of inactivitiy of the 2 montion sensors has been.

image

The config for this area is as follows:

HA Area:

image

MA Config:

image

image

image

NOTE: I use my own automations that use the "Area (Garage)" status for activation which is now stuck as "detected"

image

NOTE: Presense hold is turn on based on the position of the wall switch which has been off the entire time of this test

image

image

hirsts commented 2 years ago

BTW: Please consider using a different naming standard for the light groups created by MA as it would be natural for user to create something like light.bathroom_lights where this is just one switch. This leads to two enties called "Bathroom Lights", one being the one created by the user and the second being the light group created by MA and likely with an entity name of light.bathroom_lights_2.

We use an auto entity card to show everything that is "on". MA creating lots of additional groups leads to multiple entries on the auto entities card for just one device being "on". With 24 areas this is difficult to filter.

jseidl commented 2 years ago

Just a couple of side notes: I find the options for when things should be triggered confusing such as "state" and "sleep" etc, some hover tips would be great.

These "states" concept is indeed the biggest barrier that I'm yet to solve on how to explain it properly. I believe it to be the best way to handle MA in a way that features can be built upon reliably, I might be wrong but so far it's been very flexible and powerful.

These UI elements are quite new, as soon as they support that I'll definitely add hover hints/tooltips. I plan also on making the wiki better with examples and do a blogpost or video explaining some common scenarios but recent parenthood has not given me the required time.

Also I dont use the automation options for some rooms as I want to send data options to specific lights such as {"effect": "Solid", "brightness":"150"}, maybe an option here would be to allow triggering a scene rather than a light?

For scenes, there's a feature request for that. If your requirement is only brightness, I'd suggest you take a look at the Adaptive Lighting integration if you haven't so.

Thanks and keep it up, MA is great and simlifies automation greatly. (...) Thanks again and well done, MA is one of the best addon's for HA.

Thanks buddy, appreciate a lot!

Back to where this thread began, the garage has 2 motion sensors, was working fine but now is stuck with "Area (Garage)" showing as Detected regardless of how long the period of inactivitiy of the 2 montion sensors has been.

That's really odd. My guess would be that some of your other presence_sensors are flapping constantly.

image

Could you describe what each of the sensors listed under presence_sensors are? That might help me get an idea of what might be causing this.

TW: Please consider using a different naming standard for the light groups created by MA as it would be natural for user to create something like light.bathroom_lights where this is just one switch.

I hear you. I grew to name those "switch as X - light switches" something more specific like "Backyard Main", "Bathroom Vanity", or "Kitchen ceiling light". I'm not married to this name, it's whatever made sense when I was creating the feature, since that group is for all lights in the area I just went ahead and called "$area Lights". Could be "All Lights ($area)".

The catch is that I've done that for all other groups so change would have to be consistent across. Would have to wait for a major release tho since it's a breaking change.

jseidl commented 2 years ago

Hey @hirsts, any updates?

jseidl commented 1 year ago

Closing due inactivity. Please reopen if issue still persists.