Coder Social home page Coder Social logo

xknx's Introduction

XKNX - An asynchronous KNX library written in Python

PyPI - Python Version codecov Checked with mypy Pre-commit HA integration usage Discord

Documentation

See documentation at: https://xknx.io/

Help

We need your help for testing and improving XKNX. For questions, feature requests, bug reports either open an issue, join the XKNX chat on Discord or write an email.

Development

You will need at least Python 3.9 in order to use XKNX.

Setting up your local environment:

  1. Install requirements: pip install -r requirements/testing.txt
  2. Install pre-commit hook: pre-commit install

Testing

To run all tests, linters, formatters and type checker call tox

Running only unit tests is possible with pytest Running specific unit tests can be invoked by: pytest -vv test/management_tests/procedures_test.py -k test_nm_individual_address_serial_number_write_fail

Home-Assistant

XKNX is the underlying library for the KNX integration in Home Assistant.

Example

"""Example for switching a light on and off."""
import asyncio

from xknx import XKNX
from xknx.devices import Light


async def main():
    """Connect to KNX/IP bus, switch on light, wait 2 seconds and switch it off again."""
    async with XKNX() as xknx:
        light = Light(xknx,
                      name='TestLight',
                      group_address_switch='1/0/9')
        await light.set_on()
        await asyncio.sleep(2)
        await light.set_off()

asyncio.run(main())

Attributions

Many thanks to Weinzierl Engineering GmbH and MDT technologies GmbH for providing us each an IP Secure Router to support testing and development of xknx.

xknx's People

Contributors

arnonym avatar bachp avatar basilfx avatar buergi avatar crazyfx1 avatar croghostrider avatar dependabot-preview[bot] avatar dependabot[bot] avatar drmurx avatar elupus avatar encbladexp avatar extenzy avatar farmio avatar github-actions[bot] avatar itineric avatar jochembroekhoff avatar julius2342 avatar knxbroker avatar magenbrot avatar marvin-w avatar mielune avatar oldcorvus avatar oliverblaha avatar opieters avatar pdgendt avatar recmartin avatar rnixx avatar spacegaier avatar straeng avatar twistermcneal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xknx's Issues

Support for generic KNX Datapoints

Hello,

it seems this KNX library doesn't support setting arbitrary datapoints for each sensor but instead uses a fixed mapping between the sensor type and the datapoint. As the KNX standard defines all possible data types, it would be nice to support using just the plain datapoint as type:

  - platform: knx
    name: Kitchen.Temperature
    address: '6/2/1'
    type: '9.001'

Currently I have sensors with the following types that aren't supported:
7.013 DPT_Brightness
9.006 DPT_Value_Pres
9.008 DPT_Value_AirQuality
9.028 DPT_Value_Wsp_kmh
14.033 DPT_Value_Frequency
14.056 DPT_Value_Power

Also the current defined types aren't unique, e.g. both 9.005 DPT_Value_Wsp and 14.065 DPT_Value_Speed use m/s as unit.

group Address

the group address is in the wrong format!

the last bit is not used in the address

main = 4bit
middle = 3bit
sub = 8bit
Address bit format: 0mmm msss gggg gggg

             +-----------------------------------------------+
   16 bits   |                 GROUP ADDRESS                 |
             +-----------------------+-----------------------+
             | OCTET 0 (high byte)   |  OCTET 1 (low byte)   |
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
      bits   | 7| 6| 5| 4| 3| 2| 1| 0| 7| 6| 5| 4| 3| 2| 1| 0|
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |  |  Main Group (S13)  |   Sub Group (S13)     |
             +--+--------------------+-----------------------+

#16

Cover up/down and current position mixed up/wrong

My Cover config:

  - platform: xknx
    name: mf_toilet
    move_long_address: 2/0/60
    move_short_address: 2/1/60
    position_address: 2/2/60
    position_state_address: 2/3/60
    invert_position: true

The Up and Down buttons function correctly. Pressing Down (close_cover called), the covers move down. Pressing Up, the covers move up. Wenn cover is completely down however, the up arrow greys out and can't be pressed anymore. Same applies for when completely Up. Then the Down button greys out and cant be pressed anymore.

The Position slider is correct (0: up; 100: down). The mdi:icon continuously depicts open.

If I change the invert_position to false, then the buttons work as expected (cover completely down, only up arrow is active and vise versa) but the position slider says 0 wenn cover is completely down and 100 wenn cover is up which should be the other way around. The mdi:icon remains unchanged at open all the time.

