snowdd1 / homebridge-knx

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

Switch turnon at startup homebridge #17

Closed gjniewenhuijse closed 8 years ago

gjniewenhuijse commented 8 years ago

I have added a switch to turn a device on/off and get the current state, but when i startup homebridge my switch turns on and sends 1 on the knx bus to groupaddress 9/1/9, how to prevent values are send on startup?

{
                    "accessory_type": "knxdevice",
                    "description": "Only generic type knxdevice is supported, all previous knx types have been merged into that.",
                    "name": "Test",
                    "services": [
                        {
                            "type": "Switch",
                            "description": "iOS8 Lightbulb type, supports On (Switch) and Brightness",
                            "name": "Test",
                            "On": {
                                "Set": "9/1/9",
                                "Listen": ["9/2/9"]
                            }
                        }
                    ],
                    "services-description": "Services is an array, you CAN have multiple service types in one accessory, though it is not fully supported in many iOS HK apps, such as EVE and myTouchHome"
                },
snowdd1 commented 8 years ago

It shouldn't do that. Can you post the log from start to the moment it sends the value to the bus as a gist and link it here?

gjniewenhuijse commented 8 years ago

the problem is the read on the Set address, see the following example. Fountain has more then 1 mapping, 9/1/9 and 1/0/0 Turn on the switch with address 9/1/9 (fountain on) Turn off the switch with address 1/0/0 (all units off including the fountain) restart homebridge read is done on 9/1/9 and response 1 on the bus, because thats the last value send for 9/1/9 but the fountain is off, now its turned on.

I think reading the set address is not a good idea, reading values is for listen addresses only. Or do i think wrong?

snowdd1 commented 8 years ago

You are right. This should be avoidable. However, which device answers the 9/1/9 read with "1"? The fountain switch itself should know that it is "off", however, some other device on the bus has cached the 9/1/9 value and is answering the read request - which it shouldn't. The fountain switch itself should switch at an ANSWER type telegram, however, as there are still devices out there that do not know about READ and ANSWER telegrams, the READ flag in ETS should be off for all devices bound to your 9/1/9 device. I myself have old Gira Wall Panels that happily cache those values and answer if they are allowed to - but the values might be old as they are not fully configured to all multiple mappings I have.

Nevertheless, I am working on a new data model that allows to set READ and WRITE flags to all addresses, no matter where and how often they are assigned to services.

gjniewenhuijse commented 8 years ago

You're totally right. In the 9/1/9 group are two Berker KNX RF devices that responses on a read command even if the READ flags are off.

Very strange, so i reported this also to Hager/Berker.

gjniewenhuijse commented 8 years ago

Can i simple change this line in the index.js code to get only the listen addresses read on the bus?

this.knxreadarray([config.Set].concat(config.Listen || []));

maybe something like this: this.knxreadarray(config.Listen || []);

snowdd1 commented 8 years ago

Sure!

gjniewenhuijse commented 8 years ago

It works :)

snowdd1 commented 8 years ago

I just pushed a new version 0.2.6 which contains a new flag for the config.json to switch the behavior (see https://github.com/snowdd1/homebridge-knx#syntax-of-the-configjson). The next big version will change just everything (if I ever get that done), so stay tuned.