KNX - error on HA startup: __init__.py

Dear community,

I am facing trouble with the startup of the KNX integration during the boot of HA.
In the log I see below error (showing up multiple times):

Log details of the error:

My configuration. yaml section:

knx:
  tunneling:
    host: '192.168.50.2'       # IP Gateway
    port: 3671
    local_ip: '192.168.50.5'   # HASS
  light: !include configuration/lights_KNX.yaml
  cover: !include configuration/covers_KNX.yaml

Just for reference (as may be related): after startup of HA, all lights work correctly and I can action the covers. However the covers’ state is NOT correctly reflected.

Can anyone please provide some guidance how to get rid of the error ?

Which version of HA are you running?
Please share your full knx config (automations with knx.send ?)

I am running HA 0.118 core in Docker on QNAP NAS TS-251A.

No automations with knx.send.

How can I share my full config with you ? How to attach both .yaml files ?

Copy&paste?
From the error I read there is something wrong with a knx expose sensor, but there is none in your config!?

In general I’d advise to use HA 1.0.0 as there are some knx bugs from 0.118 fixed.

Matthias,

I apologize: I removed the “expose:” line, as I thought not relevant (I was fiddling around to see if it could solve my issue with the covers not having a correct state, after reboot).

Please find below my full config, related to KNX: configuration.yaml, lights_KNX.yaml, covers_KNX.yaml, expose_KNX.yaml.

Configuration.yaml

knx:
  tunneling:
    host: '192.168.50.2'       # IP Gateway
    port: 3671
    local_ip: '192.168.50.5'   # HASS
  expose: !include configuration/expose_KNX.yaml 
  light: !include configuration/lights_KNX.yaml
  cover: !include configuration/covers_KNX.yaml

Lights_KNX.yaml

# =====================================
# ===   Gelijkvloers   -   BUREAU   ===
# =====================================
    - name: Gelijkvloers - Bureau - Plafond Licht
      address: '0/0/8'
      state_address: '1/0/8'

# =================================
# ===   Gelijkvloers   -   WC   ===
# =================================
    - name: Gelijkvloers - WC - Plafond Spot
      address: '0/0/25'
      state_address: '1/0/25'

# ======================================
# ===   Gelijkvloers   -   TV-HOEK   ===
# ======================================
    - name: Gelijkvloers - TVHoek - Plafond Spots 4x
      address: '0/0/23'
      state_address: '1/0/23'

# =====================================
# ===   Gelijkvloers   -   LIVING   ===
# =====================================
    - name: Gelijkvloers - Living - Hanglamp Eettafel
      address: '0/0/14'
      state_address: '1/0/14'

    - name: Gelijkvloers - Living - Staaf Spot Piano
      address: '0/0/15'
      state_address: '1/0/15'

    - name: Gelijkvloers - Living - Staaf Spots Vitrinekast 2x
      address: '0/0/16'
      state_address: '1/0/16'

    - name: Gelijkvloers - Living - Plafond Spots 4x
      address: '0/0/18'
      state_address: '1/0/18'

    - name: Gelijkvloers - Living - Plafond Spot Center
      address: '0/0/19'
      state_address: '1/0/19'

    - name: Gelijkvloers - Living - Staaf Spots Schilderij 2x
      address: '0/0/20'
      state_address: '1/0/20'

    - name: Gelijkvloers - Living - Wandlichten 2x
      address: '0/0/21'                     # KNX group address for switching the light on and off. DPT 1.001
      state_address: '1/0/21'               # KNX group address for retrieving the switch state of the light. DPT 1.001
      brightness_address: '0/0/45'          # KNX group address for setting the brightness of the light in percent (absolute dimming). DPT 5.001
      brightness_state_address: '1/0/22'    # KNX group address for retrieving the brightness of the light in percent. DPT 5.001

