slashback100 / presence_simulation

Home Assistant Presence Simulation
423 stars 22 forks source link

Possible to add multiple switch entities? #95

Closed mngsps closed 4 months ago

mngsps commented 10 months ago

Hi @slashback100 , at first, thank you so much for this great work! One question: Is or would it be possible to add and configure multiple presence simulation switches (e.g. to have separate ones for lights, covers or different floors/rooms)? I tried, but the second one will not create a switch entity in my case... All the best and kind regards Benedikt

slashback100 commented 10 months ago

It has been asked in #27. I can take a look to see how to do that, but it seems like an important architecture change

slashback100 commented 8 months ago

Just created a branch manage_multiple_switches with this feature. Don't know if you can test it, in particular the migration from old to new version

tomrennen commented 5 months ago

Hi @slashback100, hopefully you're still following up on this:

I've now activated the manage_multiple_switches variant on my prod environment (Because I really want this feature). My specific setup is:

Now I've gone ahead and deleted the old presence simulation (I'll test migration later, but I want to test with clean slate first), then installed the manage_multiple_switches branch.

What I saw:

  1. The second presence simulation switch was unavailable until a restart
  2. When activating just the "Lights" PS, the attributes show next event being closing cover_0001:

This actually is applied: the covers were closed even though it was disabled for the "Covers" variant.

Edit: Lights are fully ignored, even when all PS instances are enabled. It seems like only the last added presence simulation is looked at.

slashback100 commented 4 months ago

Yes, still working on it but can't figure out why the entities are unavailable...

slashback100 commented 4 months ago

Got this problem fixed. Working now on the mix up between switches

slashback100 commented 4 months ago

There you go. I fixed the issue, which included a refactoring of the restore after restart feature. My tests give good results. Everything is in branch manage_multiple_switches, I created a PR I just need to test the migration from a v3 to this v4 still.

slashback100 commented 4 months ago

I tested the migration. It works, but since the logic changes, the id of the switch entity changes --> a new entity will be created (switch.presence_simulation_2) and the previous one will be unavailable. I don't see any solution, it is kind of breaking change. I will merge on the main, but won't do any release for now, I will be on holiday so don't have time for fixing issues.

slashback100 commented 4 months ago

FYI I managed to avoid the breaking change in the migration

slashback100 commented 4 months ago

Release has been done : https://github.com/slashback100/presence_simulation/releases/tag/v4.0