My plan is use Openhab to control values and use Sonoff TH as a thermostat.
At Sonoff switch I used Dummy device as a sensor(dht#temp).
Here is the Rules code that I'm working on:
Code: Select all
on highThreshold do
if [dht#temp]>[thermostat#temp]
gpio,12,0
endif
endon
on lowThreshold do
if [dht#temp]<[thermostat#temp]
gpio,12,1
else
event,highThreshold
endif
endon
on checkThresholds do
if [thermostat#enabled]=1
event,lowThreshold
else
gpio,12,0
endif
endof
on dht.temp do
TaskValueSet 12,1,%eventvalue%
Publish /%sysname%/dht/temp,%eventvalue%
endon
// seems issue start from here, this not work
on dht#temp do
event,checkThresholds
endon
on thermostat.enabled do
Publish /%sysname%/thermostat/enabled,%eventvalue%
TaskValueSet 4,1,%eventvalue%
event,checkThresholds
endon
on thermostat#enabled do
Publish /%sysname%/thermostat/temp,[thermostat#temp]
Publish /%sysname%/thermostat/hysteresis,[thermostat#hysteresis]
endon
on thermostat.temp do
TaskValueSet 4,2,%eventvalue%
Publish /%sysname%/thermostat/temp,%eventvalue%
event,checkThresholds
endon
on thermostat.hysteresis do
TaskValueSet 4,3,%eventvalue%
Publish /%sysname%/thermostat/hysteresis,%eventvalue%
event,checkThresholds
endon
on relay#switch do
if [relay#switch]=1
gpio,13,0
else
gpio,13,1
endif
endon
on button#switch=0 do
if [relay#switch]=0
gpio,12,1
else
gpio,12,0
endif
endon
The issue is: after a lot of variants of Rules I got some issue in MQTT from my devise:
Code: Select all
Client mosqsub/13940-peremin-l received PUBLISH (d0, q0, r0, m0, '/sonoffF009/thermostat/hysteresis', ... (1 bytes))
1
Client mosqsub/13940-peremin-l received PUBLISH (d0, q0, r0, m0, '/sonoffF009/dht/temp', ... (12 bytes))
%eventvalue%
I think something has got stuck in the memory after my experements with the Rules