staromeste / homebridge-http-advanced-accessory

Supports all devices on HomeBridge Platform / Bridges devices to http
Apache License 2.0
65 stars 22 forks source link

getName returns "undefined" value #20

Open gdavids57 opened 4 years ago

gdavids57 commented 4 years ago

The plug-in was working fine and then started throwing a getName error as indicated in Error after I activated an Hesperus automation using the output from the plug-in. I deactivated the automation but the problem persisted. As you can see in the accessory configuration, "name" is defined. I tried configuring a getter URL, "getName" to no avail.

Error [4/20/2020, 4:22:17 PM] [Pool Level Sensor] getName getter function returned with data: undefined [4/20/2020, 4:22:17 PM] [Pool Level Sensor] updating Name with value [4/20/2020, 4:22:17 PM] TypeError: Cannot read property 'url' of undefined at HttpAdvancedAccessory. (/usr/lib/node_modules/homebridge-http-advanced-accessory/index.js:208:68) at HttpAdvancedAccessory.getter (/usr/lib/node_modules/homebridge-http-advanced-accessory/index.js:371:7) at Characteristic.Name.emit (events.js:311:20) at Characteristic.Name.Characteristic.getValue (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Characteristic.js:164:10) at Bridge. (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:771:20) at Array.forEach () at Bridge.Accessory._handleGetCharacteristics (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:735:8) at HAPServer.emit (events.js:311:20) at HAPServer._handleCharacteristics (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:928:10) at HAPServer. (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:209:39)

Accessory Configuration "accessories": [ { "accessory": "HttpAdvancedAccessory", "service": "ContactSensor", "name": "Pool Level Sensor", "polling": false, "forceRefreshDelay": 0, "debug": true, "urls": { "getContactSensorState": { "url": "http://192.168.1.143/cmd?params=1", "mappers": [ { "type": "jpath", "parameters": { "jpath": "$.return_value" } } ] }, "getName": { "url": "http://192.168.1.143/", "mappers": [ { "type": "jpath", "parameters": { "jpath": "$.name" } } ] } } } ]

staromeste commented 4 years ago

That is a very strange behavior. Can you try with a non-0 "forceRefreshDelay"? Like 5, for example...

On Mon, 20 Apr 2020 at 23:36, gdavids57 notifications@github.com wrote:

The plug-in was working fine and then started throwing a getName error as indicated in Error after I activated an Hesperus automation using the output from the plug-in. I deactivated the automation but the problem persisted. As you can see in the accessory configuration, "name" is defined. I tried configuring a getter URL, "getName" to no avail.

Error [4/20/2020, 4:22:17 PM] [Pool Level Sensor] getName getter function returned with data: undefined [4/20/2020, 4:22:17 PM] [Pool Level Sensor] updating Name with value [4/20/2020, 4:22:17 PM] TypeError: Cannot read property 'url' of undefined at HttpAdvancedAccessory. (/usr/lib/node_modules/homebridge-http-advanced-accessory/index.js:208:68) at HttpAdvancedAccessory.getter (/usr/lib/node_modules/homebridge-http-advanced-accessory/index.js:371:7) at Characteristic.Name.emit (events.js:311:20) at Characteristic.Name.Characteristic.getValue (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Characteristic.js:164:10) at Bridge. (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:771:20) at Array.forEach () at Bridge.Accessory._handleGetCharacteristics (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:735:8) at HAPServer.emit (events.js:311:20) at HAPServer._handleCharacteristics (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:928:10) at HAPServer. (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:209:39)

Accessory Configuration "accessories": [ { "accessory": "HttpAdvancedAccessory", "service": "ContactSensor", "name": "Pool Level Sensor", "polling": false, "forceRefreshDelay": 0, "debug": true, "urls": { "getContactSensorState": { "url": "http://192.168.1.143/cmd?params=1", "mappers": [ { "type": "jpath", "parameters": { "jpath": "$.return_value" } } ] }, "getName": { "url": "http://192.168.1.143/", "mappers": [ { "type": "jpath", "parameters": { "jpath": "$.name" } } ] } } } ]

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/staromeste/homebridge-http-advanced-accessory/issues/20, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBP2MMH5R6FKMLLZRLALEDRNS56PANCNFSM4MMZHBRA .

gdavids57 commented 4 years ago

I set the forceRefreshDelay to five and debug and polling to false. I also left the getName emitter in the configuration. Now the plug-in works. I'm still not certain why I need to configure a getName emitter when the plug-in already has a "name" attribute.