check if Sensor is active

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
ingoiot
Normal user
Posts: 43
Joined: 15 Aug 2019, 22:09

check if Sensor is active

#1 Post by ingoiot » 20 Oct 2019, 00:43

i tried this code to check if a sensor gives plausible values
if its out of the range of 10 to 100 degrees(because of a broken cable e.g.)
it should turn off the relay.

but it doesnt work.
it prevents from turning on as the value NaN is never valid for 10 to 100 i think,
but it doesnt turn it off.

Code: Select all

on Rules#Timer=1 do
 if [DS18b20#Temperature]<10 or [DS18b20#Temperature]>100
   sendTo 1,event,RelayOff 
else
 if [DS18b20#Temperature]<[DummyVar#tempSetpoint]
   sendTo 1,event,RelayOn
else
 if [DS18b20#Temperature]>[DummyVar#tempSetpoint]
   sendTo 1,event,RelayOff
 endif
endon

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

Re: check if Sensor is active

#2 Post by TD-er » 20 Oct 2019, 10:33

You could turn it on at the boot event?
NaN compared to any value is always false.

ingoiot
Normal user
Posts: 43
Joined: 15 Aug 2019, 22:09

Re: check if Sensor is active

#3 Post by ingoiot » 20 Oct 2019, 12:00

the boot event occurs only once? so it only checked on boottime if a sensor is present?

i think im using if/else wrong
timer 1 never expires (ist set in another rule, but i think that doesnt mater)
so normally the whole rule should be skipped.
edit:my wrong timer 1 is alway on so it should run only once

but this part works

Code: Select all

else
 if [DS18b20#Temperature]<[DummyVar#tempSetpoint]
   sendTo 1,event,RelayOn
else
 if [DS18b20#Temperature]>[DummyVar#tempSetpoint]
   sendTo 1,event,RelayOff
 endif

ingoiot
Normal user
Posts: 43
Joined: 15 Aug 2019, 22:09

Re: check if Sensor is active

#4 Post by ingoiot » 20 Oct 2019, 12:24

i just tried

Code: Select all

on [DS18b20#Temperature]>10 or [DS18b20#Temperature]<100 do

 if [DS18b20#Temperature]<[DummyVar#tempSetpoint]
   sendTo 1,event,RelayOn
else
 if [DS18b20#Temperature]>[DummyVar#tempSetpoint]
   sendTo 1,event,RelayOff
 endif
endon
but seems also to be no valid code.

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

Re: check if Sensor is active

#5 Post by grovkillen » 20 Oct 2019, 13:32

Code: Select all


on [DS18b20#Temperature] do
 If  [DS18b20#Temperature]>10 or [DS18b20#Temperature]<100
   Event,SetTemp
 EndIf
EndOn

On SetTemp Do
 if [DS18b20#Temperature]<[DummyVar#tempSetpoint]
   sendTo 1,event,RelayOn
  else
   sendTo 1,event,RelayOff
  EndIf
EndOn
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:

ingoiot
Normal user
Posts: 43
Joined: 15 Aug 2019, 22:09

Re: check if Sensor is active

#6 Post by ingoiot » 20 Oct 2019, 14:05

the termperature event shows up as:
EVENT: ds18b20#Temperature=15.50
but the SetTemp event never shows up in the log,
even this rule:

Code: Select all

on [ds18b20#Temperature] do

   Event,SetTemp
 EndIf
EndOn

On SetTemp do
 if [ds18b20#Temperature]<[DummyVar#tempSetpoint]
   sendTo 1,event,RelayOn
  else
   sendTo 1,event,RelayOff
  EndIf
EndOn
generates no settemp event.
(everything in espeasy is not case senstitive, am i right?)

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

Re: check if Sensor is active

#7 Post by grovkillen » 20 Oct 2019, 14:29

What version do you use?
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:

ingoiot
Normal user
Posts: 43
Joined: 15 Aug 2019, 22:09

Re: check if Sensor is active

#8 Post by ingoiot » 20 Oct 2019, 14:33

mega-20190809
whats the difference between old and new ruletype?

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

Re: check if Sensor is active

#9 Post by Domosapiens » 20 Oct 2019, 16:59

In this part ...no EndIf !

Code: Select all

on [ds18b20#Temperature] do

   Event,SetTemp
 EndIf
EndOn
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.

ingoiot
Normal user
Posts: 43
Joined: 15 Aug 2019, 22:09

Re: check if Sensor is active

#10 Post by ingoiot » 20 Oct 2019, 17:27

now it looks like this, but still no settemp event

Code: Select all

on [ds18b20#Temperature] do

   event,SetTemp

EndOn

On SetTemp do
 if [ds18b20#Temperature]<[DummyVar#tempSetpoint]
   sendTo 1,event,RelayOn
  else
   sendTo 1,event,RelayOff
  EndIf
EndOn

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

Re: check if Sensor is active

#11 Post by Domosapiens » 20 Oct 2019, 18:13

Code: Select all

on [ds18b20#Temperature] do

   event,SetTemp

EndOn
Must be:

Code: Select all

on ds18b20#Temperature do

   event,SetTemp

EndOn
you are not operating on the content ( conent is with []), but on the event that ds18b20#Temperature is updated , so no [] there
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.

ingoiot
Normal user
Posts: 43
Joined: 15 Aug 2019, 22:09

Re: check if Sensor is active

#12 Post by ingoiot » 20 Oct 2019, 18:53

works much better:) tnx

looks like everything is working right now, except
that the first else part is not executed.

i switched the ds18b29 error from NaN to 0, but that didnt help.
the SetTempEvent isnt called in the logs, that looks ok, but
the else statment isnt run.

Code: Select all

on DS18b20#Temperature do
 If  [DS18b20#Temperature]>10 and [DS18b20#Temperature]<100
   Event,SetTempEvent
else   //doesnt execute
   sendTo 1,event,RelayOff
  
 EndIf
EndOn

On SetTempEvent Do
 if [DS18b20#Temperature]<[DummyVar#tempSetpoint]
   sendTo 1,event,RelayOn
  else
   sendTo 1,event,RelayOff
  EndIf
EndOn

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

Re: check if Sensor is active

#13 Post by grovkillen » 20 Oct 2019, 19:04

"and" means that both need to be true...
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:

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

Re: check if Sensor is active

#14 Post by grovkillen » 20 Oct 2019, 19:05

Domosapiens wrote:
20 Oct 2019, 18:13

Code: Select all

on [ds18b20#Temperature] do

   event,SetTemp

EndOn
Must be:

Code: Select all

on ds18b20#Temperature do

   event,SetTemp

EndOn
you are not operating on the content ( conent is with []), but on the event that ds18b20#Temperature is updated , so no [] there
Darn! How did I miss that! :P
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:

ingoiot
Normal user
Posts: 43
Joined: 15 Aug 2019, 22:09

Re: check if Sensor is active

#15 Post by ingoiot » 20 Oct 2019, 19:23

"and" means that both need to be true...
thats what i want. the event should be only true as long as the temperatue is between 10 and 100 degrees
so when the sensor fails it shuts off.

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

Re: check if Sensor is active

#16 Post by grovkillen » 20 Oct 2019, 19:32

Yes but are the temperature below 10 or above 100 now when you're trying the rule?
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:

ingoiot
Normal user
Posts: 43
Joined: 15 Aug 2019, 22:09

Re: check if Sensor is active

#17 Post by ingoiot » 20 Oct 2019, 19:58

the temp is about 16 degrees.

i pull out the sensor so the value should become 0,
(and it shows 0 in device menu)
therefore it should send relayoff

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

Re: check if Sensor is active

#18 Post by TD-er » 20 Oct 2019, 21:03

Hmm nope, if the sensor cannot be read, the plugin should not send out a success = true when performing the PLUGIN_READ function.
Meaning the sensor will not trigger an event.

As was also opted as a new feature, we should send out an error event when the sensor cannot be read.
But it is not there yet.

ingoiot
Normal user
Posts: 43
Joined: 15 Aug 2019, 22:09

Re: check if Sensor is active

#19 Post by ingoiot » 20 Oct 2019, 22:12

tnx,

so i changed my stayalive rule to

Code: Select all

on DS18b20#Temperature do
  sendTo 1,event,StayAlive
 endon

this should send the stayalive function with interval set for the sensor i think.
and if the senor has an error it shouldnt run - seem to work for now

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests