allenporter/pyrainbird

CurrentRunTimeRequest missing in sipcommands

wulle-80 opened this issue · 1 comments

To get the remaining seconds in an active zone the "CurrentRunTimeRequest" function is pretty useful.
Here is how I added it to the code:
(sipcommands) ControllerCommands:
CurrentRunTimeRequest:
command: 3B
parameter: 0
response: BB
length: 2

'BB':
length: 12
type: CurrentRunTimeResponse
activeStation:
position: 7
length: 1
secondsRemaining1:
position: 8
length: 2
secondsRemaining2:
position: 10
length: 2

The response looks like this:
DEBUG:pyrainbird:Response: {"jsonrpc": "2.0", "result":{"length":50, "data":"BB0100012C010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}, "id": 10377}
DEBUG:pyrainbird:Response: {'secondsRemaining2': '01', 'secondsRemaining1': '2C', 'type': 'CurrentRunTimeResponse', 'activeStation': '1'}

To get the time in seconds the response is a little confusing!!
--> the response is: 2C01
--> you have to take byte 3&4: 01
--> take than byte 1&2: 2C and put it back together in the opposite order: 012C
--> convert from HEX to Decimal: 012C = 300 seconds

May be someone can add this to the code and make a function out of this??

Instead of using CurrentRunTimeRequest, it seems like it may be much simpler to use the combined controller state call which can return a ControllerState which includes the remaining run time plus a bunch of other information in a single call.