# =====================================
# ===   Gelijkvloers   -   KEUKEN   ===
# =====================================
    - name: Gelijkvloers - Keuken - Plafond Spots Wasbak Ijskast 6x
      address: '0/0/10'
      state_address: '1/0/10'

    - name: Gelijkvloers - Keuken - Plafond Spots Eettafel 4x
      address: '0/0/11'
      state_address: '1/0/11'

# ======================================
# ===   Gelijkvloers   -   BERGING   ===
# ======================================
    - name: Gelijkvloers - Berging - Plafond Licht
      address: '0/0/9'
      state_address: '1/0/9'

# =====================================
# ===   Gelijkvloers   -   INKOM   ===
# =====================================
    - name: Gelijkvloers - Inkom - Plafond Spots 4x
      address: '0/0/24'
      state_address: '1/0/24'

    - name: Gelijkvloers - Inkom - Voordeur Spots 2x
      address: '0/0/26'
      state_address: '1/0/26'

    - name: Gelijkvloers - Inkom - Staaf Spot
      address: '0/0/17'
      state_address: '1/0/17'

# =================================
# ===   Verdieping   -   TRAP   ===
# =================================
    - name: Verdieping - Trap Muur Spots 6x
      address: '0/0/27'
      state_address: '1/0/27'

    - name: Verdieping - Trap Wandlichten 2x
      address: '0/0/40'
      state_address: '1/0/40'

# ====================================
# ===   Verdieping   -   TRAPHAL   ===
# ====================================
    - name: Verdieping - Traphal Plafond Spots 5x
      address: '0/0/37'
      state_address: '1/0/37'

# ========================================
# ===   Verdieping   -   LOGEERKAMER   ===
# ========================================
    - name: Verdieping - Logeerkamer Plafond Licht
      address: '0/0/36'
      state_address: '1/0/36'

# =====================================
# ===   Verdieping   -   BADKAMER   ===
# =====================================
    - name: Verdieping - Badkamer Plafond Spots 4x
      address: '0/0/44'
      state_address: '1/0/44'

    - name: Verdieping - Badkamer Douche Spot
      address: '0/0/29'
      state_address: '1/0/29'

    - name: Verdieping - Badkamer Spiegel LEDs 2x
      address: '0/0/28'
      state_address: '1/0/28'

# =====================================
# ===   Verdieping   -   DRESSING   ===
# =====================================
    - name: Verdieping - Dressing Plafond Spots 6x
      address: '0/0/30'
      state_address: '1/0/30'

# ==============================================
# ===   Verdieping   -   SLAAPKAMER OUDERS   ===
# ==============================================
    - name: Verdieping - Slaapkamer Ouders Plafond Spot Veerle
      address: '0/0/31'
      state_address: '1/0/31'

    - name: Verdieping - Slaapkamer Ouders Plafond Spot Koen
      address: '0/0/32'
      state_address: '1/0/32'

    - name: Verdieping - Slaapkamer Ouders Wandlichten 2x
      address: '0/0/33'
      state_address: '1/0/33'

# ============================================
# ===   Verdieping   -   SLAAPKAMER TINE   ===
# ============================================
    - name: Verdieping - Slaapkamer Tine Plafond Licht
      address: '0/0/34'
      state_address: '1/0/34'

# =============================================
# ===   Verdieping   -   SLAAPKAMER LAURE   ===
# =============================================
    - name: Verdieping - Slaapkamer Laure Plafond Licht
      address: '0/0/35'
      state_address: '1/0/35'

# ===============================
# ===   Verdieping   -   WC   ===
# ===============================
    - name: Verdieping - WC Plafond Licht
      address: '0/0/38'
      state_address: '1/0/38'

# ======================================
# ===   Kelder   -   Trap & Garage   ===
# ======================================
    - name: Kelder - Trap en Garage Plafond Licht 3x
      address: '0/0/1'
      state_address: '1/0/1'

# ==================================
# ===   Kelder   -   Wasplaats   ===
# ==================================
    - name: Kelder - Wasplaats Plafond Licht
      address: '0/0/6'
      state_address: '1/0/6'

