Czy wolisz polską wersję strony elektroda?
Nie, dziękuję Przekieruj mnie tam
"samp_sw_pin":"17",
"max_V":"3000",
"min_V":"2200",
"samp_pin":"23",
p.kaczmarek2 wrote:Sending HTTP GET also allows you to control other devices (e.g. Tasmoty or OBK, via cm?cmnd=COMMAND), but I don`t know if it is needed, because OBK also supports the Tasmoty Device Groups protocol anyway:
https://www.elektroda.pl/rtvforum/topic3925472.html
waitFor WiFiState 4
SendGET http:/ip?doorState=$var1
delay_s 10 (poczekam na zamknięcie drzwi)
PinDeepSleep (żeby poszedł spać aż znowu obudzę go kontaktronem)
Mad_Maxs wrote:
SendGET http:/ip?doorState=$CH1
Mad_Maxs wrote:
The question is how to extract the variable from the reed switch?
Mad_Maxs wrote:
How to extract state from BatteryADC to a variable? publishFloat "voltage" $CH1/1000 ?? (from your examples) always gives me 0
Mad_Maxs wrote:
How to code a trigger that will send SendGET when the sensor state changes during wake-up?
p.kaczmarek2 wrote:
Mad_Maxs wrote:
How to code a trigger that will send SendGET when the sensor state changes during wake-up?
This is a strange question. You currently have a script that is executed immediately after waking up, so in fact you have already created the trigger.
// save door state at boot time - it assumes that channel 5 is a temporary variable, and channel 1 is door sensor
setChannel 5 $CH1
// wait for WiFi
waitFor WiFistate 4
// send both states
SendGET http:/ip?doorState=$CH5
delay_s 2
SendGET http:/ip?doorState=$CH1
setChannel 5 $CH0
waitFor WiFiState 4
SendGET http://IP/sensor.php?doorSensor=1&sensor=$CH5&bat=$batteryLevel
delay_s 2
SendGET http://IP/sensor.php?doorSensor=1&sensor=$CH0&bat=$batteryLevel
delay_s 2
PinDeepSleep
Mad_Maxs wrote:An additional question arises: how to remove such a whip from the programmer level?
// script assumes there is a digitalInput on channel 2, which is low by default and high if user presses the button
if $CH2==1 then goto nothing
// here remaining script
(...)
// at the end of everything:
nothing:
Mad_Maxs wrote:
I think that it would be worth adding an if here that will check whether $ch5 == $ch0, and if so, it will not send a second SendGET
p.kaczmarek2 wrote:I would suggest scripting better in bat so that an additional button (e.g. with a Btn_ScriptOnly pin, or even as DigitalInput) checks whether it is pressed and if it is pressed, exits the script.
Maybe something like:
Code: text Expand Select all Copy to clipboard
// script assumes there is a digitalInput on channel 2, which is low by default and high if user presses the button
if $CH2==1 then goto nothing
// here remaining script
(...)
// at the end of everything:
nothing:
The above code will make it so that when the configuration button is pressed, "goto" will skip the rest of the script and leave the device turned on permanently (until the user reboots)
p.kaczmarek2 wrote:Mad_Maxs wrote:I think that it would be worth adding an if here that will check whether $ch5 == $ch0, and if so, it will not send a second SendGET
You`re right, I thought about it, but I didn`t want to complicate it anymore
setChannel 5 $CH0
waitFor WiFiState 4
SendGET http://ip/sensor.php?doorSensor=1&sensor=$CH5&bat=$batteryLevel
delay_s 5
if $CH5!=$CH0 then SendGET http://ip/sensor.php?doorSensor=1&sensor=$CH0&bat=$batteryLevel; delay_s 2
if $CH1==1 then goto nothing
PinDeepSleep
nothing:
if $CH5!=$CH0 then SendGET http://ip/sensor.php?doorSensor=1&sensor=$CH0&bat=$batteryLevel; delay_s 2
Quote:
I added this IF with a comparison of channels 5 and 0, just check if I wrote down the execution of two commands correctly (separated by a semicolon), are any additional brackets necessary?
Quote:
If I replaced PinDeepSleep with the DeepSleep 43 200 command, is wake-up from the pin still available, but I have a control signal every 12 hours? in ESP, excitation from the pin was independent of the code, but I want to make sure![]()
if $CH5!=$CH0 then backlog SendGET http://ip/sensor.php?doorSensor=1&sensor=$CH0&bat=$batteryLevel; delay_s 2
p.kaczmarek2 wrote:You could divide these delay_s 5 into 5 delay_s 1 (with a loop or manually) and check this safe mode pin every second
p.kaczmarek2 wrote:Currently, DeepSleep will not be woken up from the pin because there was no such option in the SDK. Only recently a PR for the SDK appeared:
https://github.com/openshwprojects/OpenBK7231N/pull/18
if $CH2==1 then goto nothing
PinDeepSleep
nothing:
if $CH5!=$CH0 then backlog SendGET http://ip/sensor.php?doorSensor=3&sensor=$CH0&bat=$batteryLevel; delay_s 2
alias check_again backlog SendGET http://ip/sensor.php?doorSensor=3&sensor=$CH0&bat=$batteryLevel; delay_s 2
if $CH5!=$CH0 then check_again
p.kaczmarek2 wrote:I posted an update, can you first disable deep sleep and then do an OTA to the version that will appear on Github in about 10 minutes (when it compiles)?
p.kaczmarek2 wrote:A lot of these sensors for one WiFi network. How far will they be from the router?
{
"vendor": "Tuya",
"bDetailed": "0",
"name": "Tuya Smart Door Sensor Wifi",
"model": "enter short model name here",
"chip": "BK7231N",
"board": "TODO",
"flags": "0",
"keywords": [
"TODO",
"TODO",
"TODO"
],
"pins": {
"8": "DoorSnsrWSleep;0",
"17": "BAT_Relay;1",
"20": "Btn;2",
"23": "BAT_ADC;1",
"26": "WifiLED;0"
}
"image": "https://obrazki.elektroda.pl/8866914500_1708590926.jpg",
"wiki": "https://www.elektroda.pl/rtvforum/topic3960149.html"
}
p.kaczmarek2 wrote:Does the device read batteries well? Maybe you need to change the constants when starting the driver?
p.kaczmarek2 wrote:Please complete the link to the image and forum ("wiki") and I will add both templates to https://openbekeniot.github.io/webapp/devicesList.html
p.kaczmarek2 wrote:I posted an update, can you first disable deep sleep and then do an OTA to the version that will appear on Github in about 10 minutes (when it compiles)?
setChannel 5 $CH0
DSEdge 1
alias check_again backlog SendGET http://ip/sensor.php?doorSensor=5&sensor=$CH0&bat=$batteryLevel; delay_s 2
waitFor WiFiState 4
SendGET http://ip/sensor.php?doorSensor=5&sensor=$CH5&bat=$batteryLevel
delay_s 5
if $CH5!=$CH0 then backlog SendGET http://ip/sensor.php?doorSensor=5&sensor=$CH0&bat=$batteryLevel; delay_s 2
if $CH2==1 then goto nothing
PinDeepSleep
nothing:
Build on Feb 22 2024 07:58:31 version 1.17.477
p.kaczmarek2 wrote:From what I see, it didn`t get into 477, but into 478:
p.kaczmarek2 wrote:Does the device read batteries well? Maybe you need to change the constants when starting the driver?