Rule doesn´t work...

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
sawo
Normal user
Posts: 36
Joined: 26 Mar 2020, 12:20

Rule doesn´t work...

#1 Post by sawo » 01 Dec 2021, 15:06

Hi all,
I hope anyone could help me with my rule.
It won´t start.

On Schalter_Solar#State=1 Do
if [RC_Solar#State]=0
GPIO,12,0
TaskValueSet 6,1,0
else
GPIO,12,1
EndIf
EndOn

The only thing which is set is the "TaskValueSet 6,1,0".

thx
sawo

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

Re: Rule doesn´t work...

#2 Post by Ath » 01 Dec 2021, 15:47

If task 6 is a Dummy device, then it looks quite alright.
(how) have you configured your GPIO12 in the Hardware page? For simple output actions it isn't needed to be configured there.

How do you detect 'doesn't work' ? If the TaskValueSet command is working, then the rule works :)
/Ton (PayPal.me)

sawo
Normal user
Posts: 36
Joined: 26 Mar 2020, 12:20

Re: Rule doesn´t work...

#3 Post by sawo » 01 Dec 2021, 16:03

Hi Ath :D

it doesn´t turn on the GPIO 12 port. (else)
Yes it is configured in the devices tab and works fine. when use cmd GPIO,12,1 / 0
all other devices also work fine.
devices.JPG
devices.JPG (86.61 KiB) Viewed 6849 times
This is my complete rule:

On RC_Normal#State=0 Do
GPIO,14,0
TaskValueSet 7,1,0
EndOn

On Schalter_Normal#State=1 Do
if [RC_Normal#State]=0
GPIO,14,0
TaskValueSet 7,1,0
else
GPIO,14,1
EndIf
EndOn

On RC_Solar#State=0 Do
GPIO,12,0
TaskValueSet 6,1,0
EndOn

On Schalter_Solar#State=1 Do
if [RC_Solar#State]=0
GPIO,12,0
TaskValueSet 6,1,0
else
GPIO,12,1
EndIf
EndOn


thx
sawo

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

Re: Rule doesn´t work...

#4 Post by Ath » 01 Dec 2021, 16:11

First, let's use [ code ] tag around your code:

Code: Select all

On RC_Normal#State=0 Do
  GPIO,14,0
  TaskValueSet 7,1,0
EndOn

On Schalter_Normal#State=1 Do
  if [RC_Normal#State]=0  
    GPIO,14,0
    TaskValueSet 7,1,0
  else
    GPIO,14,1
  EndIf
EndOn

On RC_Solar#State=0 Do
  GPIO,12,0
  TaskValueSet 6,1,0
EndOn

On Schalter_Solar#State=1 Do
  if [RC_Solar#State]=0
    GPIO,12,0
    TaskValueSet 6,1,0
  else
    GPIO,12,1
  EndIf
EndOn
Why is there the extra Dummy device to react on a switch state? And have an event on both?
I'll look into it later today, have other work to complete :o
/Ton (PayPal.me)

sawo
Normal user
Posts: 36
Joined: 26 Mar 2020, 12:20

Re: Rule doesn´t work...

#5 Post by sawo » 01 Dec 2021, 16:39

Hi,
this is hard for me to explain.... (english knowledge)
but I will give it a try.

The RC_Solar and _Normal are "LJ12A3-4-Z/AY inductive proximity sensor/switch" these are used as an endpoint of a 3 way ball valve.
3way.jpg
3way.jpg (12.2 KiB) Viewed 6843 times
Pumpe_Normal / _Solar are replays which control the motor to turn the 3 way ball valve.
Pumpe_normal will turn left until the proximity sensor and Pumpe_Solar will turn right until the proximity sensor. In total max. 180°

If I active the Pumpe_Solar when it already has reached the final position (proximit senor) it will turn a little bit further. (this might damage the construction)
To avoid this I taught it would be good to use a dummy device which will get a certain state and will be read before it will move.

I hope that was understandable.
sawo

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

Re: Rule doesn´t work...

#6 Post by Ath » 01 Dec 2021, 21:24

If you are worried that the motor keeps running too long, you might want to extend your design to have physical end-switches, instead of a software-based solution.

Checking the switch-state before allowing the motor to start is a usual way of protecting, like you already have.
I haven't found anything that is blocking this from working as intended, yet.
You might want to build in a protection to turn both GPIO 12 and 14 on while the other pin is already on.

How is the Schalter_Normal or Schalter_Solar set to 1?
/Ton (PayPal.me)

sawo
Normal user
Posts: 36
Joined: 26 Mar 2020, 12:20

Re: Rule doesn´t work...

#7 Post by sawo » 06 Dec 2021, 14:49

Hi Ath,

okay I will change my setup and use the inductive proximity sensor as endpoint switch.
ThX

Sascha

sawo
Normal user
Posts: 36
Joined: 26 Mar 2020, 12:20

Re: Rule doesn´t work...

#8 Post by sawo » 22 Dec 2021, 11:22

Hi,

I finally got the time to rework my setup, the proximity sensors are now configured as endpoint swichtes! :)
As aspected I have some problems with my rules, maybe any one of you can assist my or give me a hint.

Sorry for the maybe basic and stupid questions!

First off all I want the rule to work only from e.x. 8am - 6pm, but I don´t know how to realize this?
And how can I prevent an action which has alreday been done? In this case to turn GPIO 12 on again.


see this rule:

Code: Select all

On System#Boot do
  timerSet,1,300
  timerSet,2,1800
endon

On Rules#Timer=1 do
     TaskValueSet,12,1,[Pooltemperatur#temp-solar]-[Pooltemperatur#temp-pool]
  If [Diff#Temp]>5
     TaskValueSet,11,1,[Pooltemperatur#temp-solar]-[Pooltemperatur#temp-pool]
  Else
    TaskValueSet,11,1,0
  EndIf
   timerSet,1,300
EndOn  

 Rules#Timer=2 do
     If [Diff#Temp]>8
       SendToUDP,192.168.9.155,5353,"gpio,12,1"
     Else
       SendToUDP,192.168.9.155,5353,"gpio,14,1"
   EndIf
     timerSet,2,1800
EndOn
EndOn

Here is some more backgroup, I want to add an automated heating of my pool, for this is use 2 temp-sensors.
I calculate the difference temperature from these sensors.
If the value is higher then 8° it should turn pump-solar on and pump-normal off,
if the temperature is lower then 8° it will turn off pump-solar and turn on pump-normal.

thanks a lot
sawo

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

Re: Rule doesn´t work...

#9 Post by TD-er » 22 Dec 2021, 12:11

This part does at least have some grammar error (not looked at it functionally)

Code: Select all

 Rules#Timer=2 do
     If [Diff#Temp]>8
       SendToUDP,192.168.9.155,5353,"gpio,12,1"
     Else
       SendToUDP,192.168.9.155,5353,"gpio,14,1"
   EndIf
     timerSet,2,1800
EndOn
EndOn
You're missing an "on" at the beginning and have an "EndOn" too many at the end.

Should be:

Code: Select all

on Rules#Timer=2 do
     If [Diff#Temp]>8
       SendToUDP,192.168.9.155,5353,"gpio,12,1"
     Else
       SendToUDP,192.168.9.155,5353,"gpio,14,1"
   EndIf
     timerSet,2,1800
EndOn
And just as a remark.
You're setting the timer again when handling it, so why not use the looptimer?
See: https://espeasy.readthedocs.io/en/lates ... oop-timers

sawo
Normal user
Posts: 36
Joined: 26 Mar 2020, 12:20

Re: Rule doesn´t work...

#10 Post by sawo » 22 Dec 2021, 12:31

Hi TD-er,

sorry that was a copy / past issue.
I will take a look at looptimer.

Thx
sawo

Post Reply

Who is online

Users browsing this forum: No registered users and 53 guests