My first post… I new in this forum, new with espeasy, new with esp…
I’d like to use a Sonoff 4CHR3 to open and close 4 valves, driven by Domoticz.
So far I think I’ve succeeded in flashing the Sonoff. To be checked and for the record (for other beginners like me, because it was difficult for me to find information that are obvious for most of the community), I did:
what is described at the beginning of this video https://notenoughtech.com/sonoff/flashi ... usel-23132
with info how to put the FTD1232 (USB to TTL Serial Adapter) on 3.3V (and not 5V) with the jumper https://wombat3.kozo.ch/j/smarthome/985 ... -operation
I took this release mega-20210223 https://github.com/letscontrolit/ESPEas ... a-20210223
and the normal esp8285 1M bin Did I took the right version, it seems to be pre-release, is there a release?
I didn’t succeeded with the postflash action, but in the end I could connect the Sonoff 4CHR3
I did 4 buttons and 4 relays like this And rules like this
Code: Select all
on Button1#State do
if [Relay1#State]=0
gpio,12,1
else
gpio,12,0
endif
endon
Code: Select all
on System#Boot do
gpio,12,0
gpio,5,0
gpio,4,0
gpio,15,0
endon
So I added a flag to avoid it
Code: Select all
on System#Boot do
Let, 1, 0
Let, 2, 0
Let, 3, 0
Let, 4, 0
gpio,12,0
gpio,5,0
gpio,4,0
gpio,15,0
Endon
Code: Select all
on Button1#State do
LogEntry,'*** Button1 ? ***'
if [int#1]!=0
LogEntry,'*** Button1 OK ***'
if [Relay1#State]=0
gpio,12,1
else
gpio,12,0
endif
endif
Let, 1, 1
Endon
What is the best practice to handle this?
After I added a communication with Domoticz with mqtt to update user variables like this
Code: Select all
on Button1#State do
LogEntry,'*** Button1 ? ***'
if [int#1]!=0 // gpio 0 is at 0 on boot
LogEntry,'*** Button1 OK ***'
if [Relay1#State]=0
gpio,12,1
Publish domoticz/in,'{"command": "setuservariable", "idx": 13, "value": 30 }'
else
gpio,12,0
Publish domoticz/in,'{"command": "setuservariable", "idx": 13, "value": 0 }'
endif
endif
Let, 1, 1
Endon
This part seemed to be ok
With the other direction troubles arrived
I used the Generic - MQTT Import to receive value from Domoticz And a script in Domoticz triggered by the user variable update
Code: Select all
on = {
variables = VARIABLES
},
[…]
mosquitto_pub -t domoticz/out/RSDz1 -m 77
Log extract
Code: Select all
24310: inputswitchstate is deprecatedinputSwitchState,4,0.00
24319: inputswitchstate is deprecatedinputSwitchState,5,0.00
24327: inputswitchstate is deprecatedinputSwitchState,6,0.00
24337: inputswitchstate is deprecatedinputSwitchState,7,0.00
24364: IMPT : [RelaysSecondsInDz#RelaySecondsInDz1] : 77.00
24371: EVENT: Button1#State=0
24378: ACT : LogEntry,'*** Button1 ? ***'
24380: *** Button1 ? ***
24389: ACT : LogEntry,'*** Button1 OK ***'
24391: *** Button1 OK ***
24419: ACT : gpio,12,0
24422: GPIO : port#12: set to 0
24429: ACT : Publish domoticz/in,'{'command': 'setuservariable', 'idx': 13, 'value': 0 }'
24448: ACT : Let, 1, 1
24678: EVENT: Button2#State=0
25406: *** Button4 OK ***
25423: ACT : gpio,15,1
25425: GPIO : port#15: set to 1
25431: ACT : Publish domoticz/in,'{'command': 'setuservariable', 'idx': 16, 'value': 30 }'
25463: ACT : Let, 4, 1
After the system never stops and all relays are switched on and off ; I had to stop the script on Domoticz to stop it!
What is wrong in my understanding?
What are the best practice to avoid this?