Better climate support for HASS

3/4 of all feedback i got wished better climate support. Looks like we need better climate support.

I suggest the following configuration:

climate:
   - platform: xknx
     name: Kitchen.Temperature
     temperature_address: '6/2/1'
     setpoint_address: '6/2/2'

     frost_protection_address: '6/2/3'
     comfort_address: '6/2/4'
     night: '6/2/5'
     standby: '6/2/6'
     operating_mode: ''6/2/7'

Within HASS [frost,comfort,night,address] will show up as dropdown for "operation_modes".

Timeout problems on KNX environments with high latency and/or packet loss

Background

@elupus experienced the following exception during sync:

Jul 31 04:55:05 hass hass[51396]: Sync Uttag Kök
Jul 31 04:55:05 hass hass[51396]: Exception while processing telegram: Could not send telegram to tunnel
Jul 31 04:55:05 hass hass[51396]: Traceback (most recent call last):
Jul 31 04:55:05 hass hass[51396]:   File "/home/homeassistant/evn_dev/lib/python3.5/site-packages/xknx/core/telegram_queue.py", line 79, in process_telegram
Jul 31 04:55:05 hass hass[51396]:     yield from self.process_telegram_outgoing(telegram)
Jul 31 04:55:05 hass hass[51396]:   File "/home/homeassistant/evn_dev/lib/python3.5/site-packages/xknx/core/telegram_queue.py", line 91, in process_telegram_outgoing
Jul 31 04:55:05 hass hass[51396]:     yield from self.xknx.knxip_interface.send_telegram(telegram)
Jul 31 04:55:05 hass hass[51396]:   File "/home/homeassistant/evn_dev/lib/python3.5/site-packages/xknx/io/knxip_interface.py", line 139, in send_telegram
Jul 31 04:55:05 hass hass[51396]:     yield from self.interface.send_telegram(telegram)
Jul 31 04:55:05 hass hass[51396]:   File "/home/homeassistant/evn_dev/lib/python3.5/site-packages/xknx/io/tunnel.py", line 111, in send_telegram
Jul 31 04:55:05 hass hass[51396]:     raise Exception("Could not send telegram to tunnel")
Jul 31 04:55:05 hass hass[51396]: Exception: Could not send telegram to tunnel

This error occurs when the xknx.io.Tunnelling sends xknx.knxip.TunnellingRequest but did not receive an xknx.knxip.TunnellingAck within 1 second.

Open Questions

  • When does this happen? At startup? When Stateupdater does its regular sync?
  • How often does this happen?
  • We should find out if the bus always tries to read the same packets
  • Do we get any KNX/IP feedback from the router?
  • Does the Tunnel repair itself after ~1 minute? The tunnel abstraction sends a StateRequest every 15 seconds and restarts the tunneling after the 3rd failed attempt.

Suggested approaches for mitigation

There are several ideas of mitigating this:

  • RequestResponse / ValueReader : Increase the timeout for RequestResponse and for ValueReader (and make this timeout configurable)
  • KNXIPInterface : Directly send telegrams to the bus without using TelegramQueue
  • StateUpdater : Only sync status when telegram qeuue is empty. And/Or do a short sleep between device.sync()s.

Question: Should all lights turn on on startup?

Hi guys, great that you are working on improving knx support in Home Assistant. With both the old (pre-xknx as I understand it) knx implementation and the new one all my lights turn on in the house when Home Assistant is starting up. Is this the expected/normal behavior? Because it is a little bit inconvenient ;-)

CouldNotParseTelegram description

Hi i am having following error message

any idea what this could come from ?

2017-11-06 15:29:25 ERROR (MainThread) [xknx.log] Exception while processing telegram: <CouldNotParseTelegram description="" />
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/xknx/core/telegram_queue.py", line 99, in process_telegram
    yield from self.process_telegram_incoming(telegram)
  File "/usr/local/lib/python3.6/site-packages/xknx/core/telegram_queue.py", line 130, in process_telegram_incoming
    yield from device.process(telegram)
  File "/usr/local/lib/python3.6/site-packages/xknx/devices/cover.py", line 229, in process
    position_processed = yield from self.position.process(telegram)
  File "/usr/local/lib/python3.6/site-packages/xknx/devices/remote_value.py", line 76, in process
    raise CouldNotParseTelegram()
xknx.exceptions.exception.CouldNotParseTelegram: <CouldNotParseTelegram description="" />

