How to send percentage values via "knx.send" service?

Hi,

I’m currently trying to use HomeAssistant as bridge between my KNX bus and some HUE lights. What I’m trying to do atm is for HomeAssistant to replicate the state of the HUE lights on the KNX bus. In detail I’m trying to send the “on/off” state (which is working fine) and the “brightness”, which doesn’t work. From my research the xknx light component is sending/processing values from 0-255 for the brightness, thus basically just forwarding the internal HA state value. When I try to do the same by calling the “knx.send” service with the payload “200” (f.e.) the group monitor of the KNX bus is showing me a value of just “1”. It doesn’t matter if I pass the value as int or as struct. I’m using AppDeamon atm to call the service, since it is easier for me to do compared to templates etc (which I’m not familiar with yet). Do I have to convert the brightness values to something else before I pass them as payload to the service, or does the service maybe have a bug? I’m kinda lost atm and am welcome for any input on how to correctly send a brightness/percentage value to the KNX bus. Thanks.

nvm, it was an error on my end. I only sent the brightness value when the light was turned on, and at this point HUE is reporting the value 0. I’m now also correctly monitoring the brightness state and forward this to KNX.

Sorry for the noise and thanks for this awesome piece of software

Could you share some of your KNX/Hue configurations? I like to see how you implemented this.

Thanks

sorry, missed your reply. I’m using AppDeamon for the KNX/Hue bridge since for me it was the easier approach compared to messing with scripts and templates and what not.

This is my AppDeamon application: https://pastebin.com/uCJLkpqq

and this is an “app” example of a light that I registered in the apps.yaml file

hue2knx_light1:
  module: hue2knx
  class: Hue2Knx
  entity: 'light.your_hue_light_entity'
  toggleAddress: '10/1/2'
  stateAddress: '10/2/2'
  brightnessAddress: '10/3/2'
  dimmAddress: '10/4/2'

For this to work, you have to tell the KNX component to monitor a certain group address range so that you can catch the KNX signals on the event bus of home assistant. Something like this (you ofc have to adjust the group address range)

knx:
  state_updater: true
  fire_event: true
  fire_event_filter: ["2/*/*","10/*/*"]

that’s about it

edit: this currently only supports on/off and dimming, no color control via KNX yet.

Hi,

This integration is working super for me!
When do you plan to integrate the color control via knx also?

gr
Paul

no actual plans for this yet since I noticed that I rather use my phone to change the color than getting up from the couch and walk to the KNX switch :wink: So that’s really a low priority thing for me in my current smart home configuration.

no problem, but thank you for this, its working perfectly!

would you need a way to send a specific color value, or “cycle” through the RGB spectrum (like many one- or two-button solutions seem to work)?

The nicest thing would be if i could pick a color over my mdt glastaster 2 buttons

you mean https://www.mdt.de/Glastaster_Smart.html ? I also have those, but there you can’t pick a specific color but only walk up or down the color spectrum (like dimming from 0 to 100, but for colors). That’s at least what I figured out. That might be rather easy to do.

Yes i have the same here, but bought my first hue lights for 2 weeks so i didn’t do anything with the colors untill now

But those lights ara a lot cheaper then the theben dmg2t dimmers i used untill now :wink:

update - got it working - at least somewhat. I can see the current hue value (color) in my KNX switches and can also change the color via the KNX switches. But at some point the KNX component of HA just dies for yet unknown reasons. Once I found a fix for this, I’ll share my code.

I think I solved the issue. Try this new app https://pastebin.com/fPdQ0CCs

nice, i’m gonna try it this week!

maybe hang on a bit, looks like I messed up KNX->HUE direction when I cleaned up the code (was already working). Will test tonight and publish a new version

Hello Da-anda, did you manage to find the bug and update your app for color function ? Thanks a lot !

I think so. This is what I’m running for some time now. But since I barely change the color via the switch (it’s more convenient from within HA on my phone while on the couch :slight_smile: ) I can’t say if the issues are entirely gone now. But feel free to test my latest version:

In order to get it working, you also need the according xknx configuration mentioned in this post

Thank you very much for your super fast answer

I have a working xknx configuration (i can turn a knx light on/off from HA, and HA sees the status when I turn the same light on/off from a knx switch).

I did add to the configuration :

fire_event: true
fire_event_filter: ["11/*/*"] # in my case

I added your Hue2Knx.py application to AppDaemon/apps folder and edited the apps.yaml with :

hue2knx_light1:
  module: hue2knx
  class: Hue2Knx
  entity: 'light.lampe_iris'
  toggleAddress: '11/0/1'
  dimmAddress: '11/1/1'
  brightnessAddress: '11/2/1'
  hueAddress: '11/3/1'
  saturationAddress: '11/3/101'
  stateAddress: '11/4/1'
  hueStateAddress: '11/6/1'
  saturationStateAddress: '11/6/101'

The AppDaemon UI shows that “hue2knx_light1” is “loaded”, but sending a telegram to 11/0/1 with “ON” does nothing.

Do you have any idea what I am doing wrong ? Is there a way in HA to check that the telegram is received correctly ? (I am still quite new here :p)

Best regards, Laurent

I suppose you have restarted HomeAssistant after you changed the xknx config? If so, you should be able to monitor the knx event in the dev tools of your HA installation.

DeveloperTools -> Events -> Listen to event "knx_event"

once you listen and fire something on the KNX bus, you should see the event showing up there.

But I just noticed that the color change seems to be broken as of recently. Could be related to either the Hue bridge update, slightly moved location of the bridge or some change in xknx. Anyway, there is now a huuuuge delay between KNX action and the HUE bulb performing it. Dimming a light sucks as it is now for me (wasn’t perfect before, but it’s terrible now). But since I don’t use it much anymore, I won’t spend time on it atm. I will try to help and answer any questions though and maybe it’s working better for you.

Thanks you da-anda, the telegram is properly received by HA, but for some reason nothing happen. That may be linked to the recent break that you are talking bout.
Anyway thank you very much for your help, I guess that we will need to find a different method in the future.
Cheers