staromeste/homebridge-http-advanced-accessory

getName returns "undefined" value

Opened this issue · 2 comments

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"
}
}
]
}
}
}
]

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.