#Inovelli White Smart Bulb Control + HomeKit toggle automation issue

62 messages · Page 1 of 1 (latest)

sonic shale
#

I’m trying to sync it to where I can control the smart bulbs in a room with both a switch and Siri/Apple Home. I’ve currently got it automated to where this mostly works, but if I toggle the lights on then back off it will get confused and start behaving inconsistently.

Inovelli has a setting where you can make the switch never unhook the light circuit, and it just toggles the switch’s status for integrations.

Structure:

1: Automation to match switch to Phillips Hue
2: Automation (2, one on and one off) to make switch control Phillips Hue

I’m not sure exactly how automations operate but I think that my issue is that when the “match Phillips hue” (1) automation runs, it then triggers automation 2. Do automations work like this? Is there a flag I can set to prevent this if so? Thanks…

Edit: I also tried repeat move on the code shown and it seemed slightly more stable but that could have been complete random chance

sonic shale
#

Inovelli White Smart Bulb Control + HomeKit toggle automation issue

wide lotus
#

If they are different automations they can definitely trigger each other - there is a way to catch this (automations set the trigger.context.parent_id variable to be the automation, whereas manually changing it will set it to none) but it gets ugly and imo not the best way to go about it

Just to double check I understand the whole system:
You have a Hue light "light.desk" that can be controlled through Siri and now you want to connect to a switch through an automation
You have a second light that you want to automate to always match the "light.desk" bulb

#

My guess is the problem is coming from your switch automation - if you turn the lights on from the switch, then turn it off from siri, the lights will be off but your switch will be on - so when you next toggle the switch, thinking it's turning the lights on, because they're currently off, it's actually to off and it'll try to turn the lights off and thus seem like it's not working.

There's a couple of ways I could see to prevent this "desyncing" of the switch and hue bulb - and it kind of depends how the switch behaves, but for minimal changes and confusion I would add service calls to "switch.turn_on/off" in automation 1 to force the internal state of the switch to always match the hue bulb
An alternative would be to delete automation 2 and 3 and replace them with:

entity: switch
from:
  - "on"
  - "off"
to:
  - "on"
  - "off"
actions:
  - action: light.toggle
    target:
      - entity_id: light.desk
``` (not actually valid yaml but that's the idea)
sonic shale
#

the "second light" is a light switch. but it presents to homeassistant as light. so i guess its functionally a light

intended behavior:
turn on/off light switch, turn on/off hue lights
turn on/off hue lights (home app, siri, hue app), turn on/off switch

so theyre always in a matching pair, if one is on the other is on and the oppisite

#

as far as i understand you got what i meant already tho

wide lotus
#

So yeah, I'd look at either of those 2 options as potential fixes

sonic shale
#

alright i will try it soon and report back. i have a job interview today so i really shouldn't be worrying about this rn but its bothering me that i cant figure it out haha

wide lotus
#

no worries and good luck with the interview

sonic shale
#

alright so i tried that and it didn't fix the issue... it still has buggy behavior if i turn the lights on/off back to back what i think is happening is

Me: i hit turn off on HomeKit, lights turn off [Starts thread A]
Thread A: home assistant runs automation to turn switch off switch (match Hue Lights) [Triggers next automation]
Me: i hit turn on on HomeKit, lights turn on
Thread A: home assistant runs automation to make Hue match switch, lights turn off

#

its possible it doesnt work like that but i think that might be whats going on from what you said yesterday

wide lotus
#

ah, is this an issue happening if you are slamming the switch on/off/on/off really quickly?

sonic shale
#

I wouldn’t really say “super quickly” it’s like if I do it within about 2 seconds. I guess it’s livable but I really like rock solid solutions lol

#

well that might have been a fluke but just now I did it again and it did that behavior with like a 5 second pause

#

Both automations (match switch to hue and match hue to switch) are in “restart” mode, I dunno if a different one would fix it

wide lotus
#

Hmmm that's weird - I think restart is probably the best for this, but maybe stick it in queued for a bit to ensure you don't lose anything

sonic shale
#

i might just give up and bite the bullet and get those hue dimmer switches for hue bulbs and only use smart switches for non-smart circuits, it kind of drives me crazy that there's no true neat solution for having both physical and virtual control of smart bulbs

#

yeah queued makes the behavior worse rip

wide lotus
#

Could you paste all the current yaml code for your automations

sonic shale
#
alias: Match Lights to Switch
description: N/A
triggers:
  - entity_id: light.white_series_smart_2_1_switch_light_1_2
    trigger: state
actions:
  - choose:
      - conditions:
          - condition: state
            entity_id: light.white_series_smart_2_1_switch_light_1_2
            state: "on"
        sequence:
          - target:
              entity_id: light.living_room
            action: light.turn_on
            data: {}
      - conditions:
          - condition: state
            entity_id: light.white_series_smart_2_1_switch_light_1_2
            state: "off"
        sequence:
          - target:
              entity_id: light.living_room
            action: light.turn_off
            data: {}
mode: restart```

