Temperature Sensor comparison not working

Hello,

I’m new to openhab and I got my RaspberryMatic and the two Homematicsensors working…so far.
Now I’m trying to get a notification on my Openhab App for iOS for temperature changes.

  • Platform information:
    • Hardware: RaspberryPi 4 4 GB
    • OS: Ubuntu Server arm64
    • Java Runtime Environment: OpenJDK 11
    • openHAB version: 3.1.0
  • Issue of the topic: Can’t get my rule working
  • Please post configurations (if applicable):
    • item: Aussentemperatur (Number), direct Parent Group Temperatursensoren
      My Rule Code:
rule "Draußen kaelter als drinnen"
when
        Item Aussentemperatur changed
then
        var Temp = Aussentemperatur.state as Number
        if(Temp < 14.3 && Temp.previousState().state >= 14.3) {
                sendBroadcastNotification("Draussen sind es " + Temp.format("%.1f") + " °C")
        }
end

The rule is fine i guess:

2021-09-11 23:09:22.478 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘draussen_kaelter_als_drinnen.rules’

I tried also to put loginfo in then as first thing to do, but its not logging either, so I can’t check what the output of Temp is.
What am I doing wrong?

That would be a really narrow opportunity to be true

1 Like

Actually the temeprature drop ist very slow in the evening or night. It takes around 10-20 minutes for the temperature to drop from eg. 14.3 to 14.2.
In this exact moment my rule should trigger and tell me via push “Draussen sind es 14.2 °C”.
But it doesn’t.
It doens’t even log anything and I don’t understand why.
Or would you suggest to work with full numbers only? (without at dot)
But my sensors are always sending xx.xx (14.20), if I change my rule to

if(Temp < 15 && Temp.previousState().state >= 15) {

It wouldn’t change anything. And

if(Temp < 14 && Temp.previousState().state >= 15) {

wouldn’t trigger I guess.

I think I need to start to get the logging working first, so I could check what Temp’s actual value is.
Any hints?

Well, you’ve not shown us how you are trying to log anything.

You can see changes in your events.log.
You should be aware that even if you have created your Item as a plain Number type it may be getting updated with a Quantity with units, depending what kind of channel/device you linked it to.

Oh…i tried these:

logDebug("Aussentemperatur", "state" + Aussemtemperatur.state)
logInfo("Aussentemperatur","state" + Aussemtemperatur.state)
var Temp = Aussentemperatur.state as Number
logDebug("Aussentemperatur", "state" + Temp)
logInfo("Aussentemperatur","state" + Temp)

My item is part of an itemgroup, defined this way:

Group   Temperatursensoren      " [%.1f]"
Group   Feuchtigkeitssensoren

Number  Temperatur_Balkon       "Aussentemperatur [%.1f °C]"    <temperature>   (Temperatursensoren)    {channel="homematic:HmIP-STHO:3014F711A061A7DBE9975604:000EDD898A625E:1#ACTUAL_TEMPERATURE"}
Number  Temperatur_Wohnzimmer   "Innentemperatur [%.1f °C]"     <temperature>   (Temperatursensoren)    {channel="homematic:HmIP-STH:3014F711A061A7DBE9975604:000E5D898E9A75:1#ACTUAL_TEMPERATURE"}

Number  Luftfeuchtigkeit_Balkon "Aussenfeuchtigkeit [%.1f %%]"  <humidity>      (Feuchtigkeitssensoren) {channel="homematic:HmIP-STHO:3014F711A061A7DBE9975604:000EDD898A625E:1#HUMIDITY"}
Number  Luftfeuchtigkeit_Wohnzimmer  "Innenfeuchtigkeit [%.1f %%]"    <humidity>      (Feuchtigkeitssensoren) {channel="homematic:HmIP-STH:3014F711A061A7DBE9975604:000E5D898E9A75:1#HUMIDITY"}

Do you need any more information?
The logs i check are the
/var/log/openhab/openhab.log
and
/var/log/openhab/events.log

I can see that the sensors are sending updates, but I can’t see my own logging from rule.

2021-09-12 00:13:02.649 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘Temperatur_Balkon’ changed from 13.20 to 13.10
2021-09-12 00:13:16.581 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘Temperatur_Wohnzimmer’ changed from 24.30 to 24.20

oh wait…

Nevermind…I guess its simply too late.
No surprise that my rule is not working, when the trigger isnt working beacuse the item Aussemtemperatur is not changing at all. Its the Temperatur_Balkon which is changing. I kind of missed that.
I’ll try with this and i think I can get it working now.
Thanks for making me look very closely at my stuff :slight_smile:

Hello,

Thanks for posting, looking for same issue and i found lots of helpful information here, really helpful and thankful My Balance Now.

First increase the counter “counter++>10000” to something much larger, It could be that the new processor you are running increments the counter at a much faster rate and you just timeout before the pin drops.

If that doesn’t work remove the timeout counter and loop forever in your source, also remove the sensor, then physically pull the data line to ground with a piece of wire and see if your code/new processor catches the signal change, at least then you know your source/hardware is configured correctly so you can focus your efforts elsewhere.