Automation fires at night (knx, hue)

Hey,

I’m using ha, knx and hue. I have a knx phyisical light switch which triggers a automation to turn the light on. It works perfect and I can change the color etc.

But… from time to time the light turns on in the middle of the night and it is only in the night. I checked the logs and I don’t know why the light is turned on. We also use hue in other rooms but without the knx light switch. So only this combination is the problem.

Any idea?

Here is the automation

alias: Hue Schlafzimmer Einschalten
description: ""
trigger:
  - platform: state
    entity_id: sensor.schlafzimmer_helligkeit
condition:
  - condition: template
    value_template: "{{ (float(trigger.to_state.state) > 0) }}"
action:
  - service: light.turn_on
    data_template:
      entity_id: light.schlafzimmer
      brightness: "{{ (float(trigger.to_state.state) * 255 / 100) | round(0) }}"
mode: single

Did you check the history of your sensor.schlafzimmer_helligkeit?

Maybe also have a look at Advanced control of any light entity from KNX (state, brightness, dim, temperature, color + states feedback)
it might suit your needs.

1 Like

Thank you very much for the interesting blueprint! I have to check it and how to use it in my case. I have a button to toggle between 0%, 50% and 100% brightnes and a second button to toggle between to color.

I checkt the entity and the this error:
image

Schlafzimmer = sleeping room
Helligkeit = brightness
Wiederhergestellt = restored

If I open the enity I get the following error:

“This entity is no longer provided by the knx integration. If the entity is no longer used, delete it in the settings.”

What makes me wonder is, that I can still use the physical light switch to turn the light on and off…

Here is the knx config in ha

    #####
    # Hue
    #####
  - name: "Schlafzimmer Helligkeit"
    state_address: "1/3/30"
    type: "percent"
  - name: "Schlafzimmer Farbe"
    state_address: "1/3/31"
    type: "percent"
[...]
expose:
  - type: percent
    entity_id: light.schlafzimmer
    attribute: brightness_pct
    default: 0
    address: "1/3/30"

“Unavailable” in KNX can mean 2 things:

  • your KNX tunnel is not connected. If it gets reconnected, the state changes from “unavailable” to whatever it reads from the bus → your automation may trigger
    Check the history, not the current state - you will see if and when it changed from unavailable to something else
  • the entity you are looking at is not the one referenced by your yaml configuration, but an orphaned entity. Have a look at Open your Home Assistant instance and show your state developer tools. if you find a similar one - with _1 or something like that appended to the name. This can happen if you change the significant group address of a knx entity (see https://www.home-assistant.io/integrations/knx/#duplicate-entities)

Other than that, check the automation debugger what exactly triggered your automation (or if it was triggered at all - maybe there is another one doing so…)

Hey @farmio, thank you very much for the very clear, structured and helpful answer.

The KNX ist connected, because I get other values like temperatures, motion, light, cover etc. Also in HA I see the group monitor.

I search the log for “unique” to check for duplicate entities. Nothing.

I have also a lot of entities where the state is unavailable like my weather station, but I get the values form the weatherstation through knx.

I also did not find a duplicate of an entitie.

I will debug the automatisation if the light will go on the next time.

Do you have some

Could not sync group address

Messages in your logs? If so, have a look at https://www.home-assistant.io/integrations/knx/#group-address-can-not-be-read

A correctly set up Knx entity can’t be unavailable when the bus is connected. If it is disconnected, all Knx entities are set unavailable.

some? a lot… I checked it in my ets and it is very confussing…

but…

I check more GA and some doesn’t have the read flag set. I also noticed, that the error appeared for the first time yesterday. What I do not understand is, that everythink works, only the spontaneous trigger. And the error logs appeared yesterday.

I had also considered whether the firewall or AdGuard could be the cause. But HA and the KNX is in the same network and adguard also runs since few months.

Should I set the read flag and observe the situation?

My ETS config
image

No. Unless you know exactly what you are doing, you should not mess with that. Playing with flags can lead to awkward situations that are quite hard to debug in the future. Normally an objects flags are set properly and don’t need any changes.
Consider not using GAs as *state_address in HA if it doesn’t have a read-flag set instead.

Since you seem to use a router, are you using routing or tunnelling to connect HA? What IA does HA use? Do you use KNX Secure?

Good that I asked, because I thought that the default values are ok.

I configered KNX in HA before the integration was published. I checkt the integration and if it is right, I’m using tunneling.


I switch for english, but it is still german… The connection is establish 2 days ago. 0 receiving and sending erros and the connection type is “Tunnel TCP”

I download the diagnosic data and it seems to be outdated. The local and host address are old.

  "data": {
    "xknx": {
      "version": "2.11.2",
      "current_address": "1.0.1"
    },
    "config_entry_data": {
      "individual_address": "15.15.250",
      "local_ip": "192.168.0.157",
      "multicast_group": "224.0.23.12",
      "multicast_port": 3671,
      "rate_limit": 20,
      "route_back": false,
      "state_updater": true,
      "telegram_log_size": 200,
      "connection_type": "automatic",
      "host": "192.168.0.116",
      "tunnel_endpoint_ia": null
    },

In the past I had the configuration done in the configuratin.yml and I add all sensor, switches etc. using yml. For the first time I tried to use the knx physical switch to controll a hue lamp. I used this cookbook: KNX Cookbook - Community Guides - Home Assistant Community (home-assistant.io)

IA?

No.

This all looks perfectly fine. I’d have a look at the automation debugger and if there are any other Knx related messages in the logs.

Does your Knx installation have multiple lines (line couplers)?

I have to wait for the next event because the last event is to far away and I do not see it in the debugger.
Actually I have only the “Could not sync group address” error in the log.

Yes, I’m using a line coupler.

Did you add the group addresses to the tunnel interface you are using?
They may not be added to the couplers filter table and so can’t be read from HA. You can revise the filter table from ETS. See https://support.knx.org/hc/en-us/articles/115003363245-Filter-tables