# ====================================
# ===   Kelder   -   Tuinberging   ===
# ====================================
    - name: Kelder - Tuinberging Plafond Licht 2x
      address: '0/0/3'
      state_address: '1/0/3'

# ===================================
# ===   Kelder   -   Wijnkelder   ===
# ===================================
    - name: Kelder - Wijnkelder Plafond Licht
      address: '0/0/4'
      state_address: '1/0/4'

# ================================
# ===   Kelder   -   Berging   ===
# ================================
    - name: Kelder - Berging Plafond Licht 2x
      address: '0/0/5'
      state_address: '1/0/5'

# ===============================
# ===   Zolder   -   ZOLDER   ===
# ===============================
    - name: Zolder - Plafond Licht
      address: '0/0/42'
      state_address: '1/0/42'

# =================================
# ===   Buiten   -   TUINSPOT   ===
# =================================
    - name: Buiten - Tuin Spot
      address: '0/0/39'
      state_address: '1/0/39'

# ==================================
# ===   Buiten   -   BUITENNIS   ===
# ==================================
    - name: Buiten - Buitennis Vooraan
      address: '0/0/41'
      state_address: '1/0/41'

# ===============================
# ===   Buiten   -   TERRAS   ===
# ===============================
    - name: Buiten - Terras Muurarmaturen 2x
      address: '0/0/13'
      state_address: '1/0/13'

# ==============================
# ===   Buiten   -   OPRIT   ===
# ==============================
    - name: Buiten - Oprit Trap Muurarmatuur
      address: '0/0/7'
      state_address: '1/0/7'

Covers_KNX.yaml

# Configuration Variables
# =======================
# name:                   (string)(Optional)   A name for this device used within Home Assistant. Default value: KNX Cover
# move_long_address:      (string)(Optional)   KNX group address for moving the cover full up or down. DPT 1
# move_short_address:     (string)(Optional)   KNX group address for moving the cover short time up or down. DPT 1
# stop_address string     (string)(Optional)   KNX group address for stopping the current movement from the cover. DPT 1
# position_address:       (string)(Optional)   KNX group address for moving the cover to the dedicated position. DPT 5.001
# position_state_address: (string)(Optional)   Separate KNX group address for requesting the current position of the cover. DPT 5.001
# angle_address:          (string)(Optional)   KNX group address for moving the cover to the dedicated angle. DPT 5.001
# angle_state_address:    (string)(Optional)   Separate KNX group address for requesting the current angle of cover. DPT 5.001
# travelling_time_down:   (integer)(Optional)  Time cover needs to travel down in seconds. Needed to calculate the intermediate positions of cover while traveling. Default value: 25
# travelling_time_up:     (integer)(Optional)  Time cover needs to travel up in seconds. Needed to calculate the intermediate positions of cover while traveling. Default value: 25
# invert_position:        (boolean)(Optional)  Set this to true if your actuator report fully closed as 0% in KNX. Default value: false
# invert_angle:           (boolean)(Optional)  Set this to true if your actuator reports tilt fully closed as 0% in KNX. Default value: false

# =====================================
# ===   Gelijkvloers   -   BUREAU   ===
# =====================================
# Zet rolluik volledig UP (i.e. = 0%) ==> restart HASS
    - name: Gelijkvloers - Bureau - Rolluik bij WC
      move_long_address: '2/0/0'
      move_short_address: '2/0/21'
      # position_address: ''
      position_state_address: '3/0/0'
      travelling_time_up: 25
      travelling_time_down: 24
      invert_position: false

    - name: Gelijkvloers - Bureau - Rolluik in Hoek
      move_long_address: '2/0/1'
      move_short_address: '2/0/22'
      # position_address: ''
      position_state_address: '3/0/1'
      travelling_time_up: 25
      travelling_time_down: 24
      invert_position: true

