- Platform information:
- Hardware: Raspberry Pi 3
- OS: raspbian
- Java Runtime Environment: openjdk 8
- openHAB version: 2.5.0M1
- Issue of the topic: please be detailed explaining your issue
- Please post configurations (if applicable):
- Items configuration related to the issue
Number:Temperature Sensor_Salon_Temperature "Salon Temperature [%.1f %unit%]" <temperature> (gPersist, gMonitorLastUpdate) {channel="mqtt:homie300:MQTTBroker:pi:salon#temperature"}
Number:Temperature Sensor_Garden_Temperature "Garden Temperature [%.1f %unit%]" <temperature> (gPersist) {channel="mqtt:homie300:MQTTBroker:pi:ogrodek#temperature"}
Number Sensor_Salon_LastUpdate "Timestamp [%d]" <clock>
Number Sensor_Salon_MinutesSinceUpdate "Minutes since update" <clock> (gPersist)
String Sensor_Salon_SinceUpdate "Time since update" <clock>
- Rules code related to the issue
rule "LastUpdate"
when
Member of gMonitorLastUpdate received update
then
val time = new DateTimeType()
val namePrefix = triggeringItem.name.toString.substring(0, triggeringItem.name.lastIndexOf('_'))
logInfo("lastUpdate", "Result:" + triggeringItem.name + " | " + namePrefix)
//postUpdate(namePrefix + "_LastUpdate", time.getZonedDateTime.toInstant.toEpochMilli.toString)
end
- If logs where generated please post these here using code fences:
2019-04-06 23:00:14.848 [INFO ] [se.smarthome.model.script.lastUpdate] - Result:Sensor_Salon_Temperature | Sensor_Salon
2019-04-06 23:00:14.854 [INFO ] [se.smarthome.model.script.lastUpdate] - Result:Sensor_Salon_Temperature | Sensor_Salon
2019-04-06 23:00:14.861 [INFO ] [se.smarthome.model.script.lastUpdate] - Result:Sensor_Salon_Temperature | Sensor_Salon
2019-04-06 23:00:14.861 [INFO ] [se.smarthome.model.script.lastUpdate] - Result:Sensor_Salon_Temperature | Sensor_Salon
2019-04-06 23:00:14.875 [INFO ] [se.smarthome.model.script.lastUpdate] - Result:Sensor_Salon_Temperature | Sensor_Salon
2019-04-06 23:00:14.874 [INFO ] [se.smarthome.model.script.lastUpdate] - Result:Sensor_Salon_Temperature | Sensor_Salon
2019-04-06 23:00:14.871 [INFO ] [se.smarthome.model.script.lastUpdate] - Result:Sensor_Salon_Temperature | Sensor_Salon
2019-04-06 23:00:14.877 [INFO ] [se.smarthome.model.script.lastUpdate] - Result:Sensor_Salon_Temperature | Sensor_Salon
2019-04-06 23:00:14.887 [INFO ] [se.smarthome.model.script.lastUpdate] - Result:Sensor_Salon_Temperature | Sensor_Salon
Sensors are being updated using a script that is run from cron:
*/2 5-22 * * * /home/pi/sensors.sh
sensors.sh:
#!/bin/sh
MOS_IP=pi
OGRODEK=$(cat /sys/bus/w1/devices/28-0000035a5030/w1_slave | awk -F= '/ t=/ {print $NF/1000.0}')
mosquitto_pub -h $MOS_IP -r -t homie/pi/ogrodek/temperature -m "$OGRODEK"
echo $(date +%Y-%m-%dT%H:%M:%S) $OGRODEK >> /tmp/temp-ogrodek-$(date +%Y-%m-%d).txt
SALON=$(cat /sys/bus/w1/devices/28-000003bb3a34/w1_slave | awk -F= '/ t=/ {print $NF/1000.0}')
echo $(date +%Y-%m-%dT%H:%M:%S) $SALON >> /tmp/tempi-salon-$(date +%Y-%m-%d).txt
mosquitto_pub -h $MOS_IP -r -t homie/pi/salon/temperature -m "$SALON"
(the rest of homie is in sensors-schema.sh:
MOS_IP=pi
mosquitto_pub -h $MOS_IP -r -t 'homie/pi/$homie' -m "3.0"
mosquitto_pub -h $MOS_IP -r -t 'homie/pi/$name' -m "Raspberry PI w salonie"
mosquitto_pub -h $MOS_IP -r -t 'homie/pi/$state' -m "ready"
mosquitto_pub -h $MOS_IP -r -t 'homie/pi/$extensions' -m ""
mosquitto_pub -h $MOS_IP -r -t 'homie/pi/$nodes' -m "ogrodek,salon"
mosquitto_pub -h $MOS_IP -r -t 'homie/pi/ogrodek/temperature/$name' -m "Temperatura"
mosquitto_pub -h $MOS_IP -r -t 'homie/pi/ogrodek/temperature/$unit' -m "°C"
mosquitto_pub -h $MOS_IP -r -t 'homie/pi/ogrodek/temperature/$datatype' -m "float"
mosquitto_pub -h $MOS_IP -r -t 'homie/pi/ogrodek/$name' -m "Ogrodek"
mosquitto_pub -h $MOS_IP -r -t 'homie/pi/ogrodek/$properties' -m "temperature"
mosquitto_pub -h $MOS_IP -r -t 'homie/pi/salon/temperature/$name' -m "Temperatura"
mosquitto_pub -h $MOS_IP -r -t 'homie/pi/salon/temperature/$unit' -m "°C"
mosquitto_pub -h $MOS_IP -r -t 'homie/pi/salon/temperature/$datatype' -m "float"
mosquitto_pub -h $MOS_IP -r -t 'homie/pi/salon/$name' -m "Salon"
mosquitto_pub -h $MOS_IP -r -t 'homie/pi/salon/$properties' -m "temperature"
)
The issue is that the rule is run 247 times per second for that sensor, but the sensors.sh file is executed only once per 2 minutes.
I have two other items marked with the group that is run in the rule, and one of them is executed correctly only once, and the second one is executed 4 times per each update.
Why this might happen? Do I have somewhere a bug or is it a bug in 2.5.0M1? Why one item is being updated correctly only once?
And BTW. why I don’t see the value of the updated items in Control on Paper UI (when I uncomment postUpdate)?