i also have following error messages but that iss a adress related issue just adding this as perf info in case the upper error could be linke to the wrong adresses

2017-11-06 15:24:57 WARNING (MainThread) [xknx.log] Could not read value of <Light name="Lum ext avant" switch="<Address str="1/1/0" />/<Address str="1/1/1" />/None/None" /> 1/1/1
2017-11-06 15:24:59 WARNING (MainThread) [xknx.log] Could not read value of <Light name="Garage" switch="<Address str="1/1/8" />/<Address str="1/1/9" />/None/None" /> 1/1/9
2017-11-06 15:25:00 WARNING (MainThread) [xknx.log] Could not read value of <Light name="WC Cave" switch="<Address str="1/1/10" />/<Address str="1/1/11" />/<DPTBinary value="1" />/Value.ON" /> 1/1/11
2017-11-06 15:25:01 WARNING (MainThread) [xknx.log] Could not read value of <Light name="Lamp ext ARR" switch="<Address str="1/1/14" />/<Address str="1/1/15" />/None/None" /> 1/1/15
2017-11-06 15:25:05 WARNING (MainThread) [xknx.log] Could not read value of <Switch name="Prise Devant" switch="<Address str="1/5/1" />/None/None/None" /> 1/5/1

Change switch class to binary_sensor

Since we need switch as actor class it would be useful to change the class to binary_sensor.
Probably we can bundle it to a global sensor class for different types of sensors.

License of components not clear

The current license of the component is not consistent.

The repo includes the LGPL-3.0 license while the PyPi package sais it is MIT and at the same time LGPLv3.

If non of the contributors (@Julius2342, @twistermcneal, @andreasnanko, @cyberjunky) have any objections it I suggest putting the package under MIT as the license allows more flexibility. If you agree I can create a PR doing this.

If putting the component under MIT is not desired please correct the entry in https://github.com/XKNX/xknx/blob/master/setup.py#L18

Sensor types Illuminance and speed_ms do not work correctly

My xknx sensor config in Home Assistant:

  - platform: xknx
    name: o_temperature
    type: 'temperature'
    address: '0/7/9'
  - platform: xknx
    name: o_wind
    type: 'speed_ms'
    address: '0/7/0'
  - platform: xknx
    name: o_brightness
    type: 'illuminance'
    address: '0/7/1'

Temperature reports 25.3 C and is correct.
Speed reports 0.0 m/s and is not correct. It stays also at 0.0 If I use the build-in 'KNX' (and not XKNX) then it returns correctly between 1.0 and 2.0 m/s.
Illuminance reports 0x3e,0x2a with no unit.

Send Time to KNX bus

We have to send the time to the KNX bus to display it properly within my GIRA Tastsensor 3 Plus 2-fach 514200

Open question:

  • Is time a device?
  • Do we send UTC or do they use local time
  • How should the configuration look like
    time:

        Time_1:
            group_address: "1/2/7"
            time_zone: "Europe/Berlin"  # If the bus needs local time
            frequency: 20 # send every 20 seconds

Alternatively we could put the timing to the hass_component (using this utc_changed ... function)

KNX Cover State not correct in HASS

When restarting HASS (0.54.0) my KNX covers (actors are made by ABB) show an incorrect state - actually they are open, but hass says closed.
I verified group addresses, I think they are correct. Object is marked as readable in ETS.

The abb documentation says:

 "Status Höhe/Lamelle 0…255" 1 Byte 
Der Ausgang sendet die relative Position des Behangs und die Lamellenstellung auf zwei getrennten Kommunikationsobjekten jeweils als 1-Byte-Wert (0…255). Für die Position des Behangs gilt: Der Wert 0 entspricht der Position oben (0 %). Der Wert 255 entspricht der Position unten (100 %).  

I tried to set the "invert_position" flag to "true" in hass, but:

  • On hass startup, cover is still shown as closed but is actually opened
  • Movement of covers is now inverted (Button "down" -> cover goes up)

I did not notice any knx errors regarding xknx covers in the hass logs.
When I move the knx cover manually (by a native knx switch/button) the state is updated correctly in hass, after the cover has stopped.

Edit:
My Hass config:

cover:
  - platform: knx
    name: 'eg_wohnzimmer_fenster'
    move_long_address: '1'
    move_short_address: '2'
    position_address: '3'
    position_state_address: '4'

Implement target temperature in termostat module

The target temperature is not yet submitted to the KNX bus.

I also have to find out if you get a KNX event if the target temperature is changed within the Thermostat itself.

