Pulse switch via json and via button press Sonoff esp

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Nephylim
New user
Posts: 6
Joined: 26 Oct 2017, 15:29

Pulse switch via json and via button press Sonoff esp

#1 Post by Nephylim » 01 Nov 2017, 13:29

Hi there,
I am trying o integrate a light, which requires a momentary switch into domoticz.
It should be switchable at the light itself via a pushbutton and controllable from domoticz via a json command.

The hard part is taht i need a variable which trasmits the status of the light do domoticz.
I tried to use the build in LED for that.

My rule looks like this
on Knopf#Switch=0 do
Pulse,12,1,250
if [LED#Switch]=1
gpio,13,1
else
gpio,13,0
endif
endon

on an do
Pulse,12,1,250
gpio,13,0
endon

on aus do
Pulse,12,1,250
gpio,13,1
endon

the first part should be the reaction to the switch. ist works prefectly on its own. The second part should be the reavtion to the json command, which is on or off.
If I push the button on the sonoff it pulses on the relay three times and I don't know why.

Is it possible to refer to an event from inside the rule? kindoff like if button presses and led off -> event an
or can i just trigger the Knopf#switch via json

or the easiest way. can in switch 2 gpios in one json command.

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Pulse switch via json and via button press Sonoff esp

#2 Post by toffel969 » 01 Nov 2017, 15:48

Just call an event from domoticz . Instead of "gpio,13,0" as command take "event,aus". It will trigger the event aus.same works within rules
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

Nephylim
New user
Posts: 6
Joined: 26 Oct 2017, 15:29

Re: Pulse switch via json and via button press Sonoff esp

#3 Post by Nephylim » 01 Nov 2017, 17:03

my problem is, taht i cannot call events that are not on top of the rules. for example

on Knopf#Switch=0 do
Pulse,12,1,250
if [LED#Switch]=1
gpio,13,1
else
gpio,13,0
endif
endon

on schalter do
Pulse,12,1,250
if [LED#Switch]=1
gpio,13,1
else
gpio,13,0
endif

so i need it to do the exact same action wether the button is pressed or it receives a switch command from json.
But if I trigger

http://192.168.0.65/control?cmd=event,schalter
it just responds ok and nothing happens. The pushbutton works as it should.
How can i change the rule so that this will work.

Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests