Control ESPEasy-thermostat -> Rules problem

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
hvdwolf
Normal user
Posts: 51
Joined: 09 Jun 2016, 12:37

Control ESPEasy-thermostat -> Rules problem

#1 Post by hvdwolf » 05 Feb 2020, 11:25

I control my thermostat via an ESPEasy with a relais. This ESPEasy is controlled from Pimatic (could also be Domotics/OpenHAB/Home Assitant/etc.) with an extensive rule set which works really nice.
However, during my wintersports holiday, the SD-card in my RapberryPi got corrupted -> No more thermostat control. So my house went from the "fixed" temperature of 15 C to 9.5 C.

The ESPEasy itself is of course capable enough to do this all by itself, so I wanted a backup option which I could control directly..
So I wrote an Android app (see attached reduced images) and created a number of dummy devices.
The ESPEasy is connected to my central heating. The livingroom temperature (via event livingroomtemp) is sent by another ESPEasy with a ds18b20. Both are running on the normal 20191208 ESPEasy version.
This can all be controlled from the webGuid, but I also wanted to be able to do it from my phone, hence the Android app (which I can share by the way).

Devices:
cv-control_Devices.png
cv-control_Devices.png (74.31 KiB) Viewed 25783 times
And I created a 3 Rules Sets:
Rules Set 1:

Code: Select all

On System#Boot do    //When the ESP boots, do
  event InitSettings
  timerSet,1,20      //Set Timer 1 for the next event in 20 seconds
endon

On Rules#Timer=1 do  //When Timer1 expires, do
  if [Thermostat#Enabled]=1 and [Thermostat#Automatic]=0 //active and on manual
      if [Thermostat#Setpoint]>[Thermostat#Temperature]
          TaskValueSet,3,1,1
      else
          TaskValueSet,3,1,0
      endif
  endif
  if [Thermostat#Enabled]=1 and [Thermostat#Automatic]=1 //active and on auto
      if %sysweekday_s%=Sat or %sysweekday_s%=Sun
          event weekend
      else
          event weekday
     endif
  timerSet,1,15      //Set Timer 1 for the next event in 15 seconds
endon

on weekend do
  if %systime% > 07:45:00 and %systime% < 07:45:10
      TaskValueSet,2,3,[InitSetpoints#weday]
  endif
  if %systime% > 07:45:10 and %systime% < 22:30:00
      event CheckOnOff
  endif
  if %systime% < 07:45:00 or %systime% < 22:30:00
      TaskValueSet,2,3,[InitSetpoints#wenight]
      event CheckOnOff
  endif
  //timerSet,1,30      //Set Timer 1 for the next event in 30 seconds
endon

on livingroomtemp do
  TaskValueSet,2,2,%eventvalue%
endon
Rules set 2:

Code: Select all

on weekday do
  if %systime% > 06:45:00 and %systime% < 06:45:20
      TaskValueSet 2,3,[InitSetPointsWeekday#wdmorning]
  endif
  if %systime% > 06:45:20 and %systime% < 08:00:00
      event CheckOnOff
  endif
  if %systime% > 08:00:00 and %systime% < 08:00:20
      TaskValueSet 2,3,[InitSetPointsWeekday#wdday]
  endif
  if %systime% > 08:00:20 and %systime% < 16:45:00
      event CheckOnOff
  endif
  if %systime% > 16:45:00 and %systime% < 16:45:20
      TaskValueSet 2,3,[InitSetPointsWeekday#wdevening]
  endif
  if %systime% > 16:45:20 and %systime% < 22:15:00
      event CheckOnOff
  endif
  if %systime% < 06:45:00 or %systime% > 22:15:01
      TaskValueSet 2,3,[InitSetPointsWeekday#wdnight]
      event CheckOnOff
  endif
  //timerSet,1,30      //Set Timer 1 for the next event in 30 seconds
endon

on CheckOnOff
  if Thermostat#Setpoint>Thermostat#Temperature 
      //TaskValueSetAndRun,3,1,1
      GPIO,13,1
  else
      //TaskValueSetAndRun,3,1,0
      GPIO,13,0
  endif
endon
Rules set 3:

Code: Select all

On InitSettings do
  TaskValueSet 2,1,1  //enabled
  //TaskValueSet 2,1,0  //disabled
  TaskValueSet 2,3,18.0 //Setpoint
  TaskValueSet 2,4,1 //Auto=1, manual=0
  Let,1,15  //wdnight
  Let,2,19.5 //wdmorning
  Let,3,18.5 //wdday
  Let,4,20 //wdevening
  TaskValueSet 4,1,[VAR#1]
  TaskValueSet 4,2,[VAR#2]
  TaskValueSet 4,3,[VAR#3]
  TaskValueSet 4,4,[VAR#4]
  // weekend
  Let,5,15.5  //wenight
  Let,6,20 //wemorning
  Let,7,20 //weday
  Let,8,20.5 //weevening
  TaskValueSet 5,1,[VAR#5]
  TaskValueSet 5,2,[VAR#6]
  TaskValueSet 5,3,[VAR#7]
  TaskValueSet 5,4,[VAR#8]

  if %sysweekday_s%=Sat or %sysweekday_s%=Sun
      event initweekend
  else
      event initweekday
  endif
endon


on initweekend do
    if %systime% > 07:45:00 and %systime% < 22:30:00
      TaskValueSetAndRun,2,3,[InitSetPointsWeekend#weday]
    else
      TaskValueSetAndRun,2,3,[InitSetPointsWeekend#wenight]
    endif
endon


on initweekday do
    if %systime% > 06:45:00 and %systime% < 08:00:00
      TaskValueSetAndRun,2,3,[InitSetPointsWeekday#wdmorning]
    endif
    if %systime% > 08:00:00 and %systime% < 16:45:00
      TaskValueSetAndRun,2,3,[InitSetPointsWeekday#wdday]
    endif
    if %systime% > 16:45:00 and %systime% < 22:15:00
      TaskValueSetAndRun,2,3,[InitSetPointsWeekday#wdevening]
    endif
    if %systime% < 06:45:00 or %systime% > 22:15:01
      TaskValueSetAndRun,2,3,[InitSetPointsWeekday#wdnight]
    endif
endon
Everything works fine including my Android app, but for one very essential thing: the heating itself.

Code: Select all

on CheckOnOff
  if Thermostat#Setpoint>Thermostat#Temperature 
      //TaskValueSetAndRun,3,1,1
      GPIO,13,1
  else
      //TaskValueSetAndRun,3,1,0
      GPIO,13,0
  endif
endon
The GPIO command doesn't switch on the heating (I also tried tthe TaskValueSetAndRun command without success and even the sendTo command as in sendTo,30,13,1 or sendTo,30,13,0 where 30 is my unit number).
What am I doing wrong?

And for those seeing the external address in the Settings: I know it is very dangerous, but I can ssh tunnel via my server with an extra encryption on top of it)
Attachments
001-Main.png
001-Main.png (72.71 KiB) Viewed 25783 times
002-Main.png
002-Main.png (76.19 KiB) Viewed 25783 times
003-WebSettings.png
003-WebSettings.png (167.51 KiB) Viewed 25783 times
004-VariablesSettings.png
004-VariablesSettings.png (121.89 KiB) Viewed 25783 times

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Control ESPEasy-thermostat -> Rules problem

#2 Post by grovkillen » 05 Feb 2020, 11:47

Thanks for posting! Good job.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

hvdwolf
Normal user
Posts: 51
Joined: 09 Jun 2016, 12:37

Re: Control ESPEasy-thermostat -> Rules problem

#3 Post by hvdwolf » 05 Feb 2020, 12:08

Thanks.

But did you see my question in the last part? ;)
Once that has been fixed I will post it as a project and attach the Android app for those who want to try it themselves.

Everything works fine including my Android app, but for one very essential thing: the heating itself.

Code: Select all

on CheckOnOff
  if Thermostat#Setpoint>Thermostat#Temperature 
      //TaskValueSetAndRun,3,1,1
      GPIO,13,1
  else
      //TaskValueSetAndRun,3,1,0
      GPIO,13,0
  endif
endon
The GPIO command doesn't switch on the heating (I also tried tthe TaskValueSetAndRun command without success and even the sendTo command as in sendTo,30,13,1 or sendTo,30,13,0 where 30 is my unit number).
What am I doing wrong?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Control ESPEasy-thermostat -> Rules problem

#4 Post by TD-er » 05 Feb 2020, 12:47

Have you added a logitem command in there to see if it does try to set the value?

And if I'm not mistaken, you should also enable gpio monitoring (at boot).
Maybe you can also add a task "switch" which you then run?

hvdwolf
Normal user
Posts: 51
Joined: 09 Jun 2016, 12:37

Re: Control ESPEasy-thermostat -> Rules problem

#5 Post by hvdwolf » 05 Feb 2020, 13:39

I added the monitor,13 to the System#boot.
When pimatic controls it, I see it changing. 2 snippets from the log:

Code: Select all

211228: Command: gpio
211230: SW   : GPIO 13 Set to 1
211318: SW  : GPIO=13 State=1 Output value=1
211325: EVENT: ThermostatState#HeatingStatus=1.00

228385: Command: gpio
228387: SW   : GPIO 13 Set to 0
228543: SW  : GPIO=13 State=0 Output value=0
228546: EVENT: ThermostatState#HeatingStatus=0.00
When I add the LogEntry to the CheckOnOff

Code: Select all

on CheckOnOff
  LogEntry,"In CheckOnOff"
  if Thermostat#Setpoint>Thermostat#Temperature 
      LogEntry,"Setpoint > Temperature"
      //TaskValueSetAndRun,3,1,1
      GPIO,13,1
  else
      //TaskValueSetAndRun,3,1,0
      GPIO,13,0
      LogEntry,"Setpoint <= Temperature"
  endif
endon
I see nothing added to the log, for example:

Code: Select all

133012: Command: event
133019: EVENT: livingroomtemp=20.0
133046: ACT : TaskValueSet,2,2,20.0
133048: Command: TaskValueSet
135389: EVENT: Rules#Timer=1
135474: ACT : event weekday
135475: Command: event
135476: EVENT: weekday
[b]135569: ACT : event CheckOnOff
135570: Command: event
135571: EVENT: CheckOnOff[/b]
135814: ACT : timerSet,1,15
135815: Command: timerSet
139771: HTTP: status,gpio,13
139773: Command: status
but no gpio changes. What is, or what am I doing wrong?

And the question
Maybe you can also add a task "switch" which you then run?
is not clear to me. Can you please explain?

Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

Re: Control ESPEasy-thermostat -> Rules problem

#6 Post by Domosapiens » 05 Feb 2020, 16:55

on CheckOnOff
Must be
on CheckOnOff do
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

hvdwolf
Normal user
Posts: 51
Joined: 09 Jun 2016, 12:37

Re: Control ESPEasy-thermostat -> Rules problem

#7 Post by hvdwolf » 05 Feb 2020, 17:05

Unbelievable that I overlooked that for so long. :shock:

Thanks a lot. That did it.

hvdwolf
Normal user
Posts: 51
Joined: 09 Jun 2016, 12:37

Re: Control ESPEasy-thermostat -> Rules problem

#8 Post by hvdwolf » 08 Feb 2020, 12:51

Well, I needed some more changes.

In my first post you can see in Rules Set 1 that I have nested if commands. That is not allowed and therefore doesn't work (and was also overlooked by the gurus on this forum ;)), which I just discovered this weekend as it remained on weekday.

Secondly, which is my stupid fault: On every Timerset1 I check setpoint and switch on/off the relay.
Coincidence or not: my relay was broken this morning. The nodemcu/EspEasy nicely switched on/off but the relay did not activate. I replaced the relay and everything works again.
I will build another if-else: if already on (or off) do not switch again on (or off).

I could not find anything about this, but perhaps a pulse every 15-20 seconds for 6 days (~ 25900 pulses) is too much, also after 3~4 years "normal" use via pimatic. Should these (cheap Chinese) relays be able to cope with that?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Control ESPEasy-thermostat -> Rules problem

#9 Post by TD-er » 08 Feb 2020, 22:21

Please also check to see if you have a diode over the relay to protect the switching electronics.
The coil of the relay may cause a voltage spike when it is deactivated, which may destroy the transistor switching it.

Rade_mk
New user
Posts: 1
Joined: 15 Dec 2020, 17:05

Re: Control ESPEasy-thermostat -> Rules problem

#10 Post by Rade_mk » 15 Dec 2020, 17:19

hi , i`m new in this one and wery like this old project. i want to make a try with domoticz same thermostat with dalas sonde. pls can contact me if u wanna to explaine step by step this project and configuring devices in espeasy , events ... verry thankfull

kimot
Normal user
Posts: 190
Joined: 12 Oct 2017, 20:46

Re: Control ESPEasy-thermostat -> Rules problem

#11 Post by kimot » 26 Dec 2020, 23:14

@ Rade_mk

Here is my solution with Domoticz.
Not too complex at boot like this examples, but can be edited.
Rules for ESPeasy and DzVents for Domoticz in comments.
But I use very old version of ESPeasy ( v2.0-20180322 ) - maybe not all commands will work on new ESPeasy fw.
Third winter without any problem.

https://www.youtube.com/watch?v=1ef6tRinOQ4

lex007112
New user
Posts: 4
Joined: 07 Jan 2021, 17:34

Re: Control ESPEasy-thermostat -> Rules problem

#12 Post by lex007112 » 07 Jan 2021, 21:16

kimot wrote: 26 Dec 2020, 23:14 @ Rade_mk

Here is my solution with Domoticz.
Not too complex at boot like this examples, but can be edited.
Rules for ESPeasy and DzVents for Domoticz in comments.
But I use very old version of ESPeasy ( v2.0-20180322 ) - maybe not all commands will work on new ESPeasy fw.
Third winter without any problem.

https://www.youtube.com/watch?v=1ef6tRinOQ4
Hello! The thermostat was made according to your YouTube video. Can you please tell me how to implement the hysteresis function of the controlled Domoticz? I set up the transmission of the hysteresis value from Domoticz, but I haven't figured out how to apply it in the rules yet.
on RoomControl do
if [HTU21d#Temperature]<[Variables#Setpoint]+[Variables#Hysteresis] // ?????? It doesn't work like that
TaskValueSet,1,3,1
endif
endon

Hysteresis.jpg
Hysteresis.jpg (25.2 KiB) Viewed 18790 times
Hysteresis2.jpg
Hysteresis2.jpg (44.14 KiB) Viewed 18789 times

Code: Select all

On System#Boot do
 gpio,26,1
 TaskValueSet,1,1,0.5    
 TaskValueSet,1,2,21 
 TaskValueSet,1,3,0   
 TaskValueSet,1,4,10 
 timerSet,1,60 
endon

on ModeSet do   
 TaskValueSet 1,4,%eventvalue%
 timerSet,1,5
endon

on Hysteresis do
 TaskValueSet 1,1,%eventvalue%
 timerSet,1,5
endon    
 
on HeatSetpoint do   
 TaskValueSet 1,2,%eventvalue%
  if [Variables#Setpoint]>32
   TaskValueSet,1,2,32
  endif  
  timerSet,1,5
endon

on RoomControl do 
 if [HTU21d#Temperature]<[Variables#Setpoint]+[Variables#Hysteresis]  // ?????? It doesn't work like that
  TaskValueSet,1,3,1 
 endif
endon

on HeatingOn do
 gpio,26,0
 SendToHTTP xxx.xxx.xxx.xxx,8080,/json.htm?type=command&param=switchlight&idx=3&switchcmd=On
endon

on HeatingOff do
 gpio,26,1
 SendToHTTP xxx.xxx.xxx.xxx,8080,/json.htm?type=command&param=switchlight&idx=3&switchcmd=Off
endon

On relay do
 if [Variables#Heating]=1
  event,HeatingOn
 else
  event,HeatingOff
 endif
endon   

On Rules#Timer=1 do
 TaskValueSet,1,3,0
 if [Variables#Mode]=10
  event,RoomControl
 endif
 if  [Variables#Mode]=0
  TaskValueSet,1,3,0
 endif   
 event,relay
 timerSet,1,60
endon

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Control ESPEasy-thermostat -> Rules problem

#13 Post by Ath » 07 Jan 2021, 22:28

Doing calculations in comparisons isn't working (yet), so it should be something like:

Code: Select all

on RoomControl do 
  Let,1,[Variables#Setpoint]+[Variables#Hysteresis] // Assuming that var#1 isn't used yet...
  if [HTU21d#Temperature]<[Var#1]
    TaskValueSet,1,3,1 
  endif
endon
/Ton (PayPal.me)

lex007112
New user
Posts: 4
Joined: 07 Jan 2021, 17:34

Re: Контроль ESPEasy-термостат -

#14 Post by lex007112 » 08 Jan 2021, 06:59

Ath wrote: 07 Jan 2021, 22:28 Doing calculations in comparisons isn't working (yet), so it should be something like:

Code: Select all

on RoomControl do 
  Let,1,[Variables#Setpoint]+[Variables#Hysteresis] // Assuming that var#1 isn't used yet...
  if [HTU21d#Temperature]<[Var#1]
    TaskValueSet,1,3,1 
  endif
endon
Hello, I'm new to this business.If anything, sorry for google translation))). So the value, in your example, assigned to Let, 1,[Variables#Setpoint]+[Variables#Hysteresis] equals [Var # 1]. Or should it be prescribed somewhere else in the rules?For Let, 1 and Var # 1. And where to specify Let, 1 .... Let, 2 ... in the rules immediately before the "if" or you can define all the values "Let, 1 ... Let, 2" after the "System # Boot ...endon " block at the beginning of the rules?
Did I understand correctly in the example?

Code: Select all

On System#Boot do
 gpio,26,1
 TaskValueSet,1,1,0.5    
 TaskValueSet,1,2,21 
 TaskValueSet,1,3,0   
 TaskValueSet,1,4,10 
 timerSet,1,60 
endon
Let,1,[Variables#Setpoint]-[Variables#Hysteresis]
Let,2,[Variables#Setpoint]+[Variables#Hysteresis]
on RoomControl do 
  if [HTU21d#Temperature]<=[Var#1]
    TaskValueSet,1,3,1 
  endif
endon
on RoomControl do 
  if [HTU21d#Temperature]>=[Var#2]
    TaskValueSet,1,3,0 
  endif
endon

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Control ESPEasy-thermostat -> Rules problem

#15 Post by Ath » 08 Jan 2021, 07:58

1) All Rules code has to be within an 'on ... do / endon' section (event-handler), any code outside of that is ignored.
2) You would want to compare the actual measurements/values, so the assignment 'Let,1,...' should be done right before you do a comparison to it, by using its value [Var#1], so please use my example code.
3) Any event name in the rules should be used only once, so having 2 'on RoomControl do' events is causing more confusion then needed

Code: Select all

on RoomControl do 
  Let,1,[Variables#Setpoint]-[Variables#Hysteresis]
  Let,2,[Variables#Setpoint]+[Variables#Hysteresis]
  if [HTU21d#Temperature]<=[Var#1]
    TaskValueSet,1,3,1 
  endif
  if [HTU21d#Temperature]>=[Var#2]
    TaskValueSet,1,3,0 
  endif
endon
(And the endif/if could be changed to elseif, but that's just a small optimization)
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Control ESPEasy-thermostat -> Rules problem

#16 Post by TD-er » 08 Jan 2021, 10:57

Also keep in mind that the "calculate" function (to do computations) is not yet done on all commands in the rules. (this is something I'm looking into for a pending PR, so not yet fixed)
The Let command does call all kinds of calculate functions, so that's the safest one for doing computations.

lex007112
New user
Posts: 4
Joined: 07 Jan 2021, 17:34

Re: Control ESPEasy-thermostat -> Rules problem

#17 Post by lex007112 » 08 Jan 2021, 19:59

Ath wrote: 08 Jan 2021, 07:58 1) All Rules code has to be within an 'on ... do / endon' section (event-handler), any code outside of that is ignored.
2) You would want to compare the actual measurements/values, so the assignment 'Let,1,...' should be done right before you do a comparison to it, by using its value [Var#1], so please use my example code.
3) Any event name in the rules should be used only once, so having 2 'on RoomControl do' events is causing more confusion then needed

Code: Select all

on RoomControl do 
  Let,1,[Variables#Setpoint]-[Variables#Hysteresis]
  Let,2,[Variables#Setpoint]+[Variables#Hysteresis]
  if [HTU21d#Temperature]<=[Var#1]
    TaskValueSet,1,3,1 
  endif
  if [HTU21d#Temperature]>=[Var#2]
    TaskValueSet,1,3,0 
  endif
endon
(And the endif/if could be changed to elseif, but that's just a small optimization)
Under this condition, with a Setpoint value of, for example, 25 degrees, hysteresis 1 turns on correctly at 24, and turns off at 24.1, but should turn off at 26 degrees, what is the reason?
Those. the following condition does not work:
if [HTU21d#Temperature]>=[Var#2]

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Control ESPEasy-thermostat -> Rules problem

#18 Post by Ath » 08 Jan 2021, 20:33

lex007112 wrote: 08 Jan 2021, 19:59 Those. the following condition does not work:
if [HTU21d#Temperature]>=[Var#2]
Well, I just copied your code and moved it around a bit :D

You can add a line to the log to view the actual values that are used for the comparisons, like this:

Code: Select all

  LogEntry,"Temp: [HTU21d#Temperature], V1: [Var#1], V2: [Var#2]"
Insert that just before the first 'if' statement, and view the log either via the serial output or from the Tools/Log page.
/Ton (PayPal.me)

lex007112
New user
Posts: 4
Joined: 07 Jan 2021, 17:34

Re: Control ESPEasy-thermostat -> Rules problem

#19 Post by lex007112 » 08 Jan 2021, 20:52

Ath wrote: 08 Jan 2021, 20:33
lex007112 wrote: 08 Jan 2021, 19:59 Those. the following condition does not work:
if [HTU21d#Temperature]>=[Var#2]
Well, I just copied your code and moved it around a bit :D

You can add a line to the log to view the actual values that are used for the comparisons, like this:

Code: Select all

  LogEntry,"Temp: [HTU21d#Temperature], V1: [Var#1], V2: [Var#2]"
Insert that just before the first 'if' statement, and view the log either via the serial output or from the Tools/Log page.
Friends, thanks for the help, I figured out what the reason was for removing the line at the end of the code:

Code: Select all

On Rules#Timer=1 do
 TaskValueSet,1,3,0  //This prevented the hysteresis from working
 if [Variables#Mode]=10
  event,RoomControl
 endif
 if  [Variables#Mode]=0
  TaskValueSet,1,3,0
 endif   
 event,relay
 timerSet,1,60
endon
Deleted this line in the rules, and everything worked as it should. Because the code is not yours, therefore "reverse engineering" failed :D
Thanks again for participating ;)

kimot
Normal user
Posts: 190
Joined: 12 Oct 2017, 20:46

Re: Control ESPEasy-thermostat -> Rules problem

#20 Post by kimot » 08 Jan 2021, 23:45

But you set your dummy Heating variable to 1 or 0 in your RoomControl event.
So erase code for setting this variable to 0 before this event has no influence to your code.
You set its value in RoomControl event.
In the original code i set this variable to 0 on start of thermostat loop and set it to 1 only if temperature is bellow setpoint.
There must be another bug.
But thanks for adding hysteresis function to thermostat code.
I control floor temperature in my house and a floor temperature has got a big thermal inertia, so hysteresis not needed for me.
But for room temperature it can be useful feature.

Cdzn
Normal user
Posts: 58
Joined: 06 Oct 2020, 18:15

Re: Control ESPEasy-thermostat -> Rules problem

#21 Post by Cdzn » 26 Oct 2023, 02:04

Hi guys. Could anyone answer, how set hysteresis in level control via http command?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Control ESPEasy-thermostat -> Rules problem

#22 Post by TD-er » 26 Oct 2023, 08:23

Regardless of how you want to set it, or perform some specific sequence of actions via a single HTTP (or MQTT) command, it is best to create some rules block for it with your own event name.
You can give several eventvalues along with it and use those in the rules block.

See for explanation of eventvalues: https://espeasy.readthedocs.io/en/lates ... eventvalue

To set a value via commands in the level plugin, you have a rather non-intuitive naming schema (Level plugin was the first to have such a naming schema, but since it is being used "in the field", we cannot change it to a bit more intuitive form)
See: https://espeasy.readthedocs.io/en/lates ... -available

So let's create a rules block for a new event we call (you can rename it if you like) "SetThermostat".

Let's assume the "Level" task we need to update is called "temp".

Code: Select all

On SetThermostat Do
//  Syntax: config,task,<taskname>,SetLevel,<value>
  config,task,temp,SetLevel,%eventvalue1%  
Endon
Then you can call this by generating an event like this:

Code: Select all

event,SetThermostat=22
If you enter this command (with whatever eventvalue you want instead of "22") in the Command line field on the Tools page, you can see what the exact URL needs to be in the URL bar of your browser.
(the page actually refreshes after you submit the command, thus the URL gets updated)

This is the HTTP GET command you need to update your Level value.

Cdzn
Normal user
Posts: 58
Joined: 06 Oct 2020, 18:15

Re: Control ESPEasy-thermostat -> Rules problem

#23 Post by Cdzn » 26 Oct 2023, 15:14

TD-er wrote: 26 Oct 2023, 08:23 Regardless of how you want to set it, or perform some specific sequence of actions via a single HTTP (or MQTT) command, it is best to create some rules block for it with your own event name.
You can give several eventvalues along with it and use those in the rules block.

See for explanation of eventvalues: https://espeasy.readthedocs.io/en/lates ... eventvalue

To set a value via commands in the level plugin, you have a rather non-intuitive naming schema (Level plugin was the first to have such a naming schema, but since it is being used "in the field", we cannot change it to a bit more intuitive form)
See: https://espeasy.readthedocs.io/en/lates ... -available

So let's create a rules block for a new event we call (you can rename it if you like) "SetThermostat".

Let's assume the "Level" task we need to update is called "temp".

Code: Select all

On SetThermostat Do
//  Syntax: config,task,<taskname>,SetLevel,<value>
  config,task,temp,SetLevel,%eventvalue1%  
Endon
Then you can call this by generating an event like this:

Code: Select all

event,SetThermostat=22
If you enter this command (with whatever eventvalue you want instead of "22") in the Command line field on the Tools page, you can see what the exact URL needs to be in the URL bar of your browser.
(the page actually refreshes after you submit the command, thus the URL gets updated)

This is the HTTP GET command you need to update your Level value.
Hi TD-er, i know how to set temperature, but what if i need to change hysteresis. Is it possible via http or only in regulator settings?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Control ESPEasy-thermostat -> Rules problem

#24 Post by TD-er » 26 Oct 2023, 15:33

Ah sorry, had missed the word "hysteresis" in your question.

Nope, that setting is not possible to set via a command right now.
It can be added, but that does require a code change, so that's not helpful to fix it right now.

Cdzn
Normal user
Posts: 58
Joined: 06 Oct 2020, 18:15

Re: Control ESPEasy-thermostat -> Rules problem

#25 Post by Cdzn » 27 Oct 2023, 15:22

TD-er wrote: 26 Oct 2023, 15:33 Ah sorry, had missed the word "hysteresis" in your question.

Nope, that setting is not possible to set via a command right now.
It can be added, but that does require a code change, so that's not helpful to fix it right now.
Thx. I said it to one person who wanted to change hysteresis the same things. It’s not necessary to change it often.

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Control ESPEasy-thermostat -> Rules problem

#26 Post by Ath » 28 Oct 2023, 17:39

I've created PR #4860 that adds this as a feature:

Code: Select all

config,task,<TaskName>,SetHysteresis,<value|calculation>
and also adds the variable

Code: Select all

[<TaskName>#GetHysteresis]
so you can check/display the current Hysteresis setting.

Download from this GH Actions run (when logged in with your Github account) once that's finished.

Please test this build, and report your findings here (or in the PR comments)

Edit: Updated Actions Run url, as we changed the command/value with Set/Get prefix.
/Ton (PayPal.me)

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Control ESPEasy-thermostat -> Rules problem

#27 Post by Ath » 25 Nov 2023, 20:12

Cdzn wrote: 27 Oct 2023, 15:22 Thx. I said it to one person who wanted to change hysteresis the same things. It’s not necessary to change it often.
(Just quoting the user to trigger an email by the forum...)

@Cdzn, it's been a while. A PR is waiting for you to be tested. I've just started a new build so you can test with the latest code from this GH Actions run, like explained in my previous message.
Your feedback is appreciated.
/Ton (PayPal.me)

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Control ESPEasy-thermostat -> Rules problem

#28 Post by Ath » 27 Nov 2023, 23:14

The PR has been merged into the mega branch of ESPEasy today, waiting for a stable release in the coming days :)
/Ton (PayPal.me)

User avatar
uah007
Normal user
Posts: 15
Joined: 15 Oct 2022, 23:04
Location: Ukraine, Kyiv

Re: Control ESPEasy-thermostat -> Rules problem

#29 Post by uah007 » 21 Jan 2024, 15:55

ESP_Easy_mega_20231225_collection_C_ESP32_4M316k, the command doesn't work config,task,<taskname>,SetHysteresis,<value|calculation>.
Everything is fine in build ESP_Easy_mega_20231225_normal_ESP32_4M316k.

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Control ESPEasy-thermostat -> Rules problem

#30 Post by Ath » 21 Jan 2024, 16:18

uah007 wrote: 21 Jan 2024, 15:55 ESP_Easy_mega_20231225_collection_C_ESP32_4M316k, the command doesn't work config,task,<taskname>,SetHysteresis,<value|calculation>.
Everything is fine in build ESP_Easy_mega_20231225_normal_ESP32_4M316k.
What exact command doesn't work? There is no difference in the code for either NORMAL or COLLECTION builds. :?
/Ton (PayPal.me)

User avatar
uah007
Normal user
Posts: 15
Joined: 15 Oct 2022, 23:04
Location: Ukraine, Kyiv

Re: Control ESPEasy-thermostat -> Rules problem

#31 Post by uah007 » 21 Jan 2024, 16:47

On Dom#pid Do
TaskEnable,pid
config,task,pid,SetLevel,%eventvalue%
config,task,pid,SetHysteresis,1
Save
Endon

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Control ESPEasy-thermostat -> Rules problem

#32 Post by Ath » 21 Jan 2024, 16:59

Is the SetLevel version of that command working as intended?

And how is the Level plugin configured?

Do you have other rules that set the Hysteresis to a different value? If not it could better be set in the configuration.

NB: Have you read the remarks about saving the settings often? As that will physically wear out (damage!) the flash memory of your device, causing it to fail, sometime in the future...
Quite some time was invested in the auto-save feature of that plugin, to try and reduce the number of saves as much as possible, and hopefully avoid, or at least postpone, the failing of the flash memory.
/Ton (PayPal.me)

User avatar
uah007
Normal user
Posts: 15
Joined: 15 Oct 2022, 23:04
Location: Ukraine, Kyiv

Re: Control ESPEasy-thermostat -> Rules problem

#33 Post by uah007 » 21 Jan 2024, 17:17

Is the SetLevel version of that command working as intended?
yes
And how is the Level plugin configured?
Image
Do you have other rules that set the Hysteresis to a different value?
no

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Control ESPEasy-thermostat -> Rules problem

#34 Post by Ath » 21 Jan 2024, 21:33

You can add attachments in this board, external services tend to remove these screenshots after a couple of weeks/months, so we don't have a clue wat was on there... Also the image is rather small, probably also caused by that external service, so it's quite hard to see what's on there.

I've just tested the command, and it works as intended, the hysteresis is set.

BTW, why don't you configure the hysteresis in the settings page instead of executing a command from rules? You can enter a 1 there as well, it's stored as a numeric value, with decimals if required, and initially presented with decimals too.
/Ton (PayPal.me)

User avatar
uah007
Normal user
Posts: 15
Joined: 15 Oct 2022, 23:04
Location: Ukraine, Kyiv

Re: Control ESPEasy-thermostat -> Rules problem

#35 Post by uah007 » 21 Jan 2024, 22:00

Thank you for your participation.
The problem turned out to be on my side and was solved by updating the firmware again. At first I had 20231225_collection_C and it did not want to work as I described. Then I installed 20231225_normal , the problem went away. After your message I went back to 20231225_collection_C and everything worked as expected. Next time I will update the firmware before sounding the alarm. Thanks again.

Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests