Hello

Moderators: rtenklooster, Voyager, BertB, Stuntteam

Post Reply
Message
Author
crumpy10
Normal user
Posts: 1
Joined: 20 Mar 2021, 04:59

Hello

#1 Post by crumpy10 » 20 Mar 2021, 05:13

Hello,
My names Simon and live in New Zealand. Been playing around with IOT stuff for a few years now as a hobby but have a background in Avionics.

Looking at developing a better spa tub controller with Espeasy.

First question -:
I have used this example code from a You tube video and cant figure out why the first part does not set the 'Set Temp' to 20 degrees.

Code: Select all

on System#Boot do
  TaskValueSet,2,1,20.0
  TaskValueSet,2,2,19.5
  TaskValueSet,2,3,20.5
endon

on Up#Switch do
  if [Up#Switch]=1
      if [Local#SetTemp]<40
        TaskValueSet 2,1,[Local#SetTemp]+0.5
        TaskValueSet 2,2,[Local#SetTemp]
        TaskValueSet 2,3,[Local#SetTemp]+1
      endif
  endif
endon
on Down#Switch do
  if [Down#Switch]=1
      if [Local#SetTemp]>5
        TaskValueSet 2,1,[Local#SetTemp]-0.5
        TaskValueSet 2,2,[Local#SetTemp]-1
        TaskValueSet 2,3,[Local#SetTemp]
      endif
  endif
endon

on DSB18b20#Temperature do
  if [DSB18b20#Temperature] > [Local#TempHigh]
    event,TurnOff
  endif
endon

on DSB18b20#Temperature do
  if [DSB18b20#Temperature] < [Local#TempLow]
    event,TurnOn
  endif
endon

on TurnOn do
  gpio,0,0
  oledframedcmd,3,Heating:ON
 
endon

on TurnOff do
  gpio,0,1
  oledframedcmd,3,Heating:OFF
endon

on SetTemp do
  TaskValueSet 2,1,%eventvalue%
  TaskValueSet 2,2,%eventvalue%-0.5
  TaskValueSet 2,3,%eventvalue%+0.5
endon
If I reboot the D1mini then the 20 degrees shows for a fraction of a second and then seems to reset to zero? Even if I just put the first rule in on its own it still does the same...
Doesnt make sense to me but I am a total noob on ESPEasy....

Any ideas?

All the best

Simon

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

Re: Hello

#2 Post by Ath » 20 Mar 2021, 11:39

Hello Simon, welcome to this forum.

NB: This part of the forum is meant for introductions, support questions should better go in the regular (ESPEasy) support sections.

It is a bit hard to guess how you have set up the Dummy device and switches you are using, can you share screen shots of their settings pages?
It is also of interest to know what version of ESPEasy you have installed, the name of the .bin file is the most informative. When unsure, the latest release (Nightly build) can be downloaded from here: https://github.com/letscontrolit/ESPEasy/releases (Expand the Assets link just below the release notes, for a D1mini with an OLED display connected you could use the ESP_Easy_mega_{releasedate}_display_ESP8266_4M1M.bin file.)

The rules you provided are pretty straight forward.
A few small improvements though:

Code: Select all

on Up#Switch do
  if [Up#Switch]=1
This can be simplified to:

Code: Select all

on Up#Switch=1 do
(similar for the Down switch) this shortens the code, and thus speeds up processing.

The reason your temperature drops from 20 to 0 is not clear to me, unless an external source is calling the SetTemp event, but without passing in an argument, resulting in 0 to be set. The correct way of using that event would be event,SetTemp=20 (values are stored as float values, but you can provide an integer as it will be converted correctly).
You have connected the switches using pull-up resistors (10k should be fine), and either enabled ' Use Safe Button' or set De-bounce to ~100 ms, I expect? (That's the a common and reliable way of connecting switches, without picking up stray button activation) In that case I'd respond to the state of the button to go to 0, unless you have ' Inversed Logic' enabled for your switches.
/Ton

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

Re: Hello

#3 Post by TD-er » 20 Mar 2021, 13:32

System#boot may be executed before the plugin is being initialized.
At init of tasks, the values are restored from RTC.
So you can also delay this init block by scheduling a timer.

I will have a look at the code to see if some other things are done after the System#boot event which you may not expect.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests