andrei-tatar / node-red-contrib-nora

Node Red Google Home integration
74 stars 25 forks source link

Thermostat nodes not working anymore after upgrade to v0.0.34 #64

Closed GravityRZ closed 4 years ago

GravityRZ commented 4 years ago

hello, i just upgrade to v 0.0.34

now i get this error on al my thermostat devices i suspect this was always part of the complete msg.payload but was ignored in the past. now it seems to generate an error

Error: Invalid property msg.payload.Battery with value 100

this is what i have in my functionnode which i feed into the thermostat node

temperature = msg.payload.svalue1;
humidity = msg.payload.svalue2;
setpoint = 21.5;
mode = "heat";
msg.payload.temperature = temperature;
msg.payload.setpoint = setpoint;
msg.payload.humidity = humidity;
msg.payload.mode = mode;

if i delete msg.payload.Battery it is giving errors on the next payload. whatever i do it keeps on giving error messages, also on the payloads it should receive like msg.payload.humidity

the temp is fixd on 25 degrees celcius and will not accept the payload example of one of my devices

"b000aaa9.0da8d8": {
        "type": "thermostat",
        "name": "Temperatuur tuin",
        "roomHint": "Tuin",
        "availableModes": [
          "off"
        ],
        "temperatureUnit": "C",
        "state": {
          "online": true,
          "thermostatMode": "off",
          "thermostatTemperatureAmbient": 25,
          "thermostatTemperatureSetpoint": 20,
          "thermostatTemperatureSetpointLow": 20,
          "thermostatTemperatureSetpointHigh": 30
        },
GravityRZ commented 4 years ago

i fixed it by changing the payload to this apparently the acceptable json formatted string changed in 0.0.34

temperature = msg.payload.svalue1;
humidity = msg.payload.svalue2;
setpoint = 21.5;
mode = "heat";
msg.payload = {"mode":"heat",
 "setpoint":setpoint,
 "setpointLow":20,
 "setpointHigh":25,
 "humidity":humidity,
 "temperature": temperature}
Wireheadbe commented 4 years ago

I tried the exact same thing above, and I still get the error. How should it be done?

GravityRZ commented 4 years ago

i also had problems once in a while. when i tried it with fixed numbers the problem was gone. i rounded the humidity and now it seems to work. hopefully this will fix things on your end because it took me a while to fix it on my end.

setpoint = 21; humidity = Math.round(msg.payload.svalue2); temperature = msg.payload.svalue1; msg.payload = {"mode":"heat", "setpoint":setpoint, "setpointLow":20, "setpointHigh":25, "humidity":humidity, "temperature": temperature};

Wireheadbe commented 4 years ago

Yes, have it working now as well, using:

temperature = msg.payload.svalue1;
humidity = msg.payload.svalue2;
msg.topic = msg.payload.idx
msg.payload = {
    "mode":"off",
    "temperature":Number(temperature).toFixed(1),
    "humidity":Number(humidity)}
return msg;
GravityRZ commented 4 years ago

nice. looks like a better solution