Additionally we have to read the normal update Telegrams and update the local target temperature.

Shutters with our position-group address

There are shutters which don't support an absolute position group address.

I think we should do somehting like:

    class Direction(Enum):
        UP = 1
        DOWN = 2


    def set_position(self, position):
        if self.group_address_position is not None:
            self.send(self.group_address_position, [0x80, position])
        else
            self.set_position_relative(position)

    dev set_position_relative(self, position):
        relative_position = position - self.position
        direction = Direction.UP if relative_position > 0 else Direction.DOWN

        travel_time_full = travel_time_up if direction == Direction.UP else travel_time_up_down # should be taken from configuration ..

        travel_time = travel_time_full * abs(relative_position) / 100
        self.travel( direction, travel_time)
 
    dev travel(self, direction, travel_time ):

        if direction == Direction.UP:
           self.set_up()
        else:
           self.set_down()

       time.sleep(travel_time)

       self.set_short_down()

The problem with that approach is, that if changed in between, you cant readjust the cover. We therefore should lock the device.

Monitor arbitrary values on KNX

User Story

As a user I want to monitor the valve values of my heating in my home assistant

Solution

Monitoring class, which requests values of defined group_addresses regulary and displays it in home assistant

Configuration

    monitor:
        Heating.Valve1: {group_address: '2/0/0', value_type: 'percent'}
        Heating.Valve2: {group_address: '2/0/1', value_type: 'percent'}
        Some.Other.Value: {group_address: '2/0/2'}

Cover: dedicated stop address

Problem description

At the moment covers are stopped via the short up/down step address. This works for Gira and some over cover actors.

Some cover actors have a dedicated stop address, e.g. http://www.mdt.de/download/MDT_THB_Jalousieaktor_02.pdf (page 12)

The datatype is 1.001 – 1 Bit.

This would also make the home - assistant configuration less confusing.

Current workaround

The current workaround is to define a short up/down address:

- platform: knx
  name: "Livingroom.Cover2"
  move_long_address: '3/0/16'
  move_short_address: '3/0/17'

auto_update cover

2017-08-03 17:40:13 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/lib/python3.6/asyncio/tasks.py", line 179, in _step
result = coro.send(None)
File "/usr/lib/python3.6/site-packages/homeassistant/core.py", line 1025, in _event_to_service_call
yield from service_handler.func(service_call)
File "/usr/lib/python3.6/site-packages/homeassistant/components/cover/init.py", line 173, in async_handle_cover_service
yield from getattr(cover, method['method'])(**params)
File "/config/custom_components/cover/xknx.py", line 128, in async_close_cover
self.start_auto_updater()
File "/config/custom_components/cover/xknx.py", line 154, in start_auto_updater
self.hass, self.auto_updater_hook)
File "/usr/lib/python3.6/site-packages/homeassistant/helpers/event.py", line 26, in factory
hass.loop, ft.partial(async_factory, *args, **kwargs)).result()
File "/usr/lib/python3.6/site-packages/homeassistant/util/async.py", line 160, in run_callback_threadsafe
raise RuntimeError('Cannot be called from within the event loop')
RuntimeError: Cannot be called from within the event loop

I think we have this error since asyncio implementation

Results in no updates for the cover and no position change from the traveling calculater

Send Outside temperature to KNX bus

Add module for sending the outside temperature to the KNX bus.

If added as module, a timer would poll the temperature from HASS and send it the underlaying XKNX abstraction.

