New service weewx-knx

107 views
Skip to first unread message

Alexander Zeh

unread,
Nov 4, 2020, 4:17:51 AM11/4/20
to weewx-development
Hi,

i am new to this group and to participating in open source at all.
I added a new weewx service to submit weather data to knx bus (e.g. to control blinds) in an own repo: https://github.com/AZAZ78/weewx-knx.
I already created a wiki page in the weewx wiki with informations about it: https://github.com/weewx/weewx/wiki/knx.

Can i also adapt the wiki entry page and add it to the list of service extensions or do i have to ask somebody for it?

By the way, thanks to you all for this cool tool!

Best regards
Alex

Tom Keffer

unread,
Nov 4, 2020, 7:47:01 AM11/4/20
to Alexander Zeh, weewx-development
You are welcome to add your extension to the Wiki entry page.

A few small things:

1. You are not using the imports

import os
from datetime import time, date, datetime
import weeutil.weeutil

so they can safely be remove from knx.py

2. You used the old style "syslog" way of logging. This has been replaced with a "logging" based approach. See the wiki article WeeWX V4 and Logging, in particular, the section Maintaining backwards compatibility

3. You are making a copy of the configuration dictionary, then modifying it:

self._knx_map = conf.copy()
del self._knx_map['gateway_ip']
del self._knx_map['gateway_port']

Unfortunately, this is a shallow copy, so the deletions will delete not only entries in _knx_map, but also in conf. This means weewxd will not respond properly to a HUP reload. You want a deep copy:

import weeutil.config
...
self._knx_map = weeutil.config.deep_copy(conf)
del self._knx_map['gateway_ip']
del self._knx_map['gateway_port']

4. The check

if self._gateway_ip is '0.0.0.0':

is a check for identity. You want a check for equality:

if self._gateway_ip == '0.0.0.0':

5. The install program uses

from setup import ExtensionInstaller

This has been replaced with

from weecfg.extension import ExtensionInstaller


All small things. Thanks for your contribution!

-tk


--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/84462ba6-6a65-41da-b3b3-cbab3a494a34n%40googlegroups.com.

Greg Troxel

unread,
Nov 4, 2020, 3:29:49 PM11/4/20
to Alexander Zeh, weewx-development

It's great that you are extending weewx and contributing. I want to
suggest something else you might want to look into, although it's more
complicated.

weewwx excels at
dealing with weather station hardware
converting/regularizing weather data
storing weather data for the long term
making graphs and webpages of weather data
with mqtt extension, publishing data to MQTT
probably other stuff I forgot or don't know about

and while software can be extended in any direction, it sounds like you
are crossing into home automation. I think it makes sense to have a
weather thing and an automation thing and connect them, rather than
making one that does it all. (This is about sharing and reuse, nothing
fundamental).

For home automation, I use Home Assistant (also python), and I have
weeewx post data to MQTT and ingest that into Home Assistant. So I'd
awnt to have a Home Assistant integration for knx, so that you can
manually control it from the UI, write rules, have HA send the weather
dat to it if that's how it works, or perhaps you'd want the logic in
python and not use the builtin logic.

As an example, I have rules that change lights depending on how bright
it is outside. not how bright it should be based on time, but based on
the solar radiation sensor from weewx via MQTT. This sounds a bit like
what you probably want with blinds.



I don't mean to say you shouldn't do what you are doing. It certainly
makes sense and sharing it helps others. (In fact, I didn't know about
KNX and will now look into it!) I'm only writing in case you didn't
know about Home Assistant or hadn't considered it.

It turns out others have already done things you might find useful:
https://www.home-assistant.io/integrations/knx/

Greg
signature.asc

Alexander Zeh

unread,
Nov 5, 2020, 3:54:45 PM11/5/20
to weewx-development
Hi Tom,

thanks for your hints ... very usefull ;-)
I adapted the files.

Thanks
Alex

Alexander Zeh

unread,
Nov 5, 2020, 4:01:43 PM11/5/20
to weewx-development
Hi Greg,

from architectural point of view you are absolutly right.

In EIB environment you have often intelligent devices which are directly interconnected.
Means you can pay much money for a EIB enabled weather station which directly send information to the BUS.
With my extension you can use a low cost station with a Raspberry as a full replacement, even if you have no homeserver.

By the way, i use smarthomeNG with smartVISU as home server with UI.

Best regards
Alex  

Reply all
Reply to author
Forward
0 new messages