Closed jonferreira closed 8 years ago
Need full JSON output for the device from http://ipaddress:8080/json.htm?type=devices&rid=[IDX] with the device in all it's possible states (i.e.: one JSON output with it locked, another with it unlocked).
Replace [IDX] with the idx number for the lock device as per Domoticz' Settings > Devices page.
Closed
{
"ActTime" : 1471877582,
"ServerTime" : "2016-08-22 15:53:02",
"Sunrise" : "06:57",
"Sunset" : "20:20",
"result" : [
{
"AddjMulti" : 1.0,
"AddjMulti2" : 1.0,
"AddjValue" : 0.0,
"AddjValue2" : 0.0,
"BatteryLevel" : 255,
"CustomImage" : 0,
"Data" : "Closed",
"Description" : "",
"Favorite" : 0,
"HardwareID" : 15,
"HardwareName" : "Dummy",
"HardwareType" : "Dummy (Does nothing, use for virtual switches only)",
"HardwareTypeVal" : 15,
"HaveDimmer" : true,
"HaveGroupCmd" : true,
"HaveTimeout" : false,
"ID" : "00014108",
"Image" : "Light",
"InternalState" : "Closed",
"IsSubDevice" : false,
"LastUpdate" : "2016-08-22 13:10:16",
"Level" : 0,
"LevelInt" : 0,
"MaxDimLevel" : 100,
"Name" : "Garage Gate",
"Notifications" : "false",
"PlanID" : "4",
"PlanIDs" : [ 4 ],
"Protected" : false,
"ShowNotifications" : true,
"SignalLevel" : "-",
"Status" : "Closed",
"StrParam1" : "",
"StrParam2" : "",
"SubType" : "Switch",
"SwitchType" : "Door Lock",
"SwitchTypeVal" : 11,
"Timers" : "false",
"Type" : "Light/Switch",
"TypeImg" : "door",
"Unit" : 1,
"Used" : 1,
"UsedByCamera" : false,
"XOffset" : "0",
"YOffset" : "0",
"idx" : "185"
}
],
"status" : "OK",
"title" : "Devices"
}
Opened
{
"ActTime" : 1471877623,
"ServerTime" : "2016-08-22 15:53:43",
"Sunrise" : "06:57",
"Sunset" : "20:20",
"result" : [
{
"AddjMulti" : 1.0,
"AddjMulti2" : 1.0,
"AddjValue" : 0.0,
"AddjValue2" : 0.0,
"BatteryLevel" : 255,
"CustomImage" : 0,
"Data" : "Open",
"Description" : "",
"Favorite" : 0,
"HardwareID" : 15,
"HardwareName" : "Dummy",
"HardwareType" : "Dummy (Does nothing, use for virtual switches only)",
"HardwareTypeVal" : 15,
"HaveDimmer" : true,
"HaveGroupCmd" : true,
"HaveTimeout" : false,
"ID" : "00014108",
"Image" : "Light",
"InternalState" : "Open",
"IsSubDevice" : false,
"LastUpdate" : "2016-08-22 15:53:38",
"Level" : 0,
"LevelInt" : 0,
"MaxDimLevel" : 100,
"Name" : "Garage Gate",
"Notifications" : "false",
"PlanID" : "4",
"PlanIDs" : [ 4 ],
"Protected" : false,
"ShowNotifications" : true,
"SignalLevel" : "-",
"Status" : "Open",
"StrParam1" : "",
"StrParam2" : "",
"SubType" : "Switch",
"SwitchType" : "Door Lock",
"SwitchTypeVal" : 11,
"Timers" : "false",
"Type" : "Light/Switch",
"TypeImg" : "door",
"Unit" : 1,
"Used" : 1,
"UsedByCamera" : false,
"XOffset" : "0",
"YOffset" : "0",
"idx" : "185"
}
],
"status" : "OK",
"title" : "Devices"
}
Ta!
I'm happy to help anyway I can although I'm a bit lost with Apple documentation
I can see there's a Door Lock and Garage Opened "category" but no idea what characteristics each one have - https://developer.apple.com/reference/homekit/hmaccessorycategory/2315143-accessory_category_types
Service.LockMechanism... https://github.com/KhaosT/HAP-NodeJS/blob/master/lib/gen/HomeKitTypes.js#L2131
Service.GarageDoorOpener... https://github.com/KhaosT/HAP-NodeJS/blob/master/lib/gen/HomeKitTypes.js#L1996
Note the required characteristics of the Garage Door Opener (obstruction and door position states, separate to lock states, which are optional). These aren't all provided by Domoticz so more likely I'll just set it up as a LockMechanism, which only needs current & target state.
yeah that's all that's "needed" I reckon
happy to test it once you have the time to look at it ;-)
Added to the mqtt-integration branch (https://github.com/PatchworkBoy/homebridge-eDomoticz/tree/mqtt-integration)
If you need to switch to that branch from Master, see instructions on forum at https://www.domoticz.com/forum/viewtopic.php?f=36&t=10272&start=560#p93815
You can skip setting up MQTT etc and run it as the non-MQTT version by setting mqttdisable=0 in config.json
Feedback once you’ve tested it please!
Well I've followed instructions but did not seen any difference, still being shown as an On/Off Switch.
Maybe I missed something on the instructions to change from Master branch?
Will re-do and update in a bit
Just head back into the folder and run sudo git pull origin
again as I’ve just corrected a typo or two... then repeat the two rm - rf commands to empty accessories and persist, then restart homebridge.
(You can tell if you’re on the MQTT-integration branch by the presence of a lib/ folder within your homebridge-edomoticz folder - the non-MQTT version does NOT have this folder... also running head CHANGELOG
should state v2.2 in top right above logo rather than v2.1)
well I'm getting a "fatal: Not a git repository (or any of the parent directories): .git" error even though I have the .git/config file as expected
Sorry - I’ve also just changed the repo to lower case... just open the .git/config file and change eDomoticz to edomoticz in the git url (have just amended the forum post to reflect this). steps away from keyboard for an hour You should be safe now...!
OK now it did update as expected although something is wrong as my iPhone can no longer find a Homebridge accessory on the network even though the service appears to be running fine
This happens every now and again with HomeKit / homebridge - did it to me the other night. Usually due to a cached sensor’s service type being changed, and home kit gets in a muddle between your devices and iCloud.
On your iOS device, head to Settings > homekit and delete your existing home. Back on your Domoticz device, empty ~/.homebridge/accessories & ~/.homebridge/persist folders (again), then restart homebridge.
It should then let you re-bind to the bridge.
If NOT, then you MAY need to change the username (mac address style) in your homebridge config.json also.
well it did helped, Homebridge now shows as an accessory to be "pair" with but for some reason it seems to hang when I click Add and instead of asking for the code it eventually times out and gets back to the first page. the homebridge then goes missing and I can no longer attempt to pair with it until I clear those folders... I'll change username and report back in a few minutes
OK it finally managed to pair successfully, hurray for that! On the other hand the doorlock is still showing as a Light Switch so clearly I've missed something here, unsure what as I could see the files being updated when I did the git pull origin and npm install
bangs head on desk ...sorry! Found a line of code I must’ve got distracted on, as I never completed the line (line 837 of domoticz_accessory.js)...
One last sudo git pull origin
and restart, and it should come online.
no worries :-)
I got this
pi@raspberrypi:/usr/local/lib/node_modules/homebridge-edomoticz $ sudo git pull origin
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 4 (delta 3), reused 4 (delta 3), pack-reused 0
Unpacking objects: 100% (4/4), done.
From https://github.com/PatchworkBoy/homebridge-edomoticz
d8bd9a1..9740317 mqtt-integration -> origin/mqtt-integration
You asked to pull from the remote 'origin', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.```
sudo git pull origin -b mqtt-integration
(I think)...
failing that just head into homebridge-edomoticz/lib and sudo rm domoticz*
then sudo wget https://raw.githubusercontent.com/PatchworkBoy/homebridge-edomoticz/mqtt-integration/lib/domoticz_accessory.js
to just update that one file.
think the right command would be
pi@raspberrypi:/usr/local/lib/node_modules/homebridge-edomoticz $ sudo git pull origin mqtt-integration From https://github.com/PatchworkBoy/homebridge-edomoticz
* branch mqtt-integration -> FETCH_HEAD
error: Untracked working tree file 'CHANGELOG' would be overwritten by merge.
still not working though so will attempt manual path
Might be easier just to delete the entire homebridge-edomoticz folder, and from within node_modules/ run sudo git clone -b mqtt-integration https://github.com/PatchworkBoy/homebridge-edomoticz.git
then head into it and run sudo npm install
Being a clumsy dev tonight... still working on it, found more issues.
Righty - finally... done. All tested and seems to be working correctly for me here on my virtual switch, so should theoretically work for you also seeing as yours is a virtual switch also.
Do another sudo git pull origin
and restart homebridge, and the lock device should hopefully spring to life.
well I still haven't been able to pair with Homebridge again, think I need a refill :-(
OK I've managed to pair again but it's loosing connection after just a few seconds. Looking at error log I have the following which probably explains it:
Tue, 23 Aug 2016 08:41:32 GMT Accessory [Homebridge] Getting value for Characteristic "Wind Chill"
/usr/local/lib/node_modules/homebridge-edomoticz/lib/helper.js:55
var stringval = value.toString();
^
TypeError: Cannot read property 'toString' of undefined
at Function.Helper.cleanFloat (/usr/local/lib/node_modules/homebridge-edomoticz/lib/helper.js:55:25)
at Object.<anonymous> (/usr/local/lib/node_modules/homebridge-edomoticz/lib/domoticz_accessory.js:447:22)
at Array.map (native)
at Object.<anonymous> (/usr/local/lib/node_modules/homebridge-edomoticz/lib/domoticz_accessory.js:446:13)
at Request.self.callback (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/request/request.js:198:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/request/request.js:1082:10)
at emitOne (events.js:101:20)
at Request.emit (events.js:188:7)
on a side note I've changed
`var stringval = value.toString();``
to
var stringval = value ? value.toString() : "";
just so that I could test it and it's working great :-)
Cool - have just dropped that change into helper.js... thumbsup
oh dear, another one:
Tue, 23 Aug 2016 14:20:15 GMT EventedHTTPServer [::ffff:192.168.1.113] Sending HTTP event 'keepalive' with data: {"characteristics":[]}
/usr/local/lib/node_modules/homebridge-edomoticz/lib/mqtt.js:40
characteristic.setValue(value, null, "eDomoticz-MQTT");
^
TypeError: Cannot read property 'setValue' of undefined
at /usr/local/lib/node_modules/homebridge-edomoticz/lib/mqtt.js:40:23
at Object.eDomoticzAccessory.handleMQTTMessage (/usr/local/lib/node_modules/homebridge-edomoticz/lib/domoticz_accessory.js:945:8)
at MqttClient.<anonymous> (/usr/local/lib/node_modules/homebridge-edomoticz/lib/mqtt.js:39:17)
at emitThree (events.js:116:13)
at MqttClient.emit (events.js:194:7)
at MqttClient._handlePublish (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/mqtt/lib/client.js:792:12)
at MqttClient._handlePacket (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/mqtt/lib/client.js:282:12)
at process (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/mqtt/lib/client.js:238:12)
at Writable.writable._write (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/mqtt/lib/client.js:248:5)
at doWrite (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/readable-stream/lib/_stream_writable.js:237:10)
at writeOrBuffer (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/readable-stream/lib/_stream_writable.js:227:5)
at Writable.write (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/readable-stream/lib/_stream_writable.js:194:11)
Need more of the log really to work out what service / characteristic is failing... one of your devicetypes is returning 'null' for the characteristic instance.
that's the last 15 mins before the error:
Tue, 23 Aug 2016 13:46:44 GMT EventedHTTPServer [::ffff:192.168.1.113] New connection from client
Tue, 23 Aug 2016 13:46:44 GMT EventedHTTPServer [::ffff:192.168.1.113] HTTP server listening on port 36626
Tue, 23 Aug 2016 13:46:45 GMT EventedHTTPServer [::ffff:192.168.1.113] HTTP request: /pair-verify
Tue, 23 Aug 2016 13:46:45 GMT HAPServer [CC:21:3E:E4:DE:36] HAP Request: POST /pair-verify
Tue, 23 Aug 2016 13:46:45 GMT HAPServer [CC:21:3E:E4:DE:36] Pair verify step 1/2
Tue, 23 Aug 2016 13:46:45 GMT EventedHTTPServer [::ffff:192.168.1.113] HTTP Response is finished
Tue, 23 Aug 2016 13:46:45 GMT EventedHTTPServer [::ffff:192.168.1.113] HTTP request: /pair-verify
Tue, 23 Aug 2016 13:46:45 GMT HAPServer [CC:21:3E:E4:DE:36] HAP Request: POST /pair-verify
Tue, 23 Aug 2016 13:46:45 GMT HAPServer [CC:21:3E:E4:DE:36] Pair verify step 2/2
Tue, 23 Aug 2016 13:46:45 GMT HAPServer [CC:21:3E:E4:DE:36] Client 6FB62A48-246E-4A6C-9299-FF67067F576F verification complete
Tue, 23 Aug 2016 13:46:45 GMT EventedHTTPServer [::ffff:192.168.1.113] HTTP Response is finished
Tue, 23 Aug 2016 13:46:45 GMT EventedHTTPServer [::ffff:192.168.1.113] HTTP request: /accessories
Tue, 23 Aug 2016 13:46:45 GMT HAPServer [CC:21:3E:E4:DE:36] HAP Request: GET /accessories
Tue, 23 Aug 2016 13:46:45 GMT EventedHTTPServer [::ffff:192.168.1.113] HTTP Response is finished
Tue, 23 Aug 2016 13:46:47 GMT EventedHTTPServer [::ffff:192.168.1.113] HTTP request: /characteristics
Tue, 23 Aug 2016 13:46:47 GMT HAPServer [CC:21:3E:E4:DE:36] HAP Request: PUT /characteristics
Tue, 23 Aug 2016 13:46:47 GMT Accessory [Homebridge] Processing characteristic set: [{"aid":17,"iid":9,"ev":true},{"aid":17,"iid":10,"ev":true}]
Tue, 23 Aug 2016 13:46:47 GMT Accessory [Homebridge] Registering Characteristic "Lock Current State" for events
Tue, 23 Aug 2016 13:46:47 GMT Accessory [Homebridge] Registering Characteristic "Lock Target State" for events
Tue, 23 Aug 2016 13:46:47 GMT EventedHTTPServer [::ffff:192.168.1.113] HTTP Response is finished
Tue, 23 Aug 2016 13:50:15 GMT EventedHTTPServer [2001:8a0:fa4d:bc01:14c1:31a3:8694:5908] Sending HTTP event 'keepalive' with data: {"characteristics":[]}
Tue, 23 Aug 2016 13:50:15 GMT EventedHTTPServer [::ffff:192.168.1.113] Sending HTTP event 'keepalive' with data: {"characteristics":[]}
Tue, 23 Aug 2016 13:54:51 GMT EventedHTTPServer [::ffff:192.168.1.113] Client connection closed
Tue, 23 Aug 2016 13:54:51 GMT EventedHTTPServer [::ffff:192.168.1.113] HTTP connection was closed
Tue, 23 Aug 2016 13:54:51 GMT EventedHTTPServer [::ffff:192.168.1.113] HTTP server was closed
Tue, 23 Aug 2016 13:57:25 GMT EventedHTTPServer [::ffff:192.168.1.113] New connection from client
Tue, 23 Aug 2016 13:57:25 GMT EventedHTTPServer [::ffff:192.168.1.113] HTTP server listening on port 38675
Tue, 23 Aug 2016 13:57:25 GMT EventedHTTPServer [::ffff:192.168.1.113] HTTP request: /pair-verify
Tue, 23 Aug 2016 13:57:25 GMT HAPServer [CC:21:3E:E4:DE:36] HAP Request: POST /pair-verify
Tue, 23 Aug 2016 13:57:25 GMT HAPServer [CC:21:3E:E4:DE:36] Pair verify step 1/2
Tue, 23 Aug 2016 13:57:25 GMT EventedHTTPServer [::ffff:192.168.1.113] HTTP Response is finished
Tue, 23 Aug 2016 13:57:25 GMT EventedHTTPServer [::ffff:192.168.1.113] HTTP request: /pair-verify
Tue, 23 Aug 2016 13:57:25 GMT HAPServer [CC:21:3E:E4:DE:36] HAP Request: POST /pair-verify
Tue, 23 Aug 2016 13:57:25 GMT HAPServer [CC:21:3E:E4:DE:36] Pair verify step 2/2
Tue, 23 Aug 2016 13:57:25 GMT HAPServer [CC:21:3E:E4:DE:36] Client 6FB62A48-246E-4A6C-9299-FF67067F576F verification complete
Tue, 23 Aug 2016 13:57:25 GMT EventedHTTPServer [::ffff:192.168.1.113] HTTP Response is finished
Tue, 23 Aug 2016 13:57:25 GMT EventedHTTPServer [::ffff:192.168.1.113] HTTP request: /accessories
Tue, 23 Aug 2016 13:57:25 GMT HAPServer [CC:21:3E:E4:DE:36] HAP Request: GET /accessories
Tue, 23 Aug 2016 13:57:26 GMT EventedHTTPServer [::ffff:192.168.1.113] HTTP Response is finished
Tue, 23 Aug 2016 13:57:28 GMT EventedHTTPServer [::ffff:192.168.1.113] HTTP request: /characteristics
Tue, 23 Aug 2016 13:57:28 GMT HAPServer [CC:21:3E:E4:DE:36] HAP Request: PUT /characteristics
Tue, 23 Aug 2016 13:57:28 GMT Accessory [Homebridge] Processing characteristic set: [{"aid":17,"iid":9,"ev":true},{"aid":17,"iid":10,"ev":true}]
Tue, 23 Aug 2016 13:57:28 GMT Accessory [Homebridge] Registering Characteristic "Lock Current State" for events
Tue, 23 Aug 2016 13:57:28 GMT Accessory [Homebridge] Registering Characteristic "Lock Target State" for events
Tue, 23 Aug 2016 13:57:28 GMT EventedHTTPServer [::ffff:192.168.1.113] HTTP Response is finished
Tue, 23 Aug 2016 14:00:15 GMT EventedHTTPServer [2001:8a0:fa4d:bc01:14c1:31a3:8694:5908] Sending HTTP event 'keepalive' with data: {"characteristics":[]}
Tue, 23 Aug 2016 14:00:15 GMT EventedHTTPServer [::ffff:192.168.1.113] Sending HTTP event 'keepalive' with data: {"characteristics":[]}
Tue, 23 Aug 2016 14:10:15 GMT EventedHTTPServer [2001:8a0:fa4d:bc01:14c1:31a3:8694:5908] Sending HTTP event 'keepalive' with data: {"characteristics":[]}
Tue, 23 Aug 2016 14:10:15 GMT EventedHTTPServer [::ffff:192.168.1.113] Sending HTTP event 'keepalive' with data: {"characteristics":[]}
Tue, 23 Aug 2016 14:20:15 GMT EventedHTTPServer [2001:8a0:fa4d:bc01:14c1:31a3:8694:5908] Sending HTTP event 'keepalive' with data: {"characteristics":[]}
Tue, 23 Aug 2016 14:20:15 GMT EventedHTTPServer [::ffff:192.168.1.113] Sending HTTP event 'keepalive' with data: {"characteristics":[]}
/usr/local/lib/node_modules/homebridge-edomoticz/lib/mqtt.js:40
characteristic.setValue(value, null, "eDomoticz-MQTT");
^
TypeError: Cannot read property 'setValue' of undefined
at /usr/local/lib/node_modules/homebridge-edomoticz/lib/mqtt.js:40:23
at Object.eDomoticzAccessory.handleMQTTMessage (/usr/local/lib/node_modules/homebridge-edomoticz/lib/domoticz_accessory.js:945:8)
at MqttClient.<anonymous> (/usr/local/lib/node_modules/homebridge-edomoticz/lib/mqtt.js:39:17)
at emitThree (events.js:116:13)
at MqttClient.emit (events.js:194:7)
at MqttClient._handlePublish (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/mqtt/lib/client.js:792:12)
at MqttClient._handlePacket (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/mqtt/lib/client.js:282:12)
at process (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/mqtt/lib/client.js:238:12)
at Writable.writable._write (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/mqtt/lib/client.js:248:5)
at doWrite (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/readable-stream/lib/_stream_writable.js:237:10)
at writeOrBuffer (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/readable-stream/lib/_stream_writable.js:227:5)
at Writable.write (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/readable-stream/lib/_stream_writable.js:194:11)
On close inspection, you've got an incoming mqtt message for a sensor that it can't map to a characteristic - Need the MQTT message that triggers it.
If you run homeBridge directly from CLI with DEBUG=* homebridge -D
it should show the FULL logs with all incoming messages.
hmm so I reckon I'll need to change my autostart service to run in debug mode and just wait till it happens, there's dozens of MQTT messages every minute
Yep - I have similar problems - 60+ sensors...
OK changed to
dir="/home/pi"
cmd="DEBUG=* /usr/local/bin/homebridge -D"
user="pi"
let's see what happens
Again but same amount of information...this won't be easy to diagnose I reckon
Tue, 23 Aug 2016 17:14:36 GMT EventedHTTPServer [::ffff:192.168.1.119] Sending HTTP event 'keepalive' with data: {"characteristics":[]}
Tue, 23 Aug 2016 17:14:36 GMT EventedHTTPServer [::ffff:192.168.1.113] Sending HTTP event 'keepalive' with data: {"characteristics":[]}
/usr/local/lib/node_modules/homebridge-edomoticz/lib/mqtt.js:40
characteristic.setValue(value, null, "eDomoticz-MQTT");
^
TypeError: Cannot read property 'setValue' of undefined
at /usr/local/lib/node_modules/homebridge-edomoticz/lib/mqtt.js:40:23
at Object.eDomoticzAccessory.handleMQTTMessage (/usr/local/lib/node_modules/homebridge-edomoticz/lib/domoticz_accessory.js:945:8)
at MqttClient.<anonymous> (/usr/local/lib/node_modules/homebridge-edomoticz/lib/mqtt.js:39:17)
at emitThree (events.js:116:13)
at MqttClient.emit (events.js:194:7)
at MqttClient._handlePublish (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/mqtt/lib/client.js:792:12)
at MqttClient._handlePacket (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/mqtt/lib/client.js:282:12)
at process (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/mqtt/lib/client.js:238:12)
at Writable.writable._write (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/mqtt/lib/client.js:248:5)
at doWrite (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/readable-stream/lib/_stream_writable.js:237:10)
at writeOrBuffer (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/readable-stream/lib/_stream_writable.js:227:5)
at Writable.write (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/readable-stream/lib/_stream_writable.js:194:11)
any chance you can make it log the MQTT message before being processed, therefore making a record of what message is causing this?
copy line 45 of mqtt.js and paste at line 38... platform.log(message);
(Personally I use node-red with an mqtt input to json parser to debug node flow for debugging mqtt issues - handy to have)
yeah I'm using node-red for all logic etc but did not noticed anything out of the ordinary...
I did the necessary changes, now to wait till it happens again
Set Node-Red to write the output to a text file, injecting timestamp... then you can cross reference by time.
OK this is driving me nuts. First of all I have the feeling this has nothing to do with my MQTT broker cuz A) there's no mqtt message at the same exact time as the error is thrown and B) cuz it happens exactly in 10 mins interval at the same exact time the keepalive event
Wed, 24 Aug 2016 09:14:31 GMT EventedHTTPServer [::ffff:192.168.1.113] Sending HTTP event 'keepalive' with data: {"characteristics":[]}
looking at the error is the characteristic that is undefined and indeed keepalive event has no characteristics
/usr/local/lib/node_modules/homebridge-edomoticz/lib/mqtt.js:41
characteristic.setValue(value, null, "eDomoticz-MQTT");
^
TypeError: Cannot read property 'setValue' of undefined
what's bugging me is that I've edited the mqtt.js file to log both message and characteristics but I have nothing!
Mqtt.prototype.connect = function(url) {
client = mqtt.connect(url);
client.on('connect', function() {
client.subscribe('domoticz/out');
});
client.on('message', function (topic, buffer) {
var message = JSON.parse(buffer.toString());
if ('undefined' !== typeof message.nvalue || 'undefined' !== typeof message.svalue1) {
var accessory = accessories["idx_" + message.idx];
if (!accessory) {
return;
}
platform.log(accessory);
platform.log(message);
accessory.handleMQTTMessage(message, function(characteristic, value) {
characteristic.setValue(value, null, "eDomoticz-MQTT");
});
} else {
platform.log('[ERR] MQTT message received, but no nvalue or svalue1 was found:');
platform.log(message);
}
});
}
Need a fresh pair of eyes!
Wow, weird! Looks like characteristic
is undefined in the callback. This means handleMQTTMessage
returns an empty characteristic. But if your code gets to handleMQTTMessage
it should also log the incoming message and accessory!
Try console.log
instead of platform.log
for a change.
platform.log
has a check built in. You have probably not enabled debug mode the right way. Doesn't matter. 👍🏼
yeah bizarre really...
my init
dir="/home/pi"
cmd="DEBUG=* /usr/local/bin/homebridge -D"
user="pi"
pretty sure that's correct
either way I've added the following to MQTT.js
Mqtt.prototype.connect = function(url) {
client = mqtt.connect(url);
client.on('connect', function() {
client.subscribe('domoticz/out');
});
client.on('message', function (topic, buffer) {
var message = JSON.parse(buffer.toString());
if ('undefined' !== typeof message.nvalue || 'undefined' !== typeof message.svalue1) {
var accessory = accessories["idx_" + message.idx];
if (!accessory) {
return;
}
//platform.log(accessory);
//platform.log(message);
accessory.handleMQTTMessage(message, function(characteristic, value) {
if('undefined' !== typeof accessory) {
characteristic.setValue(value, null, "eDomoticz-MQTT");
} else {
platform.log('******************************');
platform.log('[ERR] undefined characteristic');
platform.log(accessory);
platform.log(message);
platform.log(value);
platform.log('******************************');
}
});
} else {
platform.log('[ERR] MQTT message received, but no nvalue or svalue1 was found:');
platform.log(message);
}
});
}
this should prevent it for crashing and provide further info
Alright, still weird. I have just committed a few changes I have made, one fixes an incorrect state for the doorlock, the other has your sanity check built in.
Debug looks valid yeah.
haven't got an error in the past 2 hours so clearly the sanity check is doing its thing but bizarre that I don't have any logs! so as it stands it's "fixed" but no idea what was causing it
Yeah, weird! I normally run DEBUG=* homebridge -D
from the console, and not start it through the init.d/ script. But don't know if that's the cause!
I don't think the sanity check is a bad idea either. I mean, it tries to update an undefined characteristic with an undefined value. No harm in dropping those messages. The other characteristics still get updated perfectly.
I have committed everything and should be up on MQTT branch now 👍🏼
thanks
Interesting... Re: the not-here post (looking at email notifications) it was caused by a Temp & Humidity sensor, which should only have 2 characteristics, yet the MQTT msg carried 3x sValues. What does the third value show as / represent in Domoticz??
yeah I removed it as it end up not being related to the original problem
I have no idea what svalue3 holds though, seems to be stuck at "3" for as long as I remember and domoticz doesn't show it anywhere else (Data variable or any other as far as I can see)
Hmmm. Duly noted! Ta!
OK I think I've finally tracked down what was causing the error!
******************************
[8/25/2016, 11:04:17 PM] [eDomoticz] [ERR] undefined characteristic
[8/25/2016, 11:04:17 PM] [eDomoticz] { haveDimmer: false,
services:
[ Service {
displayName: undefined,
UUID: '0000003E-0000-1000-8000-0026BB765291',
subtype: undefined,
iid: null,
characteristics: [Object],
optionalCharacteristics: [Object] },
Service {
displayName: 'JF Location',
UUID: '259b474a-f1b2-4741-a64e-d8e53ae6b4dc',
subtype: undefined,
iid: 7,
characteristics: [Object],
optionalCharacteristics: [],
_events: [Object],
_eventsCount: 2 } ],
log: [Function],
server: '192.168.1.2',
port: '8080',
IsScene: false,
status: 1,
idx: '258',
name: 'JF Location',
eve: undefined,
subType: 'Text',
swType: undefined,
swTypeVal: false,
isSwitch: false,
Type: 'General',
batteryRef: 255,
CounterToday: 1,
onValue: 'On',
offValue: 'Off',
param: 'switchlight',
access_url: 'http://192.168.1.2:8080/json.htm?',
control_url: 'http://192.168.1.2:8080/json.htm?type=command¶m=switchlight&idx=258',
status_url: 'http://192.168.1.2:8080/json.htm?type=devices&rid=258',
requestHeaders: {} }
[8/25/2016, 11:04:17 PM] [eDomoticz] { Battery: 255,
RSSI: 12,
dtype: 'General',
id: '00082257',
idx: 258,
name: 'JF Location',
nvalue: 0,
stype: 'Text',
svalue1: '<iframe width="365" height="300" frameborder="0" style="border:0" src="https://www.google.com/maps/embed/v1/place?key=AIzaSyDJEFKMCqoOUnG4vf1KzI6W0ZNWFV1D0rk&maptype=satellite&q=xxx" allowfullscreen></iframe>',
unit: 1 }
[8/25/2016, 11:04:17 PM] [eDomoticz] <iframe width="365" height="300" frameborder="0" style="border:0" src="https://www.google.com/maps/embed/v1/place?key=AIzaSyDJEFKMCqoOUnG4vf1KzI6W0ZNWFV1D0rk&maptype=satellite&q=xxx" allowfullscreen></iframe>
[8/25/2016, 11:04:17 PM] [eDomoticz] ******************************
It's a dummy device that I use to start text, in this case a google maps with GPS coordenates
Fantastic work so far, congrats!
Any chance we can get proper "lock" support?
"SubType" : "Switch", "SwitchType" : "Door Lock", "SwitchTypeVal" : 11,
This was I could tell Siri to "lock/unlock Garage Gate" instead of "Turn On/Off Garage Gate" if that makes sense