[I don't have a weather station :-) ]

loop.create_datagram_endpoint does not work with Windows

Problem description

Under Windows you get the following error when connecting to KNX/IP device:

2017-09-17 18:35:45 ERROR (MainThread) [homeassistant.setup] Error during setup of component knx
Traceback (most recent call last):
  File "D:\Python36\lib\site-packages\homeassistant\setup.py", line 191, in _async_setup_component
    result = yield from component.async_setup(hass, processed_config)
  File "D:\Python36\lib\site-packages\homeassistant\components\knx.py", line 78, in async_setup
    yield from hass.data[DATA_KNX].start()
  File "D:\Python36\lib\site-packages\homeassistant\components\knx.py", line 138, in start
    connection_config=connection_config)
  File "D:\HomeAssistant\deps\Python36\site-packages\xknx\xknx.py", line 66, in start
    yield from self.knxip_interface.start()
  File "D:\HomeAssistant\deps\Python36\site-packages\xknx\io\knxip_interface.py", line 76, in start
    self.connection_config.gateway_port)
  File "D:\HomeAssistant\deps\Python36\site-packages\xknx\io\knxip_interface.py", line 106, in start_tunnelling
    yield from self.interface.start()
  File "D:\HomeAssistant\deps\Python36\site-packages\xknx\io\tunnel.py", line 73, in start
    yield from self.connect_udp()
  File "D:\HomeAssistant\deps\Python36\site-packages\xknx\io\tunnel.py", line 79, in connect_udp
    yield from self.udp_client.connect()
  File "D:\HomeAssistant\deps\Python36\site-packages\xknx\io\udp_client.py", line 167, in connect
    remote_addr=self.remote_addr)
  File "D:\Python36\lib\asyncio\base_events.py", line 934, in create_datagram_endpoint
    raise exceptions[0]
  File "D:\Python36\lib\asyncio\base_events.py", line 921, in create_datagram_endpoint
    yield from self.sock_connect(sock, remote_address)
  File "D:\Python36\lib\asyncio\proactor_events.py", line 451, in sock_connect
    return self._proactor.connect(sock, address)
  File "D:\Python36\lib\asyncio\windows_events.py", line 511, in connect
    ov.ConnectEx(conn.fileno(), address)
OSError: [WinError 10022] Argomento fornito non valido [NOTE TO READER -- IN ENGLISH: Supplied argument is invalid]

Operating system: Windows
Python version: 3.6

The corresponding code fragment (udp_client.py) is:

(transport, _) = yield from self.xknx.loop.create_datagram_endpoint(
                lambda: udp_client_factory,
                local_addr=self.local_addr,
                remote_addr=self.remote_addr)

If you google for the error you find similar problems: chrysn/aiocoap#27

Help needed!

I have no experience with Windows and no idea how to fix this. Help needed!

Wrong calculation of position within shutter/travelcalculator

twistermcneal writes:

es gibt aber noch einen Bug. Wenn ich von der max/min Position eine neue Position setze dann wird manchmal eine falsche aktuelle Position errechnet!
Habs aber noch nicht gefunden.

Scheint aber immer dann zu passieren wenn man die Jalousie komplett auffährt ohne stopp zu betätigen oder eine Position anzufahren...

Adding a proper input/output queue

In order to make unit testing we need a proper input/output queue to be filled and read from unit tests.

This would also enable us to implement proper locking on the event system.

global Queue

within devices we do:

with Queue.lock:
     Queue.out( telegram )
     Queue.process_out()

within Multicast receiver we do:

with Queue.lock:
     Queue.in( telegram )
     Queue.process_in()
````

Alternatively we could have a separate thread for handling both process input queue and output queue.

Within unit tests we could e.g. do device.set_on() and then test the correct telegram in the queue.




KNX RGBW / DMX controller

Ist there any plans on adding this?

I have several LED strips and i would like to chnage their color via home-assitant

Thnak you

Covers and Wind Alarm

Hi Julius,

I just stumbled on a minor cosmetic issue with Covers during a Wind Alarm/Block.
If I issue a down command during a Wind Alarm block HAss will show, both by slider movement and after runtime (calculated reaching of 100% closed) the greying out of the down arrow, that the cover is moving when actually it is locked in the up position.
Would it be possible for the xknx component to look at the "Status of Movement" address (1bit DPT 1.010 start/stop) to determine if the cover is actually moving?

Polling Group Address

In a KNX system you dont have to poll group addresses .... each client sends is state if changed or periodically.
In a large system you will getting problems when you poll all groups

Errors on startup

Background

@elupus elupus discovered some errors on initial startup.

Plan to reproduce

Do

 rm -r ~/.homeassistant/deps/lib/python/site-packages/xknx*

and check wether the error re-occurs.

KNX scenes

I would like the possibility to trigger KNX scenes.

The switch/button/function would need to be able to send value from 0 to 63 (1-64) in 1 Byte form, to a specified address.

Like: Triggering a value “23” to 1/1/23 will trigger scene “23” which could be “all lights on on ground floor”

Datatypes:

KNX/EIB Function type: Scene | Information length: 1 Byte | DPT type: DPT 17 | Value: 0...63

Source: https://www.domotiga.nl/projects/selfbus-knx-eib/wiki/Datatypes

KNX Humidity sensor displays data as hexdecimal number.

Hi.

