-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Cannot read property 'room_id' of undefined #12
Comments
maxcube-cli uses this repository as a dependency for all communication with the maxcube (as does node-red-contrib-maxcube), so it's strange that it does work with the cli. Could you try executing maxCube.flushDeviceCache() prior to setting the temperature? What's the result of MaxCube.getDevices() after flushDeviceCache function is finished? Perhaps the duty cycle is full (due to extended testing) and the device states aren't correctly retrieved. |
So, long story short, I got it working with Node-RED and then updated and it broke again. I got it working by first making sure I sent real JSON (my bad) and not an escaped string and then I added: Then it stopped working when I was fiddling with retrieving device data, before I saw you had made the same effort in your updated maxcube-node. I'm pretty lost right now, and have run out of things to try to get it to work. I did try your maxCube.flushDeviceCache() but it didn't resolve anything. |
Could you patch you code with following diff? It should print errors while setting the temperature, and print duty cycle info when status of devices is collected. diff --git a/maxcube.js b/maxcube.js
index 33aca86..c27fdac 100755
--- a/maxcube.js
+++ b/maxcube.js
@@ -28,6 +28,8 @@ module.exports = function(RED) {
} else {
node.log('Error setting temperature');
}
+ }).catch(function(e) {
+ node.warn(e);
});
});
}
@@ -54,6 +56,7 @@ module.exports = function(RED) {
});
node.on('input', function(msg) {
+ node.log(JSON.stringify(node.maxCube.getCommStatus()));
node.maxCube.getDeviceStatus().then(function (payload) {
// send devices statuses as separate messages
node.send([payload.map(function function_name(deviceStatus) { return { rf_address: deviceStatus.rf_address, payload: deviceStatus }; })]); In regards to duty cycle:
It only affects communication between the Max Cube and the connected devices (thermostats etc.). You can see its current value in the cli with commands 'status' or 'comm' (remember to quit node-red, because only one connection to the Max Cube is allowed..). |
I also get the "TypeError: Cannot read property 'room_id' of undefined" on my install (Node Red 0.15.2 on a Raspberry Pi 2 under Fedora 24, newest nodered-contrib-maxcube). I will install the cli tool next to see if I can get some more details. |
I wonder if this is related to issue13 . |
@troelssiggaard, could you check if b33969d fixes this issue? |
Confirmed fixed :-) |
After several hours of debugging I haven't found a solution to the problem:
"
TypeError: Cannot read property 'room_id' of undefined
" when setTemperature() is called in the maxcube.js file.It seems like the deviceCache is not working, or that some information is not stored.
The error is due to the
this.deviceCache[rf_address].room_id
object doesn't contain any data, found in line 134 of maxcube.js.I've been trying to use the code both stand alone and with the Node-RED binding (node-red-contrib-maxcube), but neither works. The only code that works is the "maxcube-cli", which sets temperature without errors.
The full error:
The text was updated successfully, but these errors were encountered: