snowdd1 / homebridge-knx

KNX platform shim for homebridge
https://github.com/nfarina/homebridge
GNU General Public License v2.0
97 stars 56 forks source link

knxread:openTGroup: Error: request invalid #99

Closed migabc closed 4 years ago

migabc commented 7 years ago

Hi,

I'm trying to use KNXReadRequests to read group addresses on startup of homebridge but it doesn't seem to be working: I'm getting these errors on startup:

Jul 6 09:45:08 raspberrypi homebridge[24875]: [7/6/2017, 9:45:08 AM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid Jul 6 09:45:08 raspberrypi homebridge[24875]: [7/6/2017, 9:45:08 AM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid Jul 6 09:45:08 raspberrypi homebridge[24875]: [7/6/2017, 9:45:08 AM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid

Here's my code:

    {
        "DeviceName": "Thermostats",
        "Services": [
            {
                "ServiceType": "Thermostat",
                "ServiceName": "Corridor and Kitchen WC Thermostat",
                "Characteristics": [
                    {
                        "Type": "TargetHeatingCoolingState",
                        "Set": [
                            "1/0/41"
                        ]
                    },
                    {
                        "Type": "CurrentHeatingCoolingState",
                        "Listen": [
                            "1/0/42"
                        ]
                    },
                    {
                        "Type": "CurrentTemperature",
                        "Listen": [
                            "1/0/43"
                        ]
                    },
                    {
                        "Type": "TargetTemperature",
                        "Set": [
                            "1/0/49"
                        ],
                        "Listen": [
                            "1/0/49"
                        ]
                    }
                ],
                "KNXReadRequests": [
                    "1/0/42",
                    "1/0/43",
                    "1/0/49"
                ],
                "subtype": "SUB_03d1c1ae-8156-4fe0-8417-4067e2536482"
            },

Any help is much appreciated

snowdd1 commented 7 years ago

Please check your knxd connection settings.

migabc commented 7 years ago

What do you mean by knxd connection settings? The knxd is running fine and I can use the read command manually:

Here are my knxd connection settings:

pi@raspberrypi:~ $ cat /etc/knxd.conf | grep ^KNXD_OPTS KNXD_OPTS="-e 0.0.100 -E 0.0.101:7 -D -T -R -S -i 6720 -b tpuarts:/dev/ttyKNX1"

For example, this KNXReadRequest is not working on startup, so the Home app does not show the correct state of the Outlet when the homebridge starts up:

            {
                "ServiceType": "Outlet",
                "ServiceName": "Kitchen Counter Right-side Outlets",
                "Characteristics": [
                    {
                        "Type": "On",
                        "Set": [
                            "1/2/61"
                        ],
                        "Listen": [
                            "1/2/62"
                        ]
                    }
                ],
                "KNXReadRequests": [
                    "1/2/62"
                ],
                "subtype": "SUB_9536a472-f317-435a-adce-cdb6dcf6b968"
            }

But If I issue the read command manually the Listen statement is triggered so it automatically sets it to the correct state (ON or OFF)

iMac-27-Retina:~ maconceicao$ /opt/knx/bin/groupread ip:192.168.0.50 1/2/62 Send request

snowdd1 commented 7 years ago

Hi Miguel, that looks strange. Did that happen all the time or is that something new?
My read requests do all work, so did you change something lately?

migabc commented 7 years ago

Can it be because I have a lot of KNXReadRequests:

pi@raspberrypi:~ $ cat /var/lib/homebridge/knx_config.json | grep KNXReadRequests | wc -l 36

Maybe the knxd is not capable of sending out so many KNXReadRequests all at once. That's probably why I'm getting these error lines in the log on startup:

Jul 7 14:53:38 raspberrypi homebridge[29521]: [7/7/2017, 2:53:38 PM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid Jul 7 14:53:38 raspberrypi homebridge[29521]: [7/7/2017, 2:53:38 PM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid Jul 7 14:53:38 raspberrypi homebridge[29521]: [7/7/2017, 2:53:38 PM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid Jul 7 14:53:38 raspberrypi homebridge[29521]: [7/7/2017, 2:53:38 PM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid Jul 7 14:53:39 raspberrypi homebridge[29521]: [7/7/2017, 2:53:39 PM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid Jul 7 14:53:39 raspberrypi homebridge[29521]: [7/7/2017, 2:53:39 PM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid Jul 7 14:53:39 raspberrypi homebridge[29521]: [7/7/2017, 2:53:39 PM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid

migabc commented 7 years ago

It seems to be inconsistent, meaning it sometimes triggers the KNXReadRequests on startup and sometimes it doesn't.

Just restarted the homebridge and now it did trigger the read of the 1/2/62 outlet. So this time the Outlet state was shown as "On" (unlike before)

Anyway, I'm still puzzled about these errors that keep showing up on startup

Jul 7 15:39:41 raspberrypi homebridge[30003]: [7/7/2017, 3:39:41 PM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid Jul 7 15:39:41 raspberrypi homebridge[30003]: [7/7/2017, 3:39:41 PM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid Jul 7 15:39:41 raspberrypi homebridge[30003]: [7/7/2017, 3:39:41 PM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid Jul 7 15:39:41 raspberrypi homebridge[30003]: [7/7/2017, 3:39:41 PM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid ... Jul 7 15:39:41 raspberrypi homebridge[30003]: [7/7/2017, 3:39:41 PM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid Jul 7 15:39:41 raspberrypi homebridge[30003]: [7/7/2017, 3:39:41 PM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid Jul 7 15:39:41 raspberrypi homebridge[30003]: [7/7/2017, 3:39:41 PM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid Jul 7 15:39:41 raspberrypi homebridge[30003]: [7/7/2017, 3:39:41 PM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid Jul 7 15:39:41 raspberrypi homebridge[30003]: [7/7/2017, 3:39:41 PM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid

snowdd1 commented 7 years ago

The number shouldnt be an issue:

pi@knxd2-raspberry:~/.homebridge $ cat knx_config.json | grep KNXReadRequests | wc -l
76
pi@knxd2-raspberry:~/.homebridge $

I never had any trouble with the read requests being sent. However, as there a lot of issues with knxd and several hardware devices, you might look into the issues there - maybe something like the new pace parameter to slow down the sending of telegrams might be required with your KNX hardware.

migabc commented 7 years ago

It seems that all my KNXReadRequests eventually get triggered after a short while When I restart the homebridge after a while (some several minutes) all my devices end up showing the correct state. So in this perspective it's working fine for me.

But the strange thing is that after the restart of the homebridge the log file always shows around 64 error lines like this one:

Jul 9 17:34:31 raspberrypi homebridge[30003]: [7/7/2017, 3:39:41 PM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid

These lines only show up when I restart the homebridge (and not during normal running operation) There seems to be one error line for each KNXReadRequests address in my JSON file. The error message suggests that I probably have some invalid syntax on the KNXReadRequests but nevertheless it still starts up ok and all my KNXReadRequests eventually all get triggered after a short while.

The only strange thing is the ERRORs in the log file. I thought this might be a bug and that’s why I reported it. But if it’s working OK I’ll simply disregard it

vddgil commented 7 years ago

Hello everyone,

Actually I have the same issue after updating to knxd 0.14.16. With the previous version (0.12.15) I had not this issue. Maybe it's related ?

@migabc What version of knxd do you have ?

Thanks !

migabc commented 7 years ago

I'm running

pi@raspberrypi:~ $ knxd -V knxd 0.12.15-2

snowdd1 commented 6 years ago

Does any body still have this? I never encountered it.

migabc commented 6 years ago

Yes, I still have that. It occurs everytime I restart the homebridge:

Oct 5 23:27:52 raspberrypi homebridge[6039]: [10/5/2017, 11:27:52 PM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid Oct 5 23:27:52 raspberrypi homebridge[6039]: [10/5/2017, 11:27:52 PM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid Oct 5 23:27:52 raspberrypi homebridge[6039]: [10/5/2017, 11:27:52 PM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid Oct 5 23:27:52 raspberrypi homebridge[6039]: [10/5/2017, 11:27:52 PM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid Oct 5 23:27:52 raspberrypi homebridge[6039]: [10/5/2017, 11:27:52 PM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid Oct 5 23:27:52 raspberrypi homebridge[6039]: [10/5/2017, 11:27:52 PM] [homebridge-knx.KNX] [ERROR] knxread:openTGroup: Error: request invalid

These lines only show up when I restart the homebridge (and not during normal running operation) There seems to be one error line for each KNXReadRequests address in my JSON file. The error message suggests that I probably have some invalid syntax on the KNXReadRequests but nevertheless it still starts up ok and all my KNXReadRequests eventually all get triggered after a short while.

gsirin commented 6 years ago

Have a similar issue. Installed and configured everything today.

I can switch and dim all my lights (27 so far) one by one without any issues and get the correct state via "Listen"-GroupAddress.

But when I create a scene or tell Siri to turn all the lights off or on then the result is everytime:

Siri (Translated from german) "Most of the lights are off. 20 devices do not react"

Console 20 times the message

Oct 6 14:58:45 homebridge homebridge[4406]: [10/6/2017, 2:58:45 PM] [homebridge-knx.KNX] [ERROR] knxwrite:openTGroup: Error: request invalid

Runing on debian 9.1 nodejs 6.11.4 knxd 0.14.18 homebridge 0.4.28 homebridge-knx 0.3.13

Any ideas?

gsirin commented 6 years ago

By adding ":100" to the -E Paramter in KNXD_OPTS= I was able to get rid of the TGroup Error message. Addind an additional send_delay of 150ms and using a tunnel instead of multicast helped to send all the commands to the bus in a more reliable way.

It seems that my described problem is solved with: KNXD_OPTS="-e 0.0.1 -E 0.0.2:100 -D -T -S --send-delay=150 -b ipt:192.168.1.8"

Hopefully this is helpful for someone...

snowdd1 commented 6 years ago

@gsirin Gökhan, thanks for pointing us to that. I never assumed that the 7 addresses that @migabc is reserving might cause this issue, but sending (in his case) 36 read requests with only 7 sender addresses available might really put pressure on the expiring time in knxd.

I have to look up how many I do use, but I think more than 7, probably less than 200 - and I never encountered that error message (if not for misspelled addresses)

migabc commented 6 years ago

I reserved 100 client addresses and it fixed the problem (no more openTGroup: Error: messages on startup)

:-)

pi@raspberrypi:~ $ cat /etc/knxd.conf | grep ^KNXD_OPTS KNXD_OPTS="-e 0.0.100 -E 0.0.101:100 -D -T -R -S -i 6720 -b tpuarts:/dev/ttyKNX1"

Thanks a lot snowdd1 and gsirin for your help in solving this issue

Mr-S-D commented 6 years ago

I am experience this issue as well. My KNXD settings are: KNXD_OPTS="-e 0.0.1 -E 0.0.2:100 -u /tmp/eib -b ip:"

Is there something I should change to make it work? If turning a light on and off, it gets the correct status afterwards.... however, with sensor/contacts in doors/windows it should not be necessary to open and close all windows/doors so I get the correct readings :)

GeminiServer commented 5 years ago

Have sometimes the same Problem, too. Seems to be that homebridge-knx cloud not get a new knx client address from knxd. Restart of knxd will solve the problem (releases client address cache). May the homebridge-knx does not release the knx client address, so knxd says no more address.

Versions: knxd 0.14.24-3:4fadfa4 homebridge@0.4.45 homebridge-knx@0.3.13

hyperbart commented 5 years ago

Got the same issue, everything seems to be working okay until you do a complete sweep through your house with Siri like "turn on all sockets" or "turn off all lights", will now try the solution of @gsirin .

marco-hoyer commented 5 years ago

I also face the same problem with homebridge not properly reading the state from knx bus after restart. As @gsirin suggested I wanted to increase the number of reserved addresses in Knxd config but my MDT SCN-IP000.01 interface only support 4 concurrent connections. May it be that this is simply the limitation? Might homebridge-knx handle this somehow? I see no change fixing this elsewhere other than buying another IP interface.

marco-hoyer commented 5 years ago

This topic seems to be related to #78?!

petkoe commented 4 years ago

Hi All,

i had the same problem. I never had the problem earlier. But now I installed a complete new pi with latest Homebridge, HB-KNX and KNXD and suddenly the error appeared. After using

-E 0.0.2:100

The error disappeared.

P

snowdd1 commented 4 years ago

Yeah, that generally comes from knxd being unable to assign new "physical" addresses for write accesses to the bus. The current implementation does not re-use the existing connection but discards it after use, so the next bus write command requires a new connection. Depending on the number of write commands your setup might need, knxd runs out of address space.

As @petkoe wrote, increasing the number of physical addresses to e.g. 100 can solve the issue.

Depending on your KNX installation, you can assign up to 254 addresses by using a free physical range, such as 0.1.1 to 0.1.255, given that 0.1.x is completely unused and you do have (if existing) knx line connectors configured accordingly.

As for the syntax: some years back knxd switched to a more readable ini file. In there the according setting would be

[main]
addr = 1.1.1
client-addrs=1.1.2:253