I have modified the rule to correctly get the values but still unable to parse the regex correctly to get the values out. Could anyone please suggest how to resolve it?
Rule:
rule "Switcher Output"
when
Item Switcher_Command_Output changed
then
val SwitcherStatus = Switcher_Command_Output.state.toString.split('[+]').get(9)
val SwitcherCurrent = Switcher_Command_Output.state.toString.split('[+]').get(10)
val SwitcherPowerConsumption = Switcher_Command_Output.state.toString.split('[+]').get(11)
logInfo("SwitcherStatus", "---"+ SwitcherStatus)
var SwitcherStatusVar = transform("REGEX", "Device is (.*)", SwitcherStatus.toString)
SwitchSwitcherStatus.postUpdate(SwitcherStatusVar)
logInfo("SwitcherCurrent","---"+ SwitcherCurrent+"---")
var SwitcherCurrentVar = transform("REGEX",".*(\\d(.)\\d).*", SwitcherCurrent.toString)
NumberSwitcherCurrent.postUpdate(SwitcherCurrentVar)
logInfo("SwitcherPowerConsumption", "---"+ SwitcherPowerConsumption)
var SwitcherPowerConsumptionVar = transform("REGEX", ".*(\\d).*", SwitcherPowerConsumption.toString)
NumberSwitcherPowerConsumption.postUpdate(SwitcherPowerConsumptionVar)
end
Log:
[+] Done! to =========================================================
+ Switcher V2 Python +
+ Reverse Engineering and Coding By: +
+ Aviad Golan (@AviadGolan) and Shai Rod (@NightRang3r) +
=========================================================
[*] Sending Login Packet to Switcher...
[+] Received SessionID: 00000000
[*] Getting Switcher state...
[+] Device Name: Switcher Touch
[+] Device is ON
[+] Electric Current is: 11.1(A)
[+] Power consumption is: 2446(W)
[+] Device is configured to auto shutdown in: 2:59 hour(s)
[*] Auto shutdown device in: 2:58:47
[+] Done!
2019-10-29 01:15:48.280 [vent.ItemStateChangedEvent] - System_CPU_Uptime changed from 11520.1 to 11522.1
==> /var/log/openhab2/openhab.log <==
2019-10-29 01:15:48.805 [INFO ] [marthome.model.script.SwitcherStatus] - ---] Device is ON
[
==> /var/log/openhab2/events.log <==
2019-10-29 01:15:48.817 [vent.ItemStateChangedEvent] - SwitchSwitcherStatus changed from NULL to
==> /var/log/openhab2/openhab.log <==
2019-10-29 01:15:48.820 [INFO ] [arthome.model.script.SwitcherCurrent] - ---] Electric Current is: 11.1(A)
[---
==> /var/log/openhab2/events.log <==
2019-10-29 01:15:48.831 [vent.ItemStateChangedEvent] - NumberSwitcherCurrent changed from 0.0 to 1.1
==> /var/log/openhab2/openhab.log <==
2019-10-29 01:15:48.836 [INFO ] [odel.script.SwitcherPowerConsumption] - ---] Power consumption is: 2446(W)
[
==> /var/log/openhab2/events.log <==
2019-10-29 01:15:48.849 [vent.ItemStateChangedEvent] - NumberSwitcherPowerConsumption changed from 0 to 6
2019-10-29 01:21:04.328 [vent.ItemStateChangedEvent] - Switcher_Command_Output changed from =========================================================
+ Switcher V2 Python +
+ Reverse Engineering and Coding By: +
+ Aviad Golan (@AviadGolan) and Shai Rod (@NightRang3r) +
=========================================================
[*] Sending Login Packet to Switcher…
[+] Received SessionID: 00000000
[*] Getting Switcher state…
[+] Device Name: Switcher Touch
[+] Device is ON
[+] Electric Current is: 11.0(A)
[+] Power consumption is: 2417(W)
[+] Device is configured to auto shutdown in: 2:59 hour(s)
[*] Auto shutdown device in: 2:54:34
[+] Done! to =========================================================
+ Switcher V2 Python +
+ Reverse Engineering and Coding By: +
+ Aviad Golan (@AviadGolan) and Shai Rod (@NightRang3r) +
=========================================================
[*] Sending Login Packet to Switcher…
[+] Received SessionID: 00000000
[*] Getting Switcher state…
[+] Device Name: Switcher Touch
[+] Device is ON
[+] Electric Current is: 11.2(A)
[+] Power consumption is: 2463(W)
[+] Device is configured to auto shutdown in: 2:59 hour(s)
[*] Auto shutdown device in: 2:53:31
[+] Done!
==> /var/log/openhab2/openhab.log <==
2019-10-29 01:21:04.349 [INFO ] [marthome.model.script.SwitcherStatus] - —] Device is ON
[
2019-10-29 01:21:04.366 [INFO ] [arthome.model.script.SwitcherCurrent] - —] Electric Current is: 11.2(A)
[—
2019-10-29 01:21:04.380 [INFO ] [odel.script.SwitcherPowerConsumption] - —] Power consumption is: 2463(W)
[
==> /var/log/openhab2/events.log <==
2019-10-29 01:21:04.385 [vent.ItemStateChangedEvent] - NumberSwitcherCurrent changed from 1.0 to 1.2
2019-10-29 01:21:04.398 [vent.ItemStateChangedEvent] - NumberSwitcherPowerConsumption changed from 7 to 3