arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
22.12k stars 4.79k forks source link

KNX: please increment the amount of Group Addresses to Receive Data #6520

Closed jkx closed 5 years ago

jkx commented 5 years ago

By default KNX Tasmota accept up to 10 group addresses to receive data. For a single relay, we usually need 3 addresses. one to accept read request, one to receive on/off commands and one for toggle.

For a Sonoff 4channels, that give us 12 group addesses, but 10 is the default max. So we are unable to use this kind of config for 4 chanels devices.

I tried to modify the source code as described in xdrv_11_knx.ino

// sonoff.h

const uint8_t MAX_KNX_GA = 16;  
const uint8_t MAX_KNX_CB = 16;   

// esp-knx-ip.h

#define MAX_CALLBACK_ASSIGNMENTS  16
#define MAX_CALLBACKS             16
#define MAX_CONFIGS               32

After changing this lines, the whole config isn't stored anymore. Every "save config" (even the module config) on the sonoff isn't saved. I'm unable to upgrade the firmware OTA.

Thanks for the help.

ascillato commented 5 years ago

Hi,

After changing this lines, the whole config isn't stored anymore. Every "save config" (even the module config) on the sonoff isn't saved. I'm unable to upgrade the firmware OTA.

That change brokes the memory map on your device. You need to erase all flash and flash Tasmota from the precompiled bins. A change in the number of Group Addresses to Receive Data requires much more code modifications also in the KNX driver and RAM usage.

For a single relay, we usually need 3 addresses. one to accept read request, one to receive on/off commands and one for toggle.

Could you be more specific? How is your config that you need 3 KNX slots for every relay? I just use one KNX slot for every relay. You can read/write on the same address.

Can you share your config and setup?

jkx commented 5 years ago

Here a sample config, for a single relay.

screenshot

4 / 0 / 13 -> Output 1  is mandatory (same as send group) to be able to request a read value 4 / 0 / 14 -> Output 1  to send ON/OFF. If you use the same 4/0/13, you will broadcast a KNX state that isn't the real state. 4 / 0 / 15 -> Output 1 Toggle , just to toggle.

Thanks

ascillato commented 5 years ago

Ok, but why you separate them in 3 different slots? It works in the same slot.

jkx commented 5 years ago

I have some buttons paired w/ the ON/OFF commands (1bits) and some w/ the toggle, so at leat 2 are needed.

The last one come from one bug in esp-knx-ip. It need a slot to receive the READ request for the state.

Check out issue 3165 that describe this.

https://github.com/arendst/Sonoff-Tasmota/issues/3165

Without this, my automation won't able to query the state off the devices at boot.

Thanks

ascillato commented 5 years ago

For 1 output, your config should look like in the wiki:

image

And you can use the same address for Data to send to group addresses and for Group Addresses to receive data from

(the loop avoiding in KNX is just not using the same address for output and input in more than 1 device)

Tasmota answers the state when a read request arrives to the "group address to receive data", so you don't need any extra slot.

The screenshot is one of my devices. My home automation system (Home Assistant) makes a KNX read request to 2/2/1 when it boots and with that config, Tasmota answers the state by KNX. Also, I can send to Tasmota to the same address an ON, or OFF and receive from the same address its state when it changes.

In your config you are duplicating slots. There is no need for that.

ascillato commented 5 years ago

The last one come from one bug in esp-knx-ip. It need a slot to receive the READ request for the state.

That is not a bug. It is the way it works. Tasmota answer the state when a read request arrives to the "group address to receive data"

ascillato commented 5 years ago

Please, share a screenshot of your full KNX config

jkx commented 5 years ago

knx-slots

ascillato2 commented 5 years ago

Please, try without using 4/0/14 and 4/0/15

Those are just duplicated. You can use just 4/0/13 for controlling, reading state and for informing its state.

jkx commented 5 years ago

If I remove the 4/0/14, I will have the same address for command and the the state. This can work, but if the device is disconnected (wifi is dead or anything else), when someone on the bus (for example an knx switch) send an "ON". The homeautomation will receive this "ON" too. And will think the device is "ON", even if the device is disconnected or not working properly. This is the main reason why in KNX state and command address aren't the same. (this is exactly what #3165 is about).

Look at this cEMI, if I push a KNX btn. If you have both GA set to 4/0/13. You will not able to distinguish the two cEMI (the command & the state change).

2019-09-30 21:50:30 i7 __main__[5195] DEBUG Receive: <KNXcEMI at 0x7f9452ba4a90 pa=6.6.6 ga=4/0/15 code=0x29 cmd=KNXCommand.WRITE data=bytearray(b'\x01')>

2019-09-30 21:50:30 i7 __main__[5195] DEBUG Receive: <KNXcEMI at 0x7f945061f3d0 pa=4.0.2 ga=4/0/13 code=0x29 cmd=KNXCommand.WRITE data=bytearray(b'\x01')>

For the 4/0/15, I have an KNX push button linked to this, not doable :)

You can use HomeAssistant with only 1 GA but : 1) It will send command and never can really trust the state of the device without sending an bunch of READ, or only trusting internal state.

2) To toggle the light, it will use the internal state (or query the current state) before sending an ON or OFF. I can't do that cause I don't use HA, it will put the whole house in dark if HA stops working. And that's really bad the WAF.

Thanks.

ascillato commented 5 years ago

Ok, I understand your use case. You want to have separated the address for control and for state, making the 10 available slots not enough for you. That is Ok.

I'm adding this request to my to do list for the KNX driver, but will not do this soon as this adds more RAM usage and will require to do some more optimizations to the code in order to not affect other Tasmota features.

it will put the whole house in dark if HA stops working

That doesn't happen in a home automation well done. Every smart device can control itself. If your home assistant brokes, all devices will continue to communicate between them by KNX as long as your wifi works. A Home Assistant instance should have just telesupervision (panels, databases, etc) and very high level automations. The rest of automations should be in every device (distributed control approach).

ascillato2 commented 5 years ago

Added the label (Requested Feature - Hold Over) for future reference.

@jkx Thanks for sharing your ideas