seydx / homebridge-fritz-platform

AiO Homebridge dynamic platform plugin for AVM hardware like Fritz!Box, Fritz!Repeater etc.
MIT License
225 stars 32 forks source link

Error when adding smarthome: Cannot read property identifier of undefined #18

Closed Phoenix-DH closed 5 years ago

Phoenix-DH commented 5 years ago

Hi,

I updated yesterday to latest version. It is running fine until now. I used from history an additional plugin for fritz: homebridge-fritz for DECT 200. But I want to get rid of this and use this instead.

My config is working fine, until I add the smarthome block. If I add it I get the attached error .

My config is the following: { "platform": "FritzPlatform", "devices":{ "Fritz!Box":{ "host":"192.168.XX.XX", "master":true, "port":49000, "username":"USERNAME", "password":"PASSWORD", "type":"cable", "wifi2":true, "wifi5":true, "wifiGuest":true, "phoneBook":true, "wps":true, "aw":true, "deflection":false, "led": true, "lock":true, "beta":false, "mesh":false } }, "smarthome": { "Rack DECT 200":{ "ain":"111111111111", "type":"switch", "tempSensor":true, "unit":"celsius" } }, "broadband":{ "active":true, "measureTime":5, "polling":30 }, "delay":60, "polling":5, "timeout": 5 }

The error what I get is the following: img_3927

When I remove this block: "smarthome": { "Rack DECT 200":{ "ain":"111111111111", "type":"switch", "tempSensor":true, "unit":"celsius" } }, ...everything is working fine.

It seems to me that the plugin will not trigger an update.

Phoenix-DH commented 5 years ago

No recommendations? Would be great if I can get it working.

Thanks.

seydx commented 5 years ago

Hey, checking currently the issue, will publish a fix later

Phoenix-DH commented 5 years ago

Great, thank you.

Phoenix-DH commented 5 years ago

Thanks for the update!

I was now able to add the samrthome features. I tried a AVM DECT 200. It is showing up in home but the values are not upüdating.

There are no errors in the homebridge log.

I also removed the other fritz plugin, no change. The other one is still working.

Config: { "platform": "FritzPlatform", "devices": { "Fritz!Box": { "host": "XXX", "master": true, "port": 49000, "type": "cable", "username": "XXX", "password": "XXX", "wifi2": true, "wifi5": true, "wifiGuest": true, "wps": true, "deflection": false, "led": true, "phoneBook": false, "aw": true, "beta": false, "mesh": false } }, "broadband": { "active": true, "measureTime": 5, "polling": 30 }, "smarthome": { "Rack DECT 200": { "ain": "XXX", "type": "switch", "tempSensor": true, "unit": "celsius" } }, "delay": 60, "polling": 5, "timeout": 5 },

seydx commented 5 years ago

Hey i need more info for this. Can you update to v3.0.6. I have added a "test" file to debug more.

Open terminal, go to the plugin/test folder (example: cd /usr/lib/node_modules/homebridge-fritz-platform/test)

If you are in the "test" folder, write "sudo node index.js" and click enter. In the input field, write "smarthome" and click enter

Post the output here pls

Phoenix-DH commented 5 years ago

Thanks!

It took a lot of time, but then ...

An error occured by initializing device! { Error: connect ETIMEDOUT 192.168.178.1:49000 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1083:14) errno: 'ETIMEDOUT', code: 'ETIMEDOUT', syscall: 'connect', address: '192.168.178.1', port: 49000 }

The IP is wrong, I have not this value, this seems to be the value from the GUEST Network ...

I have "host": "192.168.99.1",

This seems to be the problem.

seydx commented 5 years ago

Ah yes you need to open the index.js file in the test folder and edit some lines

you need to change the ip (line: 7) to your fritzbox ip and also username (line: 10) and password (line: 11), save the file and try running again

Phoenix-DH commented 5 years ago

Got it ... this is the result:

Encrypted communication started with: FRITZ!Box 6490 Cable (kdg) events.js:173 throw er; // Unhandled 'error' event ^

TypeError: Cannot read property 'split' of undefined at /usr/lib/node_modules/homebridge-fritz-platform/test/index.js:64:46 at /usr/lib/node_modules/homebridge-fritz-platform/lib/Service.js:277:15 at Parser. (/usr/lib/node_modules/homebridge-fritz-platform/node_modules/xml2js/lib/parser.js:303:18) at Parser.emit (events.js:197:13) at SAXParser.onclosetag (/usr/lib/node_modules/homebridge-fritz-platform/node_modules/xml2js/lib/parser.js:261:26) at emit (/usr/lib/node_modules/homebridge-fritz-platform/node_modules/sax/lib/sax.js:624:35) at emitNode (/usr/lib/node_modules/homebridge-fritz-platform/node_modules/sax/lib/sax.js:629:5) at closeTag (/usr/lib/node_modules/homebridge-fritz-platform/node_modules/sax/lib/sax.js:889:7) at SAXParser.write (/usr/lib/node_modules/homebridge-fritz-platform/node_modules/sax/lib/sax.js:1436:13) at Parser.exports.Parser.Parser.parseString (/usr/lib/node_modules/homebridge-fritz-platform/node_modules/xml2js/lib/parser.js:322:31) Emitted 'error' event at: at Parser.exports.Parser.Parser.parseString (/usr/lib/node_modules/homebridge-fritz-platform/node_modules/xml2js/lib/parser.js:326:16) at Parser.parseString (/usr/lib/node_modules/homebridge-fritz-platform/node_modules/xml2js/lib/parser.js:5:59) at exports.parseString (/usr/lib/node_modules/homebridge-fritz-platform/node_modules/xml2js/lib/parser.js:354:19) at Request._callback (/usr/lib/node_modules/homebridge-fritz-platform/lib/Service.js:224:13) at Request.self.callback (/usr/lib/node_modules/homebridge-fritz-platform/node_modules/request/request.js:185:22) at Request.emit (events.js:197:13) at Request. (/usr/lib/node_modules/homebridge-fritz-platform/node_modules/request/request.js:1161:10) at Request.emit (events.js:197:13) at IncomingMessage. (/usr/lib/node_modules/homebridge-fritz-platform/node_modules/request/request.js:1083:12) at Object.onceWrapper (events.js:285:13)

seydx commented 5 years ago

Can you replace the index.js file in the test folder with the index.js file here in the attachment and change the lines (ip, username and password) with your own data and try the procedure again pls

index.js.zip

Phoenix-DH commented 5 years ago

Done... now I get values i think:

Encrypted communication started with: FRITZ!Box 6490 Cable (kdg) { 'NewX_AVM-DE_UrlSID': 'sid=XXX' }

########### 1 ############

{ devicelist: { '$': { version: '1' }, device: { '$': [Object], present: '1', name: 'Technikraum', switch: [Object], powermeter: [Object], temperature: [Object] } } }

########### 2 ############

{ '$': { version: '1' }, device: { '$': { identifier: 'XXX', id: '17', functionbitmask: '2944', fwversion: '03.87', manufacturer: 'AVM', productname: 'FRITZ!DECT 200' }, present: '1', name: 'Technikraum', switch: { state: '1', mode: 'manuell', lock: '0', devicelock: '0' }, powermeter: { power: '59430', energy: '834866' }, temperature: { celsius: '245', offset: '0' } } }

########### 3 ############

{ '$': { identifier: 'XXX', id: '17', functionbitmask: '2944', fwversion: '03.87', manufacturer: 'AVM', productname: 'FRITZ!DECT 200' }, present: '1', name: 'Technikraum', switch: { state: '1', mode: 'manuell', lock: '0', devicelock: '0' }, powermeter: { power: '59430', energy: '834866' }, temperature: { celsius: '245', offset: '0' } }

seydx commented 5 years ago

v3.0.7 is online, can u try and report pls if everything working with smarthome now

Phoenix-DH commented 5 years ago

I works, great, thank you! Will see if the eve history for the DECT will also work.

ANd maybe something for the next release: DECT visible as power plug in Home would be great. Also to have in eve app the single values of actual consumption etc.

Thank you!

seydx commented 5 years ago

Will add this into my todo list, closing the issue for now :)

Phoenix-DH commented 5 years ago

For sure! Thank you!