# =====================================
# ===   Gelijkvloers   -   KEUKEN   ===
# =====================================
    - name: Gelijkvloers - Keuken - Baantje
      move_long_address: '2/0/2'
      move_short_address: '2/0/23'
      # position_address: ''
      position_state_address: '3/0/2'
      travelling_time_up: 25
      travelling_time_down: 24
      invert_position: true

    - name: Gelijkvloers - Keuken - Tuin
      move_long_address: '2/0/3'
      move_short_address: '2/0/24'
      # position_address: ''
      position_state_address: '3/0/3'
      travelling_time_up: 25
      travelling_time_down: 24
      invert_position: true

    - name: Gelijkvloers - Keuken - Terras
      move_long_address: '2/0/4'
      move_short_address: '2/0/25'
      # position_address: ''
      position_state_address: '3/0/4'
      travelling_time_up: 25
      travelling_time_down: 24
      invert_position: true

# =====================================
# ===   Gelijkvloers   -   LIVING   ===
# =====================================
    - name: Gelijkvloers - Living - Links
      move_long_address: '2/0/5'
      move_short_address: '2/0/26'
      # position_address: ''
      position_state_address: '3/0/5'
      travelling_time_up: 25
      travelling_time_down: 24
      invert_position: true

    - name: Gelijkvloers - Living - Midden
      move_long_address: '2/0/6'
      move_short_address: '2/0/27'
      # position_address: ''
      position_state_address: '3/0/6'
      travelling_time_up: 25
      travelling_time_down: 24
      invert_position: true

    - name: Gelijkvloers - Living - Rechts
      move_long_address: '2/0/7'
      move_short_address: '2/0/28'
      # position_address: ''
      position_state_address: '3/0/7'
      travelling_time_up: 25
      travelling_time_down: 24
      invert_position: true

    - name: Gelijkvloers - Living - Padje
      move_long_address: '2/0/8'
      move_short_address: '2/0/29'
      # position_address: ''
      position_state_address: '3/0/8'
      travelling_time_up: 25
      travelling_time_down: 24
      invert_position: true

# ======================================
# ===   Gelijkvloers   -   TV HOEK   ===
# ======================================
    - name: Gelijkvloers - TV Hoek - Padje
      move_long_address: '2/0/9'
      move_short_address: '2/0/30'
      # position_address: ''
      position_state_address: '3/0/9'
      travelling_time_up: 25
      travelling_time_down: 24
      invert_position: true

    - name: Gelijkvloers - TV Hoek - Links
      move_long_address: '2/0/10'
      move_short_address: '2/0/31'
      # position_address: ''
      position_state_address: '3/0/10'
      travelling_time_up: 25
      travelling_time_down: 24
      invert_position: true

    - name: Gelijkvloers - TV Hoek - Rechts
      move_long_address: '2/0/11'
      move_short_address: '2/0/32'
      # position_address: ''
      position_state_address: '3/0/11'
      travelling_time_up: 25
      travelling_time_down: 24
      invert_position: true

# =====================================
# ===   Verdieping   -   BADKAMER   ===
# =====================================
    - name: Verdieping - Badkamer - Links
      move_long_address: '2/0/12'
      move_short_address: '2/0/33'
      # position_address: ''
      position_state_address: '3/0/12'
      travelling_time_up: 25
      travelling_time_down: 24
      invert_position: true

    - name: Verdieping - Badkamer - Rechts
      move_long_address: '2/0/13'
      move_short_address: '2/0/34'
      # position_address: ''
      position_state_address: '3/0/13'
      travelling_time_up: 25
      travelling_time_down: 24
      invert_position: true