```yaml
alias: Match Switch to Desk Light State
description: N/A
triggers:
  - entity_id: light.desk
    trigger: state
actions:
  - choose:
      - conditions:
          - condition: state
            entity_id: light.desk
            state: "on"
        sequence:
          - target:
              entity_id: light.white_series_smart_2_1_switch_light_1_2
            action: light.turn_on
            data: {}
      - conditions:
          - condition: state
            entity_id: light.desk
            state: "off"
        sequence:
          - target:
              entity_id: light.white_series_smart_2_1_switch_light_1_2
            action: light.turn_off
            data: {}
mode: restart

the reason one polls specifically the lamp is because i couldn't get it to work with the "lights.living_room" which is the hue... "virtual" switch(? idk exact terminology) that toggles all the light bulbs at once, it doesn't list it as having any available state info like "is turned off" or "is turned on" unlike a specific bulb

wide lotus
#

ok, what is the relationship between light.desk, light.living_room and light.white_series_smart_2_1_switch_light_1_2?

#

is living_room a light group with both desk and white_series... in it?

sonic shale
#

light.living_room is all like… 6 bulbs in the room. it presents to home assistant as an icon of 3 light bulbs and toggling it toggles every light bulb in the room. light.desk is one of the bulbs in that group, chosen arbitrarily because it has the shortest name. it is always controlled in a batch with the others besides color

light.white_series etc etc is the light switch

wide lotus
#

OK, and that's the one controlled by home kit?

sonic shale
#

im not exactly sure how homekit sends the signal but hitting the on/off button in homekit has the same effect to the state of the room as toggling light.living_room in home assistant. I think it may send an individual command to all of the lights separately but I have them grouped

wide lotus
#

gimme a sec, i'll look into it a little

sonic shale
#

in HomeKit, this button controls the same lights as light.living_room

wide lotus
#

and you're using homekit bridge to link to home assistant, or is it running entirely independently?

sonic shale
#

The switch is added directly to HomeAssistant, hue is added to both independently. the switch is like a little too ambitious so it shows up as a huge headache in HomeKit, I’m trying to use home assistant here primarily to simplify things… (ex it has an LED bar that HomeKit thinks is a light bulb, HomeKit also sees the switch itself as a light bulb even when in smart bulb control mode…)

I’m not sure if you would have any idea about this, but if added to HomeKit directly it has the ability to just present as a scene controller that you can assign scenes to, (ex, up does x down does y) which I think would probably work around all of this, but as far as I can see HomeAssistant doesn’t have the ability to forward that element

#

for the one that I have that just controls dumb lights I forwarded it to HomeKit as a simple on/off light switch because it also is classed as a dimmer by default but you can’t dim multi way circuits which is where that one is installed, that one works with no issues

wide lotus
#

Are you sure light.white... is what home assistant calls the switch, and not the light of the switch?

#

I'm afraid this might end up being some quirk of homekit behaviour and i have less than no experience with HK

sonic shale
#

yes, home assistant calls the LED strip white_series_smart_2_1_switch_light_6_2

#

i too am prob getting too ambitious here myself, i appreciate you trying to help lol. i will prob just move this one to a different dumb circut and get hue dimmers for hue lights

#

I got two, one to try with dumb lights and one to try with smart lights and the smart light thing is I guess just not there yet, not sure how much of that is on Inovelli and how much is on Apple, definitely shared blame but not sure who has the majority

#

I guess Matter not having a like “status light” device type doesn’t help either one of them

wide lotus
#

i prodded some others who might be able to help, because this is definitely something that should be doable ^^

sonic shale
#

thank you so much for all your effort, and sorry if I ever came off as annoying 😊

wide lotus
#

dw, i know how it feels during integration hell ^^ nothing more annoying than looking at something and being like "this feels like it should work, WHY ISN'T IT?!?"

sonic shale
#

I went to college for cs and to this day trying to fix code that can cause like cyclical triggers like what I think might be happening gives me a headache and makes me want to slam my laptop shut lol, I can only imagine the agony of the developers who make all this smart home integration stuff for us

unique snow
#
- alias: Deck String Lights
  id: toggle_deck_string_lights
  trigger:
  - platform: state
    entity_id: &deck_string_entities
    - switch.deck_mood_lighting
    - switch.patio_string_light
  variables:
    entities: *deck_string_entities
    state_list:
    - 'on'
    - 'off'
    continue: >
      {{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }}
    to_state: >
      {{ trigger.to_state.state | default(none) if continue else none }}
    targets: >
      {{ expand(entities) | rejectattr('entity_id', 'eq', trigger.entity_id) | rejectattr('state', 'eq', to_state) | map(attribute='entity_id') | list if continue else [] }}
  condition:
  - condition: template
    value_template: "{{ continue and to_state in state_list and targets | count > 0 }}"
  action:
  - service: switch.turn_{{ to_state }}
    target:
      entity_id: "{{ targets }}"
#

yaml only

#

if you need it to work with anything but switches, let me know. Just modify this list


    entity_id: &deck_string_entities
    - switch.deck_mood_lighting
    - switch.patio_string_light
#

TLDR: it debounces the turn_on/off commands.

#

when you turn one on, it will turn the other on and vice versa and it will debounce other runs of the automation so that you don't get oddness

#

You can use any number of switches

#

if you want it to work with lights, change this line from - service: switch.turn_{{ to_state }} to - service: light.turn_{{ to_state }}

#

and if you want it to work with lights and switches, change it to - service: homeassistant.turn_{{ to_state }}

sonic shale
#

Thanks so much, I will try this later today

mystic rapids
#

You have a lot going on here, it took me a while to decipher the entirety of this thread as it bubbled up to the top again. I'm a prolific user of Inovelli and of HomeKit so perhaps I can provide some assistance here (then again maybe I cannot LOL).

So on your Inovelli White SWITCH, which is thread/matter (which I don't really use in my system), it has - like most Inovelli's in the past few years - a "Smart Bulb Mode" on it. Is this enabled? Is it set to On/Off instead (thus no Smart Bulb Mode)? When in smart bulb mode it does not cut power to the load, it just virtually indicates that it's on or off so you can use that as a trigger to control your bulb because if it was on/off then you lose power to load and then to your bulb and then you have no communication with the bulb at all.

If it's smart bulb mode then you simply need to create automation that says to turn the bulb {mode of switch} (i.e., light.turn_{{mode}}). If it's on/off then you need to synchronize, probably giving the bulb a few seconds to register with the network after regaining power.

I apologize if you answered this, I didn't see any reference to the smart bulb mode of the switch in the threads so it prompted this response.

sonic shale
mystic rapids
#

If that's the case then you should only need automation on the switch to toggle the bulb and expose the switch to HK, which in turn should fire the automation when toggled. The inconsistent behavior could be due to toggling too fast, although I wouldn't think it would be too much of an issue. I would start at basic HA first, toggling the switch and seeing if the bulb gets "confused", if so then it may be a latency issue and has nothing to do with HK. If HA works but HK has issues due to rapid changes then you have to either slow down your toggle frequency in HK or create a switch template to add a bit of a delay or sanity check. Since HK has to talk to HA, it's possible to actually toggle faster than the transaction can make it through.

I don't use the Smart Bulb mode that much, only on a couple of bulbs, and it works rapidly, even when exposed through HA to HK.

sonic shale
# unique snow ``` - alias: Deck String Lights id: toggle_deck_string_lights trigger: - p...

where exactly am i supposed to put this? I see code like this a lot and I can never figure out where it is intended to go, because if i like open a new automation, set it to edit in YAML and then paste code that starts with -alias it errors saying its in the wrong format... is there a different menu for this that I dont see?

i also tried to just remove the - before alias and that made it not pleased

also going to try this on my “dumb switch” as well because rarely it seems to have debouncing issues even though it’s wayyyyy more stable overall…

unique snow
#

It goes in configuration.yaml

sonic shale
mystic rapids
#

As you have seen, that's not how it goes - or where it goes. configuration.yaml is a generic term, not a verbatim cut-and-paste. Since all configs are done via configuration.yaml Petro was saying to put that into your config in it's proper place. He also used one of his own (presumably) systems for an example for you to work from and it's more on the 'advanced user' side of things.

The easiest way to go about this is to simply create an automation for turning on the bulb when your switch is turned on. Start with a single trigger entity and just put in an if...then statement that if that switch is on then turn on your bulb, otherwise turn it off.

#

Or even two automation, one for when it goes on and another when it goes off, sometimes starting with the absolute basics are a good way to learn how to start diving into more advanced methods of doing automation.

unique snow
# sonic shale ???

Sorry! I was mixing up people. That goes in your automation area. If you remove the first -, you can paste it in yaml mode in an automation

sonic shale
#

so far, semi good. ive had a few hard crashes of the entire OS with this but im pretty sure it was due to a typo on the script or something that i think ive now fixed, will update in a while