Support sync_state for all device types

In integration => KNX => configuration => communication settings, we can enable and disable “state updater”. The description:

“Set default for reading states from the KNX Bus. When disabled, Home Assistant will not actively retrieve entity states from the KNX Bus. Can be overridden by sync_state entity options.”

But according to KNX - Home Assistant, not every device types has sync_state as optional parameter.

Hi :wave:!

For button, scene and notify it wouldn’t make sense.
Climate is an edge case where some configuration would not work without sync_state (when set to False).
Platforms that support respond_to_read would need validation - it can’t read from itself I guess.

For the rest it should be fine. Do you want to add that functions yourself?

I was planning to change the option to turn it on/off in the Configuration menu to make the default strategy and time selectable.

Another question @ouzhg : what would you configure syncc_state to on your entities?

Hi farmio,

Thanks very much for for reply. If you agree, I would like to add that function by myself, for device types of Fan, Climate, Cover, Switch, except Button, Scene and Notify.

For my case, I would configure Climate for my floor heating. That a power saving screen, sleep for several minutes, wake up, write current temperature to KNX, if the current temperature is lower than expectation, write switch on to KNX.

Sure, go ahead.
I guess the xknx lib already supports that, so it’s just missing configuration in HA (schema and documentation) Configurable sync_state in all devices by farmio · Pull Request #722 · XKNX/xknx · GitHub

I’m not sure though how this would help for your described issue, but tbh I don’t 100% understand what you are trying to do.

Hi,

may I have the “state updater” active and then disable the sync_state for certain sensor where I need to have the passive read only ?

Doesn’t matter - disabling the state updater seems to have no effect anymore :upside_down_face:

If totally makes sense for me.
If you have a switch GA for example that doesn’t have a device that saves the state, home assistant will try to read the GA when there is no update for one hour.
But nobody will respond to the read request. Home assistant will therefore set the GA to off and also write it to the bus.
That is not the expected behavior. So in this case one needs to be able to disable the sync for these specific items.

I also have this for dimming GAs where the endpoint is a broadcast address of my DALI Gateway. This address also can’t be read so it will spam the log every hour. Luckily it doesn’t write to the bus in that case.

You can just omit the *_state_address for almost all entity configurations. These are optional. HA will never send a read request then.
For switches you may even set respond_to_read so other knx devices can query HAs state (similar to expose).

That is not the case. States are not changed when no responses are received. Neither will anything be written to the bus.
On startup though it will assume OFF state when there is no response.

If you experience different behavior you should investigate if some automation etc is doing that on your system.

1 Like

Thanks for the hint!
It was a wrong L flag in one of the KOs of the devices connected to this GA.
I just let the Group Monitor run again.

Omitting the state address is not a good option. If a bus device changes the state, HA would not notice it and have the wrong state.

You can configure passive addresses instead. These will update the state, but not actively read, nor sent to. https://www.home-assistant.io/integrations/knx/#group-addresses

Does not work, at least not anymore, only sets first entity by second, when using two entities.

Not sure what you mean by this, or what exactly doesn’t work for you. Can you elaborate?

In HA you can configure sync_state in the KNX-GUI for light and switch. In YAML, sync_state for light and switch brings up an error.

It would be great to use sync_state for all entities in YAML :slight_smile:

Same problem as herr2d2
sync_state return an error:

Invalid config for 'knx' at KNX.yaml, line 12: 'sync_state' is an invalid option for 'knx', check: knx->light->0->sync_state

sync_state is needed at the init of HA to sync the light state.
After the start up init, it’ is no more needed because the actuator will always return and send the output state on each command (On/off, scene, timing, …)

So yes, it would very nice to have this option. It will reduce significant number of useless telegram on the knx bus.

Thank you :smiley: