unfoldedcircle / feature-and-bug-tracker

Feature and bug tracker repository for Unfolded Circle products
22 stars 0 forks source link

[Bug] Entity Change events are not properly processed on remote if light entity does not have "toggle" feature #180

Open Talkabout opened 8 months ago

Talkabout commented 8 months ago

Is there an existing issue for this?

Description

Using light entities without "toggle" feature causes the state (on, off) to not be properly shown on remote. It seems that the entity change events are not handled correctly.

How to Reproduce

  1. create light entity without "toggle" feature
  2. assign entity to a page
  3. try to switch the light
  4. although the light switch is triggered, the corresponding "entity_change" event containing the "ON" state does not reflect on the remote
  5. this behaviour causes the switch to "lock" as without the "toggle" feature the remote tries to always send the "on" command

Expected behavior

The entity state should reflect whatever the "entity_change" event provides as information.

System version

1.4.5

What part of the system affected by the problem?

UI, Core, Integration

Additional context

No response

zehnm commented 8 months ago

I cannot reproduce this and only found another issue while testing it (https://github.com/unfoldedcircle/remote-ui/issues/4). Tested with a demo integration:

Are you sure that your integration sends an entity_change event with the correct state? As far as I remember, the UI immediately shows the expected state first, then uses the known entity state. That would explain why the other pages still show the old known state.

After a command, the integration needs to send the new state. Only acknowledging the entity command is not enough. Example:

<-: {"kind":"req","id":81,"msg":"entity_command","msg_data":{"cmd_id":"toggle","entity_id":"switch1","entity_type":"switch"}}
->: {"kind": "resp", "req_id": 81, "code": 200, "msg": "result", "msg_data": {}}
->: {"kind": "event", "msg": "entity_change", "msg_data": {"entity_id": "switch1", "entity_type": "switch", "attributes": {"state": "ON"}}, "cat": "ENTITY"}

See Python example in https://github.com/unfoldedcircle/remote-ui/issues/4 The integration library will send a change event with:

        api.configured_entities.update_attributes(
            entity.id, {switch.Attributes.STATE: state}
        )
Talkabout commented 8 months ago

Hi @zehnm ,

I tried again with another entity, configured it with only "on_off" feature and was NOT able to reproduce it either. Maybe there was a state issue or something similar with the old entity. Glad though that you found another issue that can be fixed based on my ticket :)

Talkabout commented 8 months ago

Hi @zehnm ,

today I was again able to reproduce this issue. The entity is one that worked in the past without problems. This time this entity supports the "toggle" feature, but switching it on did not reflect the "on" state on the remote, the light itself toggled properly. I checked the events fired by the integration and received by the remote in the "websocket test console" and in both cases I could see the events being sent and received correctly, still the UI did not reflect the correct state...

Image

Image

Please ignore the "UNKNOWN" state as this happens when the status in my home automation system is something like "set_on".

I tried to download logs in "DEBUG" mode to check if I can find more information, but unfortunately nothing there related to my integration.

I then decided to restart the remote and after rebooting it the entity works as expected and the state is reflected on the UI. So it seems something "hangs", but I don't know how to find out what...

Do you have any idea how to debug this further?

Thanks!