Skip to content

Commit d1e019d

Browse files
committed
Update NeoPool cmd script
1 parent 3019822 commit d1e019d

File tree

1 file changed

+57
-17
lines changed

1 file changed

+57
-17
lines changed

docs/NeoPool.md

Lines changed: 57 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ The class `NeoPoolCommands` below adds two new commands to Tasmota:
574574
Command|Parameters
575575
:---|:---
576576
NPAux<x\><a id="NPAux"></a>|`<state>`<BR>Set auxiliary relay <x\> (x=`1..4`, state = `0..2`):<ul><li>`0` - switch off auxiliary relay</li><li>`1` - switch on auxiliary relay</li>`2` - toggle auxiliary relay</li></ul>
577+
NPAntiFreeze<x\><a id="NPAntiFreeze"></a>|`<state>`<BR>Set Smart mode antifreeze (state = `0..2`):<ul><li>`0` - switch Smart mode antifreeze off</li><li>`1` - switch Smart mode antifreeze on</li>`2` - toggle Smart mode antifreeze</li></ul>
577578
NPTimer<x\><a id="NPTimer"></a>|`0` or `OFF` or `<hh:mm hh:mm>( <period>)` or `<json>`<BR>Set device timer for filtration, light and auxiliary relay (x=`1..12`)<BR> <x\>:<ul><li>`1` - Filtration timer 1</li><li>`2` - Filtration timer 2</li><li>`3` - Filtration timer 3</li><li>`4` - Light timer</li><li>`5` - Aux1 timer 1</li><li>`6` - Aux1 timer 2</li><li>`7` - Aux2 timer 1</li><li>`8` - Aux2 timer 2</li><li>`9` - Aux3 timer 1</li><li>`10` - Aux3 timer 2</li><li>`11` - Aux4 timer 1</li><li>`12` - Aux4 timer 2</li></ul><BR><ul><li>`0` or `OFF` - Switch timer off</li><li>`hh:mm hh:mm` - Start/End time pair<li>`period` - optional period interval (default seconds), use postfix (e. g. "1d") for period unit:<BR>`s` - seconds<BR>`m` - minutes<BR>`h` - hours<BR>`d` - days<BR>`w` - weeks</li><li>`json` - valid JSON string containng start-/endtime and period e. g. `#!json {"Start":"17:00","End":"22:15","Period":"1d"}`</li></ul>
578579
NPVersion<a id="NPVersion"></a>|Get the firmware info as array (firmware version and creation date)
579580

@@ -587,13 +588,14 @@ Store the following code into a Tasmota file by using the WebGUI "Console" / "Ma
587588
```berry
588589
# File: neopoolcmd.be
589590
#
590-
# Add commands NPAux, NPTimer and NPVersion
591+
# Add commands NPAux, NPAntiFreeze, NPTimer and NPVersion
591592

592593
# Neopool definitions
593594

594595
MBF_POWER_MODULE_REGISTER = 0x000C
595596
MBF_POWER_MODULE_DATA = 0x000D
596597
MBF_RELAY_STATE = 0x010E
598+
MBF_PAR_SMART_ANTI_FREEZE = 0x41A
597599

598600
# configuration of the system timers
599601
MBF_PAR_TIMER_BLOCK_FILT_INT1 = 0x0434
@@ -681,11 +683,6 @@ Store the following code into a Tasmota file by using the WebGUI "Console" / "Ma
681683
MBF_PAR_TIMER_BLOCK_AUX4_INT1
682684
]
683685

684-
685-
686-
687-
688-
689686
import string
690687
import json
691688

@@ -771,7 +768,7 @@ Store the following code into a Tasmota file by using the WebGUI "Console" / "Ma
771768
end
772769

773770
# NPAux<x> OFF|0|ON|1|TOGGLE|2 (<x> = 1..4)
774-
def NPAux(cmd, idx, payload, payload_json, subcmd)
771+
def NPAux(cmd, idx, payload)
775772
var ctrl, parm
776773

777774
if idx < 1 || idx > 4
@@ -786,10 +783,11 @@ Store the following code into a Tasmota file by using the WebGUI "Console" / "Ma
786783
ctrl = MBV_PAR_CTIMER_ALWAYS_ON
787784
elif 2 == parm
788785
try
789-
ctrl = (self.Read(cmd, "NPRead", MBF_RELAY_STATE) >> (idx+2)) & 1 ? MBV_PAR_CTIMER_ALWAYS_OFF : MBV_PAR_CTIMER_ALWAYS_ON
786+
ctrl = self.Read(cmd, "NPRead", MBF_RELAY_STATE)
790787
if nil == ctrl
791788
return
792789
end
790+
ctrl = (ctrl >> (idx+2)) & 1 ? MBV_PAR_CTIMER_ALWAYS_OFF : MBV_PAR_CTIMER_ALWAYS_ON
793791
except ..
794792
return
795793
end
@@ -801,19 +799,59 @@ Store the following code into a Tasmota file by using the WebGUI "Console" / "Ma
801799
tasmota.cmd("NPExec")
802800
else
803801
try
804-
ctrl = (self.Read("NPRead", MBF_RELAY_STATE) >> (idx+2)) & 1
802+
ctrl = self.Read(cmd, "NPRead", MBF_RELAY_STATE)
805803
if nil == ctrl
806804
return
807805
end
806+
ctrl = (ctrl >> (idx+2)) & 1
808807
except ..
809808
return
810809
end
811810
end
812-
if subcmd != nil
813-
tasmota.resp_cmnd(string.format('{"%s":"%s"}', subcmd, ctrl == (parm != nil ? 4 : 0) ? self.TEXT_OFF : self.TEXT_ON))
811+
tasmota.resp_cmnd(string.format('{"%s%d":"%s"}', cmd, idx, ctrl == (parm != nil ? 4 : 0) ? self.TEXT_OFF : self.TEXT_ON))
812+
end
813+
814+
# NPAntiFreeze OFF|0|ON|1|TOGGLE|2
815+
def NPAntiFreeze(cmd, idx, payload)
816+
var ctrl, parm
817+
parm = self.ParmSwitch(payload, self.TEXT_TOGGLE)
818+
if parm != nil
819+
if 0 == parm
820+
ctrl = 0
821+
elif 1 == parm
822+
ctrl = 1
823+
elif 2 == parm
824+
try
825+
ctrl = self.Read(cmd, "NPRead", MBF_PAR_SMART_ANTI_FREEZE)
826+
if nil == ctrl
827+
return
828+
end
829+
if 1 == ctrl
830+
ctrl = 0
831+
else
832+
ctrl = 1
833+
end
834+
except ..
835+
return
836+
end
837+
else
838+
tasmota.resp_cmnd_error()
839+
return
840+
end
841+
tasmota.cmd(string.format("NPWrite 0x%04X,%d", MBF_PAR_SMART_ANTI_FREEZE, ctrl))
842+
tasmota.cmd("NPExec")
814843
else
815-
tasmota.resp_cmnd(string.format('{"%s%d":"%s"}', cmd, idx, ctrl == (parm != nil ? 4 : 0) ? self.TEXT_OFF : self.TEXT_ON))
844+
try
845+
ctrl = self.Read(cmd, "NPRead", MBF_PAR_SMART_ANTI_FREEZE)
846+
if nil == ctrl
847+
return
848+
end
849+
except ..
850+
tasmota.resp_cmnd_error()
851+
return
852+
end
816853
end
854+
tasmota.resp_cmnd(string.format('{"%s":"%s"}', cmd, ctrl ? self.TEXT_ON : self.TEXT_OFF))
817855
end
818856

819857
# NPTimer<x> 0|OFF|<hh:mm hh:mm>( <period>)|<json> (<x> = 1..12)
@@ -856,7 +894,7 @@ Store the following code into a Tasmota file by using the WebGUI "Console" / "Ma
856894
)
857895
end
858896

859-
def NPTimer(cmd, idx, payload, raw)
897+
def NPTimer(cmd, idx, payload)
860898
var parm
861899

862900
if idx < 1 || idx > 12
@@ -965,18 +1003,20 @@ Store the following code into a Tasmota file by using the WebGUI "Console" / "Ma
9651003

9661004
def init()
9671005
# get tasmota settings
968-
self.TEXT_OFF = tasmota.cmd("StateText1")['StateText1']
969-
self.TEXT_ON = tasmota.cmd("StateText2")['StateText2']
970-
self.TEXT_TOGGLE = tasmota.cmd("StateText3")['StateText3']
1006+
self.TEXT_OFF = tasmota.cmd('StateText1').find('StateText1', 'OFF')
1007+
self.TEXT_ON = tasmota.cmd('StateText2').find('StateText2', 'ON')
1008+
self.TEXT_TOGGLE = tasmota.cmd('StateText3').find('StateText3', 'TOGGLE')
9711009
# add commands
9721010
tasmota.add_cmd('NPAux', / cmd, idx, payload -> self.NPAux(cmd, idx, payload))
973-
tasmota.add_cmd('NPTimer', / cmd, idx, payload, raw -> self.NPTimer(cmd, idx, payload, raw))
1011+
tasmota.add_cmd('NPAntiFreeze', / cmd, idx, payload -> self.NPAntiFreeze(cmd, idx, payload))
1012+
tasmota.add_cmd('NPTimer', / cmd, idx, payload -> self.NPTimer(cmd, idx, payload))
9741013
tasmota.add_cmd('NPVersion', / cmd -> self.NPVersion(cmd))
9751014
end
9761015

9771016
def deinit()
9781017
# remove commands
9791018
tasmota.remove_cmd('NPAux')
1019+
tasmota.remove_cmd('NPAntiFreeze')
9801020
tasmota.remove_cmd('NPTimer')
9811021
tasmota.remove_cmd('NPVersion')
9821022
end

0 commit comments

Comments
 (0)