MycroftAI / skill-homeassistant

Mycroft Skill/Integration for Homeassistant
GNU Lesser General Public License v3.0
114 stars 62 forks source link

request to turn on light group doesn't work if ONE (or more) of the lights is already on #37

Closed fermulator closed 2 years ago

fermulator commented 4 years ago

Consider the following light group

- platform: group
  name: Main Floor
  entities:
   - light.back_den
   - light.kitchen
   - light.dining_room
   - light.main_front_hall

or

- platform: group
  name: Kitchen
  entities:
   - light.kitchen_main
   - light.kitchen_sink
   - light.kitchen_island
   - light.kitchen_counter

Let's use the kitchen for this example.

  1. "baseline test" -- all lights are off

    Hey Mycroft, turn on the kitchen lights

    works!

    turned on kitchen

  2. "subset of lights in a room are on" -- and we want ALL lights in the room on

    Hey Mycroft, turn on the kitchen lights
    or
    Hey Mycroft, turn on all of the kitchen lights

    , doesn't work:

    no change kitchen lights already on

This is because the "state" of the group is on if any one sub-entity is on. Selection_042

Any suggestions for how to address this scenario?

PS:

  1. "subset of lights in a room are on" -- and we want ALL lights in the room off
    Hey Mycroft, turn off the kitchen lights

    , works:

    turned off kitchen

Tony763 commented 4 years ago

Yes, this could be done.

Api sends all entity_id in attributes: {"attributes": {"entity_id": ["light.kitchen_light", "light.outdoor_light"], "friendly_name": "Kitchen", "order": 0}, "context": {"id": "c0711b8a6081431a8600a22a4109e834", "parent_id": null, "user_id": null}, "entity_id": "group.kitchen", "last_changed": "2020-04-23T21:49:10.603502+00:00", "last_updated": "2020-04-23T21:49:10.603502+00:00", "state": "off"}

With that when we detect a group inside entity id we can loop trough all corresponding ids. This could be done for turn on/off and maybe for set/adjust intensity.

It's question what action could by done with intent toggle. If do action based on first entity or count states of all entities and do action based on percentage.

Tony763 commented 4 years ago

Fast workaround is to set all:true In HA group settings. Group will be only on when all entities are on.

fermulator commented 4 years ago

Fast workaround is to set all:true In HA group settings. Group will be only on when all entities are on.

downside of this is that if one is using the web UI, then it is more difficult to turn OFF all the the lights in the group hehe

fermulator commented 4 years ago

It's question what action could by done with intent toggle. If do action based on first entity or count states of all entities and do action based on percentage.

I was wondering about how to logically handle toggle as well.

On one side, I thought maybe toggle would actually be a workaround, like if I said

"toggle on kitchen lights"

But of course the pure answer is that

"toggle kitchen lights" , should actually toggle (INVERT) all of the lights within the group.

fermulator commented 4 years ago

This could be done for turn on/off and maybe for set/adjust intensity.

Note for set/adjust intensity/brightness; Intuitively, I could suggest that it would ONLY affect the lights in the group that are currently ON.

However I can see the other side of the coin that it should do it for ALL lights ... but some scenarios would not desire that scenario.

Tony763 commented 4 years ago

@fermulator Test this turn_on_all-group

fermulator commented 4 years ago

@fermulator Test this turn_on_all-group

@Tony763 i pulled down your branch on top of the ha skill /opt/mycroft/skills/homeassistant.mycroftai

mycroftai@mycroftai /opt/mycroft/skills/homeassistant.mycroftai $ git status
HEAD detached at tony673/turn_on_all-group

. restarted mycroft; (not sure how to verify it is actually loading your version...)

but .. after doing so, nothing works at all, so ..

 turn on the kitchen counter light                                                    skills.log, other                                                                 
 >> I don't understand.                                                               voice.log                                                                         
 turn on the kitchen sink light                                                                                                                                         
 >> I don't understand, but I'm learning new things everyday.                                                                                                           
 turn on kitchen light                                                                                                                                       --- 133.48 
 >> You might have to say that a different way.       
Tony763 commented 4 years ago

Seems just like TYPO: HEAD detached at tony673/turn_on_all-group

Change a order of numbers :)

fermulator commented 4 years ago

Seems just like TYPO: HEAD detached at tony673/turn_on_all-group

Change a order of numbers :)

gawd; how'd that even work? (it wouldn't have been a valid branch fun)

Tony763 commented 4 years ago

managed to get it working?

fermulator commented 4 years ago

@Tony763 sorry no, after the oopsie in the git branch switch, it wiped the config (didn't know the config was stored there! figured skill configs would be in user home...) - need some time delay before i'll try again cause I have to start over :(

fermulator commented 4 years ago

@Tony763 - got my setup re-installed on picroft - ready to retest; is that branch you have there still usable? (should we rebase it first?)

Tony763 commented 4 years ago

Yes, still works. I do not want to rebase it yet as i still have other open issues that i have fixed by this branch but need to test them

stratus-ss commented 2 years ago

@Tony763 is this still valid. I know we have merged a bunch of your stuff since the last comment in this ticket

stratus-ss commented 2 years ago

Closing this due to being stale