# ======================================================
# ===   Verdieping   -   SLAAPKAMERS + LOGEERKAMER   ===
# ======================================================
    - name: Verdieping - Slaapkamer - Ouders
      move_long_address: '2/0/14'
      move_short_address: '2/0/35'
      # position_address: ''
      position_state_address: '3/0/14'
      travelling_time_up: 25
      travelling_time_down: 24
      invert_position: true

    - name: Verdieping - Slaapkamer - Tine
      move_long_address: '2/0/15'
      move_short_address: '2/0/36'
      # position_address: ''
      position_state_address: '3/0/15'
      travelling_time_up: 25
      travelling_time_down: 24
      invert_position: true

    - name: Verdieping - Slaapkamer - Laure Tuin
      move_long_address: '2/0/16'
      move_short_address: '2/0/37'
      # position_address: ''
      position_state_address: '3/0/16'
      travelling_time_up: 25
      travelling_time_down: 24
      invert_position: true

    - name: Verdieping - Slaapkamer - Laure Padje
      move_long_address: '2/0/17'
      move_short_address: '2/0/38'
      # position_address: ''
      position_state_address: '3/0/17'
      travelling_time_up: 25
      travelling_time_down: 24
      invert_position: true

    - name: Verdieping - Logeerkamer - Padje
      move_long_address: '2/0/18'
      move_short_address: '2/0/39'
      # position_address: ''
      position_state_address: '3/0/18'
      travelling_time_up: 25
      travelling_time_down: 24
      invert_position: true

    - name: Verdieping - Logeerkamer - Vooraan
      move_long_address: '2/0/19'
      move_short_address: '2/0/40'
      # position_address: ''
      position_state_address: '3/0/19'
      travelling_time_up: 25
      travelling_time_down: 24
      invert_position: true

expose_KNX.yaml

# Configuration Variables
# =======================
# - type:         (string, required)
#                 Type of the exposed value. Either ‘binary’, ‘time’, ‘date’, ‘datetime’ or any 
#                 supported type of KNX Sensor (e.g., “temperature” or “humidity”).
# - entity_id:    (string, optional)
#                 Entity id to be exposed. Not needed for types time, date and datetime.
# - attribute:    (string, optional)
#                 Attribute of the entity that shall be sent to the KNX bus. 
#                 If not set (or None) the state will be sent. Eg. for a light the state is 
#                 either “on” or “off” - with attribute you can expose its “brightness”.
# - default:      (boolean | string | integer | float, optional, default: None)
#                 Default value to send to the bus if the state or attribute value is None. 
#                 Eg. a light with state “off” has no brightness attribute so a default value of 0 could be used. 
#                 If not set (or None) no value would be sent to the bus and a GroupReadRequest to 
#                 the address would return the last known value.
# - address:      (string, required)
#                 KNX group address.


# =====================================
# ===   Gelijkvloers   -   BUREAU   ===
# =====================================
    - type: 'percentU8'
      entity_id: cover.gelijkvloers_bureau_rolluik_bij_wc
      address: '3/0/0'

    - type: 'percentU8'
      entity_id: cover.gelijkvloers_bureau_rolluik_in_hoek
      address: '3/0/1'

Try to use attribute: current_position on your cover exposes.
When you expose just the state it tries to convert “closed” to a % value - which is not possible.

Why are you forwarding a state that is received from knx to knx?

Thx for the suggestion, Matthias.

I will firstly remove the “Expose” and see if the error with init.py persists.
If not, I know I need to correct the expose- section.

PS: I merely tried the “Expose” route, to solve an issue I have with my covers, not showing the correct state after a reboot (even though there is a ‘position_state_address’). I am not clear on what this ‘Expose’ section is supposed to do, based on what I could read in the documentation.

This bug is fixed in 1.0.0

Expose is used to forward states or attributes of HA entities to knx.
That said you can always suggest improvements to the documentation via GitHub. This would be much appreciated.

Many thanks for your kind help.
I will install v2020.12.x soon to see if this solves my issues.

As to the documentation: I believe it would be clarifying if the sentence you have written “Expose is used to forward states or attributes of HA entities to knx.” is added at the beginning of the “Expose” section. It provides the right context, in my opinion.

I think this is more or less what is written in the documentation, but I’m no native english speaker.

KNX integration is able to expose entity states or attributes to KNX bus. The integration will broadcast any change of the exposed value to the KNX bus and answer read requests to the specified group address. It is also possible to expose the current time.

If you can rephrase it so it is easier understandable for a broader audience, don’t hesitate to go to KNX - Home Assistant and follow the link on top reading Edit this page on GitHub.
Your help will be appreciated.