I’m new to this and still fairly vague about the concepts.
My Setup is: a DHT22 measuring Humidity (and Temp) via a python script, and a Water pump whose powerplug is controlled by the humidity level.
The sensor is setup as number items updating by rules via command line (no associated Thing. Is that bad practice? see my setup below).
The Switch for the pump can be controlled manually, and it also works ‘automatically’ if the humidity value is above threshold; the pump turns off.
The Problem is this: when I add that rule, the sensor stops updating and just stays stuck at the last value. What am I doing wrong?
things:
Thing exec:command:aqualight-control "Aqualight Control Command" [command="/home/openhabian/aquabeet/aqualight_switch.sh %2$s", interval=0, timeout=10, autorun=true]
Thing exec:command:aquapump-control "Aquapump Control Command" [command="/home/openhabian/aquabeet/aquapump_switch.sh %2$s", interval=0, timeout=10, autorun=true]
items:
Number tmp_dht22 "DHT22 Temp [%.1f °C]"
Number humidity_dht22 "DHT22 Humidity [%.1f %%]"
Number tmp_cpu "DHT22 CPUTemp [%.1f °C]"
Number volts_pi "DHT22 PiVolts [%.1f V]"
String AqualightSwitch "Aqualight" <light> ["Switchable"] { channel="exec:command:aqualight-control:input", autoupdate="true" }
String AquapumpSwitch "Aquapump" <humidity> ["Switchable"] { channel="exec:command:aquapump-control:input", autoupdate="true" }
rules (working, without the automatic pump control:
rule "DHT22"
when
Time cron "3 */1 * * * ?"
then
val TEMP = executeCommandLine("/home/openhabian/dht22/read_temperature.py", 10000)
Thread::sleep(11000)
if (TEMP.toString().length <= 5) tmp_dht22.postUpdate(TEMP)
Thread::sleep(400)
val HUMID = executeCommandLine("/home/openhabian/dht22/read_humidity.py", 10000)
Thread::sleep(11000)
if (HUMID.toString().length <= 5) humidity_dht22.postUpdate(HUMID)
Thread::sleep(400)
end
The offending pump control rule that ‘stalls’/blocks the sensor from updating, if I delete this the sensor goes back to updating (I add this before the ‘end’ of the previous rule):
if(humidity_dht22.state as DecimalType < 60) AquapumpSwitch.sendCommand("ON")
Thread::sleep(400)
if(humidity_dht22.state as DecimalType > 65) AquapumpSwitch.sendCommand("OFF")
another rule for turning on Light by time works fine:
rule "AutoAquaLighton"
when
Time cron "13 0 7 * * ?"
then
AqualightSwitch.sendCommand("ON")
end
rule "AutoAquaLightoff"
when
Time cron "13 0 20 * * ?"
then
AqualightSwitch.sendCommand("OFF")
end
and this is my sitemap, where I can switch on and off both the pump and the light without problems:
sitemap demo label="My home automation" {
Frame label="Aquabeet" {
Text item=tmp_dht22 label="DHT22 Temp [%.1f °C]"
Text item=humidity_dht22 label="DHT22 Humidity [%.1f %%]"
Switch item=AqualightSwitch mappings=[ "ON"="ON", "OFF"="OFF" ]
Switch item=AquapumpSwitch mappings=[ "ON"="ON", "OFF"="OFF" ]
}
}