I have a KNX Temp/Humidity sensor installed in my bedroom. Wenn I add the sensor to HAss via the following config:

  • platform: xknx
    name: lf_masterbedroom_humidity
    type: percent
    address: 5/1/0
    I get a readout in HAss where the number is in hexdecimal (e.g. 0x0e,0x73) in stead of in a decimal format.
    If I change type: percent to type: temperature I get the correct value in decimal but then I have the C suffix behind the number.

The DPT in KNX is 9.007 (humidity %), 2-byte

Raw access to KNX bus from HASS module

Background

@firefrei suggested to add raw access to KNX bus from Home Assistant Plugin:

Is it possible to use xknx to access "raw knx messages" in automation like you can do in the current knx component?
Example: You can create an automation that listens on the event "knx_event" which includes all data received on the knx bus.
This makes it possible to use "special" knx devices that aren't implemented yet. In my case: I have some wall buttons - when I press them, i'd like to run an automation.

Aaaand what about the other way around: Is it possible to send "raw" messages to the knx bus using a HASS service?

Implementation

xknx:
    fire_event: True
  • fire_event (Optional) if set to True, platform will write all received KNX messages to event bus

Additionally you can now use the following service:

Domain: xknx
Service: send
Service Data: {"address": "1/0/15", "payload": 0}

  • address : KNX group addresss
  • payload : payload, either an integer or an array of integers

Error thrown when Reading DPT 9.004

I have setup a sensor in home assitant. and when ever the lux value updates a error is thrown, however the value is update.

ETS Group
| 3/2/0 | Driveway-SEN-LUX |   | No | No | lux (Lux) | 2 bytes |   |  

Error message:

2017-09-25 11:58:42 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.drivewaysenlux, old_state=<state sensor.drivewaysenlux=595.84; unit_of_measurement=lx, friendly_name=Driveway Measured Lux @ 2017-09-25T13:58:31.623374+02:00>, new_state=<state sensor.drivewaysenlux=544.0; unit_of_measurement=lx, friendly_name=Driveway Measured Lux @ 2017-09-25T13:58:42.614233+02:00>>
2017-09-25 11:58:42 ERROR (MainThread) [xknx.log] Exception while processing telegram: unsupported operand type(s) for &: 'tuple' and 'int'
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/xknx/core/telegram_queue.py", line 99, in process_telegram
    yield from self.process_telegram_incoming(telegram)
  File "/usr/local/lib/python3.6/site-packages/xknx/core/telegram_queue.py", line 130, in process_telegram_incoming
    yield from device.process(telegram)
  File "/usr/local/lib/python3.6/site-packages/xknx/devices/binary_sensor.py", line 133, in process
    binary_value = telegram.payload.value & bit_masq != 0
TypeError: unsupported operand type(s) for &: 'tuple' and 'int'

CouldNotParseTelegram should not block whole stateupdater

Current behaviour

A CouldNotParseTelegram exception while reading the states interrupts the stateupdater.

File "/config/deps/lib/python3.6/site-packages/xknx/devices/notification.py", line 85, in _process_message
raise CouldNotParseTelegram()
xknx.exceptions.exception.CouldNotParseTelegram: <CouldNotParseTelegram description="" />

Expected behaviour

  • Stateupdater continues after a wrong telegram
  • human readable explanation of which payload was wrong and how to fix this.

CouldNotParseKNXIP "wrong HPAI length" with HassIO

Hey,
I'm using Home Assistant 0.56.2 within HassIO on a Raspberry Pi 3
I have a Siemens 5WG1 148-1AB22 KNX/IP ethernet gateway (AKA N148/22)
I can successfully connect to my KNX bus with eibd-server and linknx on a separate Linux Voyage system.

Unfortunately I can't connect to my KNX bus with Home Assistant, as it raises this exception at startup :

2017-11-04 15:00:01 INFO (MainThread) [homeassistant.setup] Setting up knx
2017-11-04 15:00:01 DEBUG (MainThread) [xknx.log] Starting tunnel to 10.100.4.96:3671 from 10.100.4.99
2017-11-04 15:00:01 DEBUG (MainThread) [xknx.knx] Sending: <KNXIPFrame <KNXIPHeader HeaderLength="6" ProtocolVersion="16" KNXIPServiceType="KNXIPServiceType.CONNECT_REQUEST" Reserve="0" TotalLength="26" />
 body="<ConnectRequest control_endpoint="<HPAI 10.100.4.99:54510 />" data_endpoint="<HPAI 10.100.4.99:54510 />" request_type="ConnectRequestType.TUNNEL_CONNECTION" />" />
