ad-automoli icon indicating copy to clipboard operation
ad-automoli copied to clipboard

`disable_switch_entity` only if automoli switched a light on

Open chbndrhnns opened this issue 4 years ago • 5 comments

My use case:

  • i have a light strip in the kitchen which is switched on based on illuminance and motion
  • if it's on and I additionally switch on other lights, I would like to disable automoli

In my understanding, disable_switch_entity switches automoli off completely. Is my use case covered by an existing functionality already?

chbndrhnns avatar Mar 29 '20 14:03 chbndrhnns

Is there something that I could provide as additional input to that issue? I still see that I am missing that functionality and I am not sure how I could simulate that in pure HA YAML.

chbndrhnns avatar Oct 19 '20 12:10 chbndrhnns

I am currently very busy due to the university. Be back in december for my open source projects... So, give me just a few more weeks 👍

benleb avatar Oct 19 '20 16:10 benleb

Would you have a conceptual idea how this could work? Then I could try implementing it.

Something like tracking in a dictionary which lights have been switched on by automoli?

chbndrhnns avatar Oct 19 '20 16:10 chbndrhnns

tl;dr: duplicate the self.disable_switch_entities set and self.is_disabled() function but check only in lights_off and not in lights_off and lights_on like self.is_disabled()


Hm my first idea would be an only_on option/mode to control this behavior which you could enable when you switch on additional lights (maybe an automation or something...).

This option could then be checked similar to the "humidity above threshold" condition. The humidity conditions originate from showering - if humidity is high because someone has a shower, automoli will not switch off the light.

If so, you could try something quick and dirty like

self.only_on_entities: Set[str] = self.listr(self.args.pop("only_on_entities", set()))

around line 144 (similar to "disable_switch_entities")

and

if any([bool(await self.get_state(entity) == "on") for entity in self.only_on_entities]):
    return

above the linked shower check around line 424.

A little more elegant would be to duplicate the is_disabled() function to is_only_on() and implement accordingly. checking could then be placed below the is_disabled check

If anything is unclear, feel free to ask :)

benleb avatar Oct 19 '20 17:10 benleb

Something like tracking in a dictionary which lights have been switched on by automoli?

This already happens. AutoMoLi saves handles (strings) there if it switched on the lights (to keep track to switch it off later). see self.handles and the clear_handles() and refresh_timer() functions

benleb avatar Oct 19 '20 17:10 benleb

should be fixed by your own #56

evildad avatar Apr 24 '23 13:04 evildad