Constructor.
the URL helper to use
the auth builder to authenticate requests with; the required credentials must be set appropriately
the ID of the node with the control to manage
the ID of the control to manage
Optional
queryApi: SolarQueryApia URL helper for accessing node datum via SolarQuery; if not provided one
will be created using the environment from api
. Useful in a development
environment when the SolarUser and SolarQuery hosts are different.
Optional
callbackA callback function, which is called after the state of the control changes.
The this
reference will be set to this object. If an error has occurred,
the error will be passed as the first argument.
Readonly
controlThe control ID to manage.
Readonly
nodeThe node ID to manage the control on.
The refresh rate, in milliseconds, when a toggle instruction is queued. Defaults to 5 seconds.
The refresh rate, in milliseconds. Defaults to 20 seconds.
Test if a state change is pending confirmation.
true
if a state change is pending (not complete)
Start automatically updating the status of the configured control.
Optional
when: numberan optional offset in milliseconds to start at (defaults to 20)
this object
Stop automatically updating the status of the configured control.
this object
Refresh the control state from SolarNetwork.
Once the ControlToggler#start method is called, this method is invoked periodically automatically. Only call this directly if you need to manually update the state of the control.
promise that resolves after getting the updated state
Set the desired control value.
the control value to set
a promise that resolves to the enqueued instruction
Manage the state of a boolean control switch using SolarNetwork
SetControlParameter
instructions.Use an instance of this class to keep track of, and update the state of, a single switch-like control configured on a SolarNode. Because updating the state of a control is an asynchronous process involving multiple steps, this class simplifies this with a promise-based API that will be resolved when the control value changes.
If the ControlToggler#start method is called, the toggler will make periodic calls to SolarNetwork to get the most recent value for the configured control ID, which it treats as a ControlDatum
sourceId
value. Thus if some other process changes the control, the toggler will eventually pick up that change and invoke the callback function.Example