2017-11-04 15:00:01 ERROR (MainThread) [xknx.log] <CouldNotParseKNXIP description="wrong HPAI length" />
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/xknx/io/udp_client.py", line 85, in data_received_callback
    knxipframe.from_knx(raw)
  File "/usr/lib/python3.6/site-packages/xknx/knxip/knxip.py", line 77, in from_knx
    pos += self.body.from_knx(data[pos:])
  File "/usr/lib/python3.6/site-packages/xknx/knxip/connect_response.py", line 54, in from_knx
    pos += self.control_endpoint.from_knx(raw[pos:])
  File "/usr/lib/python3.6/site-packages/xknx/knxip/hpai.py", line 23, in from_knx
    raise CouldNotParseKNXIP("wrong HPAI length")
xknx.exceptions.exception.CouldNotParseKNXIP: <CouldNotParseKNXIP description="wrong HPAI length" />
2017-11-04 15:00:02 ERROR (MainThread) [homeassistant.components.knx] Can't connect to KNX interface: Could not establish connection
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/components/knx.py", line 80, in async_setup
    yield from hass.data[DATA_KNX].start()
  File "/usr/lib/python3.6/site-packages/homeassistant/components/knx.py", line 140, in start
    connection_config=connection_config)
  File "/usr/lib/python3.6/site-packages/xknx/xknx.py", line 66, in start
    yield from self.knxip_interface.start()
  File "/usr/lib/python3.6/site-packages/xknx/io/knxip_interface.py", line 76, in start
    self.connection_config.gateway_port)
  File "/usr/lib/python3.6/site-packages/xknx/io/knxip_interface.py", line 106, in start_tunnelling
    yield from self.interface.start()
  File "/usr/lib/python3.6/site-packages/xknx/io/tunnel.py", line 74, in start
    yield from self.connect()
  File "/usr/lib/python3.6/site-packages/xknx/io/tunnel.py", line 89, in connect
    raise XKNXException("Could not establish connection")
xknx.exceptions.exception.XKNXException: Could not establish connection
2017-11-04 15:00:02 INFO (MainThread) [homeassistant.setup] Setup of domain knx took 1.2 seconds.
2017-11-04 15:00:02 ERROR (MainThread) [homeassistant.setup] Setup failed for knx: Component failed to initialize.

Here is my config :

knx:
  tunneling:
    host: '10.100.4.96'
    port: 3671
    local_ip: '10.100.4.99'

10.100.4.96 is my Siemens KNX/IP ethernet gateway
10.100.4.99 is my HassIO
However, I understand that HassIO uses Docker and I have the following from the HassIO ssh shell :

core-ssh:/config# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 02:42:AC:1E:21:00  
          inet addr:172.30.33.0  Bcast:0.0.0.0  Mask:255.255.254.0

And :

core-ssh:/config# arp
hassio (172.30.32.2) at 02:42:ac:1e:20:02 [ether]  on eth0
homeassistant (172.30.32.1) at 02:42:04:f5:dc:22 [ether]  on eth0

Is it something with NAT that prevents me from connecting to the gateway ?
Thanks

Home Assistant

Is it possible to implement this in Home Assistant ?

I'am trying to use a Shutter/Cover component for the KNX Bus...
does this one work?

Thanks in advance

Venetian Blinds - Angle Address and State not working

Hi.

After the recent update for inverted control and slider for covers I noticed that the Controls in HAss for my Venetian Blinds (Raffstores) were missing (without changes to the .yamls).
After some trouble shooting I figured out that when the angle_address and angle_state_address were commented out (removed), the controls were back. But I can now only control the up and down movement of the blinds. I no longer have direct control of the angle (the second slider is also missing when you open the cover controls in HAss).

current cover configuration (working, but up/down only)

  • platform: xknx
    name: mf_dining_e
    move_long_address: 3/0/1
    move_short_address: 3/1/1
    position_address: 3/2/1
    position_state_address: 3/3/1
    travelling_time_down: 81
    travelling_time_up: 83
    invert_position: false
    invert_angle: false

old cover configuration (used to work up/down and with direct angle control)

  • platform: xknx
    name: mf_dining_e
    move_long_address: 3/0/1
    move_short_address: 3/1/1
    position_address: 3/2/1
    position_state_address: 3/3/1
    angle_address: 3/4/1
    angle_state_address: 3/5/1
    travelling_time_down: 81
    travelling_time_up: 83
    invert_position: false
    invert_angle: false

Karssi

