henry-spanka / freeathome-api

Busch-Jaeger free@home API to control actuators
MIT License
45 stars 4 forks source link

Receive <log> message in SystemAccessPoint.parseEncryptedUpdates #18

Closed guckykv closed 4 years ago

guckykv commented 4 years ago

My first try to install homebridge for my new free@home installation. But freeathome-api failes.

For a message of type headline I receive an item with an log element:

`

kLrR...YNKg==

`

The api doesn't like this. The filter function item.getChild('update').attrs.xmlns dies.

29.12.2019, 20:33:47 - ERR: Unexpected error while processing stanza event
29.12.2019, 20:33:47 - ERR: TypeError: Cannot read property 'attrs' of undefined

I've made a small patch for the function to skip the log messages (never done anything in JS before :) )

        let logitems = stanza.getChild('event').getChild('items').getChildren('item').filter((item) => item.getChild('log'));
        if (logitems.length == 0) {
            let items = stanza.getChild('event').getChild('items').getChildren('item').filter((item) => item.getChild('update').attrs.xmlns == 'http://abb.com/protocol/update_encrypted');
            for (let item of items) {
                let data = item.getChild('update').getChildText('data');
                let update = this.parseDecryptedData(new MessageReader_1.MessageReader(this.crypto.decryptPubSub(data)));
                this.applyIncrementalUpdate(XmlParser_1.XmlParser.parseUpdate(update));
            }
        }

Then the API is up and running. But I'm not sure if I'm missing now some important information.

If I start homebridge now I can connect it with my iOS home app, but absolutely nothing happens. No devices appear on the screen. But http://127.0.0.1:8080/info shows a lot of devices/data.

I've tried to handle the log messages like the update messages (parseDecryptedData). But than the first update(!) message failes with

29.12.2019, 20:48:30 - ERR: Error: Unexpected sequence in received symmetric nonce 653963(653968)

I have SysAP 2.0 with 97 devices and version 2.4.0 rev 7586.

henry-spanka commented 4 years ago

Hi, thank you for reporting this. I have never seen log messages before. Not sure what exactly they do but I think we can ignore them.

I have pushed a commit to the master branch which should correctly filter the update messages. Please switch to the master version and check if the error is gone.

If you still have issues, please post the data you receive from the info endpoint. Please mask all sensitive data like serial numbers if you post it here. You can also send it to my email address (see my GitHub profile) if you don't want to post it online.

guckykv commented 4 years ago

Hi!

I've tested the current version at ea37191 and it works good. I got new warnings, but the api itself works fine.

I get now some new log information:

30.12.2019, 20:37:38 - WARN: Received Log Data which is currently not supported: 1.W3sgIlRJTUU...iLCAiUFJJT1JJVFkiOiAiNiIgfV0=
30.12.2019, 20:37:38 - WARN: Received Log Data which is currently not supported: 0.toTPUart   fc000....1001
toTPUart   30
fromTPUart fb000...100100
fromTPUart 10000010120801000007cd000005e50033000000a500000000000000000000000000000000
fromBus 7a 00 bce0  0109 94a8  01  0080 -
fromBus 7a 00 bce0  0109 8275  02  0080 - 00

Feel free to contcat me if you need more log examples.

Now I also configured homebridge better and I see many new icons on my home app. ;-)

Thanks for the quick reaction!

henry-spanka commented 4 years ago

👍 It seems that the log data is for debug purposes. Do you have the free@home monitor enabled in the web interface? If so please try to disable it. Otherwise just ignore the messages. The API should just work fine.

guckykv commented 4 years ago

Yes. After disabling monitoring in the web interface, the LOG messages disappear.

henry-spanka commented 4 years ago

Alright. So I can close this issue now, right?

guckykv commented 4 years ago

yes - thx