Unable to expose sensor value to knx bus

Hi. I’m new to home assistant - and like it already very much. I have a working knx installation and some philips hue and xiaomi sensors - and nearly everything works great more or less right out of the box. Thank you very much for making this possible.

The only thing I couldn’t get to work is to expose xiaomi sensor values to the knx bus. According to the “manual” one has to use “expose:” in configuration.yaml (knx: expose:). But using that I get an error in the log file saying that “expose:” isn’t a know term for the knx component. Any suggestions?

Thank you very much!

Update: This (see docs) doesn’t to work (whether I use expose:: or expose:) for me:

# Example configuration.yaml entry
knx:
    expose::
        - type: 'temperature'
          entity_id: 'sensor.owm_temperature'
          address: '0/0/2'

do you have the upper section that appears to be required? Like all the stuff for climate/hub?

No. As I understand it „expose:“ should be able to expose any sensor value to the knx bus, regardless of its origin. As long as Home Assistant is able to get the sensor value (e.g. temperature, humidity, motion, …) of a device it should be able to pass it along to the knx bus. But maybe I missunderstood something …

It seems like that, so to me the odd things about that documentation is that none of it really follows typical yaml that we deal with in these configs… try this out:

knx:
  expose:
    - type: temperature
      entity_id: sensor.owm_temperature
      address: '0/0/2'

Thank you very much for your help - unfortunately it doesn’t work. Using your code, I get the following error:

starting version 3.2.4
Testing configuration at /config
ERROR:homeassistant.config:Invalid config for [knx]: [expose] is an invalid option for [knx]. Check: knx->knx->expose. (See /config/configuration.yaml, line 16). Please check the docs at https://home-assistant.io/components/knx/
ERROR:homeassistant.setup:Setup failed for knx: Invalid config.
Failed config
  knx: 
    expose: [source /config/configuration.yaml:17]
      - address: 8/0/0
        entity_id: sensor.temperature_158d0001c14eb8
        type: temperature
  General Errors: 
    - Setup failed for knx: Invalid config.
Successful config (partial)

knx:

Could it be that the expose-option is only available in the newest xknx-versions, but hass uses an older version (see xknx.io)?

I’m not sure. That whole expose thing looks odd. If you are just trying to get the temperature, try using the sensor version of knx:

sensor:
  - platform: knx
    address: '8/0/0'
    type: 'temperature'

It looks like that should do what you want anyways

No, because this shows a knx sensor in hass (which, by the way, works). But I want it the other way around: a Xiaomi Temperature sensor (discovered by hass) should send its temperature to the knx bus.

Ah, ok. I get it. Sorry, I’ve been leading you in the wrong direction.

So looking at

it appears as if the expose config option is there in current release. Are you at the current release?

BTW, this code is the proper code when following the syntax in the knx component:

knx:
  expose:
    - type: temperature
      entity_id: sensor.temperature_158d0001c14eb8
      address: '8/0/0'

Thanx again for your help. Yes, I am at the current hass release 0.64.1 or 0.64.02 (I’m not at home right now). Maybe I should check whether I’ve got the newest knx.py version. Where is this file stored? Couldn’t find it with the configurator. Or is it in a hidden drawer, only accessible by ssh?

Yes, I guess I used the proper syntax. I even copied your code and pasted it to configuration.yaml - but I still get the same error.

If you are on hass.io, i’m not sure where it is. I have hass.io and I haven’t been able to locate files. You could always copy the source code and use it as a custom component. I’m pretty sure it would overwrite whats installed.

What strikes me as odd is the fact that you are getting an error about expose when the source code explicitly calls it out. It should be working for you.

Can you post your entire config that you are using for the knx?

This is my configuration file. I’ve tried with and without a separte xknx.yaml file and get the same error message:

homeassistant:
    name: Home
    latitude: xxxxx
    longitude: xxxxxx
    elevation: 476
    unit_system: metric
    time_zone: Europe/London
    customize: !include customize.yaml
panel_iframe:
  configurator:
    title: Configurator
    icon: mdi:wrench
    url: http://xxxxx:3218
http:
    api_password: xxxxxx
logger:
knx:
  expose:
    - type: temperature
      entity_id: sensor.temperature_158d0001c14eb8
      address: '8/0/0'
  config_file: 'xknx.yaml'      
sensor:
  - platform: knx
    name: Büro.Temperatur
    address: '3/0/1'
    type: 'temperature'
[...]
switch:
    - platform: knx
      name: Kaffeemaschine
      address: '1/0/17'
      state_address: '1/1/17'
[...]
discovery:
xiaomi_aqara:
  discovery_retry: 5
  gateways:
    - key: xxxx

And here xknx.yaml. I also tried to expose the sensor in the xknx.yaml file according to https://github.com/XKNX/xknx/blob/master/xknx.yaml

groups:
  sensor:
    Wohnen.Temperature: {group_address: '3/0/2', value_type: 'temperature'}
  light:
    Essen.Tischlampe: {group_address_switch: '0/1/6', group_address_switch_state: '0/4/6', group_address_brightness: '0/3/6', group_address_brightness_state: '0/5/6'}
  expose_sensor:
    sensor.temperature_158d00020278da: {group_address: '8/0/0', value_type: 'temperature'}

well I’m stumped. To me, it should be working.

But thanks any way for your effort!

1 Like

@petro Just got in touch with (one of ?) the programmer behind xknx. Expose will implemented in the next hass update :slightly_smiling_face:

Nice, explains why it doesn’t work. We must not be running the latest knx release.