molobrakos / tellduslive

Communicate with Telldus Live servers
The Unlicense
10 stars 9 forks source link

Listen to local UDP broadcasts with sensor readings in addition to server polling #8

Closed molobrakos closed 6 years ago

molobrakos commented 6 years ago

Using https://github.com/molobrakos/tellsticknet to listen to local UDP broadcasts with sensor readings (in addition to server polling), will allow faster sensor updates, which in particular is useful for e.g. door sensors. Main target/context for this is integration into HA (althouh it could be used standalone or in any other application)

molobrakos commented 6 years ago

Main issues for integrating into this into HA.

  1. Integrate protocol definitions from https://github.com/telldus/tellstick-server/tree/master/rf433/src/rf433 into the tellsticknet library Let's just keep the current protocol definitions. Accept new protocols later as PRs if needed by anyone.
  2. Decide / find out how to map a device on LAN to a device from the API (cloud or local). From the API we only get clientId and name, no IP/MAC. We probably need a mapping section in configuration.yamlfor this as well. The constructor (in tellduslive) could accept (in additon to the device mapping) a value listen_local_udp_broadcast (default False), if set to True, use autodiscover, if set to host name / ip, just use it. Also default True if local API is enabled (then we know we are on the same network).

(moved from https://github.com/molobrakos/tellsticknet/issues/7 since most work needs to be done in this library)

molobrakos commented 6 years ago

~Adding feature in https://github.com/molobrakos/tellduslive/tree/udp_listener~ (Merged to master)

kentsoderlind commented 6 years ago

I have made an implementation witch contains a UDP listener for sensors and switches, the main use for the code is setting up a local tellstick net v1 without support for local-api. I will make a pull request from my fork shortly.

molobrakos commented 6 years ago

Great, and thanks for helping out! I checked your branch, is it possible to make one patch against the tellsticknet library, adding whatever you need there to interface (I noticed a lot of code seemed to be copied from there), and then another smaller patch to this library?

Do you think your code can be used for tellstick net v2 and znet devices as well, where we use the local/cloud API, but would like to have the faster local updates over udp as well?

(I'm Erik#2455 on discord btw if you want to discuss)

kentsoderlind commented 6 years ago

There is no reason that this would't work with tellstick net v2 and znet as well. I think we could easily make the auto sensing of sensors work to have fast local updates.

It's correct that a lot of my code is based on the tellsticknet library. The changes i made i not compatible with the old library, except for maybe some of the protocol code. I opted for moving what was need so i didn't have to worry about compatibility the old library.

kentsoderlind commented 6 years ago

I'm knet#5714 on discord

molobrakos commented 6 years ago

Closing this issue. Decided to keep this functionality within the https://github.com/molobrakos/tellsticknet library and implement HA integration using a custom MQTT gateway instead.