several rules

Moderators: BertB, rtenklooster, Voyager, Stuntteam, Martinus

Message
Author
TungstenE2
Normal user
Posts: 51
Joined: 03 Apr 2018, 21:46

Re: several rules

#21 Post by TungstenE2 » 09 Jun 2018, 21:34

thx, the event works in general, but the motor does not stop if [Reed1-oben#Switch] changes from 0 to 1.
But this should be the case, right?

If I release the [Taster1#Switch] and press it again, while [Reed1-oben#Switch] is still 1 motor does not start again. This is correct.

Also if [Reed1-oben#Switch] is 1 when [Taster1#Switch] is pressed the motor does not start. Keeping the [Taster1#Switch] pressed and [Reed1-oben#Switch] changes from 1 to 0 the motor starts. This is alos correct.

danmero
Normal user
Posts: 64
Joined: 11 May 2017, 01:19

Re: several rules

#22 Post by danmero » 10 Jun 2018, 01:49

Post your code and add comments (//) where is not working.

Regards,

TungstenE2
Normal user
Posts: 51
Joined: 03 Apr 2018, 21:46

Re: several rules

#23 Post by TungstenE2 » 10 Jun 2018, 09:48

I was refering to this:

Code: Select all

//Dummy1
//999 default
//1[Dummies#Tag][Reed1-oben#Switch][Reed2-unten#Switch]
//1110 day door open
//1101 day door down
//1010 night door open
//1001 night door down


On System#Boot do
  TaskValueSet 7,1,0 // no day = 0
  TaskValueSet 7,2,200 // Helligkeit on dummy sensor
  TaskValueSet 7,3,0 // DC Motor off
  TaskValueSet 7,4,0 // Timer off
  TaskValueSet 8,1,999 // To concat of some dummys (named Dummy1#Concat) '999' just as a default ref
  timerSet,2,10
endon




// day or night
On Lichtsensor#Analog do
	if [Lichtsensor#Analog] > [Dummies#HelligkeitTriggerTag]
		TaskValueSet 7,1,1
	else
		TaskValueSet 7,1,0
	endif
endon

//every 1 sek Timer1 is adding values from the devices to the concat dummy
On Rules#Timer=1 do
	TaskValueSet 8,1,1[Dummies#Tag][Reed1-oben#Switch][Reed2-unten#Switch]
 	timerSet,1,1
endon




On Taster1#Switch do
	If [Taster1#Switch]=1 and [Reed1-oben#Switch]=0
		Event,DoorClose
	Else
		Event,DoorStop
endif
endon

On DoorStop Do
	WemosMotorShieldCMD 0 Stop
	TaskValueSet 7,3,0
EndOn

On DoorOpen Do
	WemosMotorShieldCMD 0 Backward 50
	TaskValueSet 7,3,1
EndOn

On DoorClose Do
	WemosMotorShieldCMD 0 Forward 50
	TaskValueSet 7,3,1
EndOn

And I would have expected the motor to stop, when [Reed1-oben#Switch] changes from 0 to 1.

Code: Select all

Else
		Event,DoorStop

TungstenE2
Normal user
Posts: 51
Joined: 03 Apr 2018, 21:46

Re: several rules

#24 Post by TungstenE2 » 10 Jun 2018, 12:39

ok, got this now working with events. door motor is triggered by push button or cmd.

so basic version is working, as wife is asking for POC...

but this is manual interaction. next step is automation. either based on light sensor or weekday and time.

Code: Select all

On System#Boot do
  TaskValueSet 7,1,0 // no day = 0
  TaskValueSet 7,2,200 // Helligkeit on dummy sensor
  TaskValueSet 7,3,0 // DC Motor off
  TaskValueSet 7,4,0 // Timer off
  TaskValueSet 8,1,999 // To concat of some dummys (named Dummy1#Concat) '999' just as a default ref
  timerSet,2,10
endon


//close door if Taster1 is pressed and door is not closed
On Taster1-close#Switch do
	If [Taster1-close#Switch]=1 and [Reed2-close#Switch]!=1
		Event,DoorClose
	Else
		Event,DoorStop
endif
endon

//stop door close if reed2 changes from 0 to 1
On Reed2-close#Switch do
	If [Dummies#DCMotorOn]=1 and [Reed2-close#Switch]=1
		Event,DoorStop
	endif
endon

//stop door open if reed1 changes from 0 to 1
On Reed1-open#Switch do
	If [Dummies#DCMotorOn]=1 and [Reed1-open#Switch]=1
		Event,DoorStop
	endif
endon


//Events
On DoorStop Do
	WemosMotorShieldCMD 0 Stop
	TaskValueSet 7,3,0
EndOn

On DoorOpen Do
If [Reed1-open#Switch]!=1
	WemosMotorShieldCMD 0 Backward 50
	TaskValueSet 7,3,1
EndOn

On DoorClose Do
    If [Reed2-close#Switch]!=1
  	WemosMotorShieldCMD 0 Forward 50
	TaskValueSet 7,3,1
EndOn




danmero
Normal user
Posts: 64
Joined: 11 May 2017, 01:19

Re: several rules

#25 Post by danmero » 10 Jun 2018, 14:00

Just to simplify, both reed should stop the motor regardless the state of the motor.

Code: Select all

  TaskValueSet 7,3,0 // Door state

On Reed2-close#Switch do
	If [Reed2-close#Switch]=1
		TaskSet,7,1// here you can set the state of the door for later use
		Event,DoorStop
	endif
endon

On Reed1-open#Switch do
	If [Reed1-open#Switch]=1
		TaskSet,7,0// here you can set the state of the door for later use
		Event,DoorStop
	endif
endon

TungstenE2
Normal user
Posts: 51
Joined: 03 Apr 2018, 21:46

Re: several rules

#26 Post by TungstenE2 » 11 Jun 2018, 21:02

thx, added your rules partly.
state of door is already known by state of reed1 and reed2.

Code: Select all

On System#Boot do
  TaskValueSet 7,1,0 // no day = 0
  TaskValueSet 7,2,200 // Helligkeit on dummy sensor
  TaskValueSet 7,3,0 // DC Motor off
  TaskValueSet 7,4,0 // Timer off
  TaskValueSet 8,1,999 // To concat of some dummys (named Dummy1#Concat) '999' just as a default ref
  timerSet,2,10
endon


// day or night
On Lichtsensor#Analog do
	if [Lichtsensor#Analog] > [Dummies#HelligkeitTriggerTag]
		TaskValueSet 7,1,1
	else
		TaskValueSet 7,1,0
	endif
endon

//close door if Taster1 is pressed and door is not closed
On Taster1-close#Switch do
	If [Taster1-close#Switch]=1 and [Reed2-close#Switch]!=1
		Event,DoorClose
	Else
		Event,DoorStop
endif
endon

//close door if Taster2 is pressed and door is not open
On Taster2-open#Switch do
	If [Taster2-open#Switch]=1 and [Reed1-open#Switch]!=1
		Event,DoorOpen
	Else
		Event,DoorStop
endif
endon

//stop door close if reed2 changes from 0 to 1
On Reed2-close#Switch do
	If [Dummies#DCMotorOn]=1 and [Reed2-close#Switch]=1
		Event,DoorStop
endif
endon

//stop door open if reed1 changes from 0 to 1
On Reed1-open#Switch do
	If [Dummies#DCMotorOn]=1 and [Reed1-open#Switch]=1
		Event,DoorStop
endif
endon

//stop motor if Reed1 or Reed2 triggered
On Reed1-open#Switch do
	If [Reed1-open#Switch]=1
		Event,DoorStop
	endif
endon

On Reed2-close#Switch do
	If [Reed2-close#Switch]=1
		Event,DoorStop
	endif
endon


// for all day close door at time if not closed
On Clock#Time=All,22:30 do 
	If [Reed2-close#Switch]!=1
		Event,DoorClose
	Else
		Event,DoorStop
endif
endon


//Events

On DoorOpen Do
If [Reed1-open#Switch]!=1
	WemosMotorShieldCMD 0 Backward 50
	TaskValueSet 7,3,1
endif
EndOn

On DoorClose Do
    If [Reed2-close#Switch]!=1
  	WemosMotorShieldCMD 0 Forward 50
	TaskValueSet 7,3,1
endif
EndOn

On DoorStop Do
	WemosMotorShieldCMD 0 Stop
	TaskValueSet 7,3,0
EndOn

danmero
Normal user
Posts: 64
Joined: 11 May 2017, 01:19

Re: several rules

#27 Post by danmero » 12 Jun 2018, 00:16

You complicate yourself
This:

Code: Select all

On Reed1-open#Switch do
	If [Dummies#DCMotorOn]=1 and [Reed1-open#Switch]=1
		Event,DoorStop
endif
endon

//stop motor if Reed1 or Reed2 triggered
On Reed1-open#Switch do
	If [Reed1-open#Switch]=1
		Event,DoorStop
	endif
endon
Should be only

Code: Select all

On Reed1-open#Switch do
	If [Reed1-open#Switch]=1
		TaskSet,7,0// here you can set the state of the door for later use
		Event,DoorStop
	endif
endon
You don't need to check the state of the motor if you want to stop it.

TungstenE2
Normal user
Posts: 51
Joined: 03 Apr 2018, 21:46

Re: several rules

#28 Post by TungstenE2 » 14 Jun 2018, 22:07

thx danmero, changed it.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests