Help on rules with domoticz

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Mijn.Handen
New user
Posts: 7
Joined: 23 Dec 2016, 07:56

Help on rules with domoticz

#1 Post by Mijn.Handen » 27 Dec 2016, 09:07

Hi all,
As we are all playing with the great ESPeasy software I am struggling with the rules. I am not a programmer and as there is hardly any documentation available I bumped into a dead stop. Would someone be able to help me out?
In my believe in a domotica system all parts should work as much autonomous as possible. The 'server' should be there for remote control, push settings and logging but the individual parts should work on their own. This means you depend a lot on the local rules in your projects.
I have created a ledstrip dimmer with a PIR and a IR receiver. The idea is when you pass the light it pops on for 30 seconds and turns off again. If you want the light on you can either grab Domoticz or the IR remote control and control the intensity and it should be on till you switch it off. If you remove Domoticz out of the equation the IR remote should still work. Even when you remove the network it should still work with the remote and if switched off it should still work on the PIR.
My setup:
  • ESP-01 loaded with ESPeasy 147_RC8 and serial communication disabled to gain 2 extra GPIO’s.
    On GPIO 0 IR receiver
    On GPIO 1
    On GPIO 2 Dimmer
    On GPIO 3 PIR
The electrical setup is working as a charm. The dimmer is working controlled by Domoticz, the PIR is sending a pulse when you pass it and the IR receiver pops out a number when you hit the button of the simple IR remote control. This has only 4 buttons, on, off, + and -. The remote control I have not programmed or done anything with. That is the next phase for me.
These are the rules I have put in:

Code: Select all

on pir#Switch=1.00 do
pwm,2,127,1000
timerSet 1,30
endon

on Rules#Timer=1 do
pwm,2,0,1000
endon
so after passing a nice, not too bright glow comes out of the ledstrip (127) and it dims up in 1000 ms (1sec) after 30 seconds it fades out in 1000ms as well.

At this moment, I can control it with Domoticz but as soon as you pass it it will dim to the set level and goes off after 30 seconds. This is because the local rules overrule the Domoticz setting. I know why this is but don’t know how to solve it…
So I experimented with if statements and let the dimmer in Domoticz send an 'on action' 'http://192.168.xx.xx/control?cmd=event,dimon,1' when you switch it on in Domoticz and 'off action' 'http://192.168.12.37/control?cmd=event,dimon,0' when you switch if off. Just to have Domoticz report to the ESP it will overrule the PIR action and keep it on even when passing. But no luck.

I also would like to use the IR remote control to control the brightness and keep it to that level, report that level to Domoticz (so it knows how bright it’s set) and when switched off (reported to Domoticz) it goes back to the PIR operation. When you switch it on it goes back to the same level it was switched off to (report that to Domoticz again). This needs to be done through the rules of ESPeasy so it’s independent of Domoticz or network.

Why the focus on independency? I guess we all been there. The misses calling you in a panic "your things" do not work. So, you have to troubleshoot remotely and after 35 micro seconds the misses is irritated. In the end it’s the network having a hick-up or she unplugged the Domoticz raspberry pi. To avoid this as much as possible and have a stable and steady system I prefer to have all items as autonomously as possible. The bigger the independency the larger your success rate will be and the bigger investment you can make to automate your house. I do realize I am taking the difficult route here with all my wishes but I think a lot of projects get removed after a few weeks because of this. At least it does for me. After all, you are not the only one in the house.

Is anyone able to help me out on this one? All help is appreciated.

MH

Mijn.Handen
New user
Posts: 7
Joined: 23 Dec 2016, 07:56

Re: Help on rules with domoticz

#2 Post by Mijn.Handen » 28 Dec 2016, 08:13

I found this in the forum somewhere: viewtopic.php?f=6&t=1982&hilit=pir+reset+timer
if i read this correctly I can do this

Code: Select all

on pir#Switch=1.00 do
if dimon=0 do (if [dimon#light]=0 do ??? )
pwm,2,80,1000
timerSet 1,30
endon

on Rules#Timer=1 do
pwm,2,0,1000
endon
Time for some testing tonight.. :)

MH

Mijn.Handen
New user
Posts: 7
Joined: 23 Dec 2016, 07:56

Re: Help on rules with domoticz

#3 Post by Mijn.Handen » 28 Dec 2016, 20:46

It was less simple that I expected. Had to create a dummy on device 3 and send "http://192.168.xx.xx/control?cmd=event,dimon" and "http://192.168.xx.xx/control?cmd=event,dimoff" and make rules to set the dummy. Could not find a direct HTTP command to set the dummy. but it works....

Code: Select all

on dimon do
  TaskValueSet 3,1,1
endon
on dimoff do
  TaskValueSet 3,1,0
endon

on pir#Switch=1.00 do
 if [dumdim#Dummy]=0 do
  pwm,2,80,1000
  timerSet 1,30
 else
 endif
endon
on Rules#Timer=1 do
 pwm,2,0,1000
endon
Now the LUA for the dimmer needs to be smarter. when you hit the on button it dims all the way up and not the set level... up for the next step..

MH

hugo11
Normal user
Posts: 17
Joined: 08 Nov 2016, 20:30

Re: Help on rules with domoticz

#4 Post by hugo11 » 06 Jan 2017, 10:27

Hi Mijn.Handen,

I have a similar setup than you but I'm fighting with the PIR.

I would like to send a HTTP request from ESP when the PIR triggers, the issues I have:
- There is a delay between triggering the PIR and ESP recognizing it
- What is the configuration of the SWITCH in ESP for PIR ?

Thanks a lot.

Mijn.Handen
New user
Posts: 7
Joined: 23 Dec 2016, 07:56

Re: Help on rules with domoticz

#5 Post by Mijn.Handen » 03 Feb 2017, 14:29

on the PIR I have:
Device: switch input
pull up ticked
GPOI = 3
Switch Type: switch
Switch Button Type: Normal switch

So nothing special. no delays here.

MH

rosskopp
New user
Posts: 5
Joined: 16 Aug 2016, 09:36

Re: Help on rules with domoticz

#6 Post by rosskopp » 04 Mar 2017, 22:33

hugo11 wrote:Hi Mijn.Handen,

I have a similar setup than you but I'm fighting with the PIR.

I would like to send a HTTP request from ESP when the PIR triggers, the issues I have:
- There is a delay between triggering the PIR and ESP recognizing it
- What is the configuration of the SWITCH in ESP for PIR ?

Thanks a lot.
have you tried to shorten the delay in the settings of the device? change the delay to 1 or 0, and your ESP should send updates every second no matter if there is a trigger sent from the PIR.

The_Rascal
New user
Posts: 4
Joined: 09 Mar 2017, 01:56

Re: Help on rules with domoticz

#7 Post by The_Rascal » 09 Mar 2017, 22:17

Mijn.Handen wrote: 28 Dec 2016, 20:46 ******** xx/control?cmd=event,dimoff" and make rules to set the dummy. Could not find a direct HTTP command to set the dummy. but it works....

Code: Select all

on dimon do
  TaskValueSet 3,1,1
endon
on dimoff do
  TaskValueSet 3,1,0
endon

on pir#Switch=1.00 do
 if [dumdim#Dummy]=0 do
  pwm,2,80,1000
  timerSet 1,30
 else
 endif
endon
on Rules#Timer=1 do
 pwm,2,0,1000
endon
Now the LUA for the dimmer needs to be smarter. when you hit the on button it dims all the way up and not the set level... up for the next step..

MH
I use i setpoints sent by Domoticz in my scrips so ive changed my scrips to suit yours. This might help

Code: Select all

http://192.168.xx.xx/control?cmd=event,Dimsettings='SETTINGS_TO_BE_USED'
In esprules i use this

Code: Select all

on Dimsettings do
  TaskValueSet 3,1,%eventvalue%         /// This will set the setpoint for Device 3, Value 1, 'SETTINGS_TO_BE_USED'
endon
Hope this helps.

Post Reply

Who is online

Users browsing this forum: No registered users and 23 guests