Lamp in HA is off and in HUE bridge it's on

I just started with Home Assistant so please excuse me if I don’t know the specifiek names for certain parts.

I have the following situation:
Untitled Diagram

When I switch the wall switch the shelly sends a signal to HA which send a toggle message to HUE bridge to get the lamp on.

The problem is that in HA the switch is off and in HUE the lamp on. Does that has something to do with the toggle of the light instead of putting it off or on?
Users can switch the light on via the wall switch which works via Shelly -> HA -> HUE or use the HUE app on their mobile or use the remote from hue.

Now I have this automation:

- id: '1579187816097'                  
  alias: Licht Slaapkamer J&J          
  description: ''                         
  trigger:                             
  - entity_id: switch.shelly_shsw_1_b96815
    from: 'off'                           
    platform: state                       
    to: 'on'                              
  - entity_id: switch.shelly_shsw_1_b96815
    from: 'on'                            
    platform: state                       
    to: 'off'                             
  condition: []                           
  action:                                 
  - alias: ''                             
    data:                                 
      brightness: 255                     
      kelvin: 2700       
    entity_id: light.slaapkamer_j_j_2
    service: light.toggle

Is there a way to get the switch in HA synced with the in HUE? Or do I need to create a different kind of automation?

Thanks in advance!

so after that automation fires, light.slaapkamer_j_j_2 has a state of off?

Yes but the HUE led lamp is on and the bridge also says it’s on.

So when somebody turns the lamp on via the app then that on status is not set in HA.

where does the light come from? what integration?

What do you mean? HUE lamp is connected to the HUE bridge.

You can turn it on via the app or via the wall switch. But in HA the switch is off but in HUE the switch/light is on. You want some kind of synchronization between the two that if via the HUE app the lamp is turned on the switch in HA should also be turned on.

So are you using the Hue integration?

Yes, I did.

check out this param

If that’s not the problem, then there isn’t much you can do because that integration is what monitors the state for hue lights in home assistant.

Fixed it… :man_facepalming:

I was checking the status of the switch of the shelly instead of the HUE lamp. You should not care what the status of the shelly switch is. It toggles.

How stupid of me…

So how does your automation finally look like? I have the same problem…

you can make a template light or switch if you have a toggle switch and a sensor that displays the state.