Improve requirements.

Currently we use this requirements:

pyyaml>=3.11,<4
pylint
netifaces
tox
coveralls
pytest
pytest-cov
pytest-timeout

We should improve this a little bit:

  • Split requirements.txt in requirements/base.txt and requirements/development.txt
  • Always pin requirements to releases, currently it is easly possible to break things if requirements get updates upstream, also updates on client system get not applied, as the requirement foobar is met after installation, only foobar==X.y.z would force an update on pip install -r requirements/base.txt

I can provide an pull request if required, also i would recommend integration of requires.io, so we have an status on our pinned requirements.

Handle GROUP Reads

Scope

XKNX devices check the length of the payload. This fails if a GROUP_READ is sent to an specific group_address.

How to reproduce:

#!/usr/bin/python3

from xknx import XKNX,Config,Multicast,Address,Telegram,TelegramType,TelegramDirection,DPTBinary, DPTArray, DPTTemperature

xknx = XKNX()
Config(xknx).read(file="/home/julius/.homeassistant/xknx.yaml")

xknx.globals.own_address = Address("6.6.6")

def read(address):
    telegram = Telegram(address, direction = TelegramDirection.OUTGOING, telegramtype=TelegramType.GROUP_READ)
    multicast = Multicast(xknx)
    multicast.send(telegram)

read(Address("5/1/1"))

Solutions

  • Either ignore these kind of errors
  • Introduce two different process methods: process_group_write and process_group_read, which both can be overloaded.

Support for maximum Setpoint Shift

Usually, by using Setpoint Shift, a maximum of this shift is defined in the Actuator using ETS. This maximum is normally not returned on the KNX bus and therefor XKNX does not know it. If a shift is set higher then the max shift, then the Actuator returns a new target temperature corresponding to the max shift. Some Actuators, like mine, does also not send the current shift.

For example:
Current Setpoint: 21C
Setpoint size: 0.5K
Max Setpoint shift: 3.0K

If new temp is set to 25C, the KNX bus (Actuator) returns 24C. However internally (in XKNX) the shift is still 4K (if not returned on the bus by the Actuator - like mine) and subsequently, the next shift is miscalculated.

Therefor it would be nice to incorporate a maximum setpoint shift. Like:
setpoint_max_shift: 3.0

DPT Types

I use this as DPT reference. Should we use this for documentation purposes?

Function length EIS DPT Value
Switch 1 Bit EIS 1 DPT 1 0,1
Dimming (Position, Control, Value) 1 Bit, 4 Bit, 8 Bit EIS 2 DPT 3 [0,0]...[1,7]
Time 3 Byte EIS 3 DPT 10 10.001 DPT_TimeOfDay Day 1 = Monday 7 = Sunday 0 = no day[0…7] Hour binary encoded [0…23] hours h Minutes binary encoded [0…59] minutes min Seconds binary encoded [0…59] seconds s
Date 3 Byte EIS 4 DPT 11
Floating point 2 Byte EIS 5 DPT 9 -671088,64 - 670760,96
8-bit unsigned value 1 Byte EIS 6 DPT 5 0...255
8-bit unsigned value 1 Byte DPT 5.001 DPT 5.001 0...100
Blinds / Roller shutter 1 Bit EIS 7 DPT 1 0,1
Priority 1 Bit EIS 8 DPT 2 [0,0]...[1,1]
IEEE Floating point 4 Byte EIS 9 DPT 14 4-Octet Float Value
16-bit unsigned value 2 Byte EIS 10 DPT 7 0...65535
16-bit signed value 2 Byte DPT 8 DPT 8 -32768...32767
32-bit unsigned value 4 Byte EIS 11 DPT 12 0...4294967295
32-bit signed value 4 Byte DPT 13 DPT 13 -2147483648...2147483647
Access control 1 Byte EIS 12 DPT 15
ASCII character 1 Byte EIS 13 DPT 4
8859_1 character 1 Byte DPT 4.002 DPT 4.002
8-bit signed value 1 Byte EIS 14 DPT 6 -128...127
14 character ASCII 14 Byte EIS 15 DPT 16
14 character 8859_1 14 Byte DPT 16.001 DPT 16.001
Scene 1 Byte DPT 17 DPT 17 0...63
HVAC 1 Byte DPT 20 DPT 20 0..255
Unlimited string 8859_1 . DPT 24 DPT 24
List 3-byte value 3 Byte DPT 232 DPT 232 RGB[0,0,0]...[255,255,255]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.