Hi all,
I earlier introduced my Display Node to present data from other nodes in.
Now I run into the issue where a boolean value sent to this node by using a Pimatic rule not seems te be evaluated as a boolean.
The rule I use where ‘$weerstation.Regen’ is a boolean value
{
"id": "zend-weerstation-regen-naar-display",
"name": "Zend weerstation regen naar display",
"rule": "when $weerstation.Regen gets updated then send custom \"V_VAR1\" nodeid: \"100\" sensorid: \"5\" cmdcode: \"$weerstation.Regen\"",
"active": true,
"logging": true
}
On the serial monitor of the Display node I see the data being received, where ‘rain’ in the second line is a debug message for me to see the sensor is evaluated by the Display node and ‘0’ in the third line is the evaluated value (tried both message.GetUInt() and message.GetBool():
11956 TSF:MSG:SEND,100-100-0-0,s=5,c=1,t=24,pt=0,l=4,sg=0,ft=0,st=OK:true
rain
0
So the value ‘true’ is evaluated as 0 and also in a test case where a ‘false’ was sent the evaluated value was ‘0’.
Below the code in the ‘receive’ function, where case 5 is for evaluating the boolean Rain value:
void receive(const MyMessage &message)
{
// Explore message
switch (message.sensor)
{
case 0: // Humidity sensor
{
recHumidity = message.getFloat();
break;
}
case 1: // Temperature sensor
{
recTemperature = message.getFloat();
break;
}
case 2: // Light sensor
{
recLight = message.getUInt();
break;
}
case 3: // Barometer sensor
{
recPressure = message.getFloat();
break;
}
case 4: // Barometer Temperature sensor
{
break;
}
case 5: // Rain sensor
{
//recRain = message.getBool();
recRain = message.getUInt();
Serial.println("rain");
Serial.println(recRain);
break;
}
case 6: // Battery
{
recBattery = message.getUInt();
break;
}
}
}
I guess the sent ‘true’ message by the rule is not recognized as boolean. Of course I defined ‘recRain’ as bool or int in relevant cases.
What am I doing wrong?