Protocol¶
Constatnts¶
skydance.protocol.PORT
¶
A port used for communication with a relay.
skydance.protocol.HEAD
¶
A magic byte sequence used as a header for each command and response.
skydance.protocol.TAIL
¶
A magic byte sequence marking end of each command and response.
skydance.protocol.State
¶
Holds state of a connection.
increment_frame_number(self)
¶
Increment a frame number used by a relay to reconstruct a network stream.
Important
The frame number must be (manually) incremented after each command.
Commands¶
skydance.protocol.Command
¶
A base command.
body: bytes
property
readonly
¶
Return byte body which represents the command core.
The returned value exclude HEAD,
frame number and TAIL. These are added
automatically in Command.raw
.
raw
property
readonly
¶
Return complete byte output of a command ready to send over network.
__init__(self, state)
special
¶
Create a Command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state |
State |
A state of connection used to generate byte output of a command. |
required |
skydance.protocol.PingCommand
¶
Ping a relay to raise a communication error if something is wrong.
skydance.protocol.ZoneCommand
¶
skydance.protocol.PowerCommand
¶
Power a Zone on/off.
__init__(self, *args, *, power, **kwargs)
special
¶
Create a PowerCommand.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
|
See ZoneCommand. |
() |
power |
bool |
A power on/off state. |
required |
**kwargs |
|
See ZoneCommand. |
{} |
skydance.protocol.PowerOnCommand
¶
skydance.protocol.PowerOffCommand
¶
skydance.protocol.MasterPowerCommand
¶
skydance.protocol.MasterPowerOnCommand
¶
skydance.protocol.MasterPowerOffCommand
¶
skydance.protocol.BrightnessCommand
¶
Change brightness of a Zone.
__init__(self, *args, *, brightness, **kwargs)
special
¶
Create a BrightnessCommand.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
|
See ZoneCommand. |
() |
brightness |
int |
A brightness level between 1-255 (higher = more bright). |
required |
**kwargs |
|
See ZoneCommand. |
{} |
validate_brightness(brightness)
staticmethod
¶
Validate a brightness level.
Exceptions:
Type | Description |
---|---|
ValueError |
If brightness level is invalid. |
skydance.protocol.TemperatureCommand
¶
Change white temperature of a Zone.
__init__(self, *args, *, temperature, **kwargs)
special
¶
Create a TemperatureCommand.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
|
See ZoneCommand. |
() |
temperature |
int |
A temperature level between 0-255 (higher = more cold). |
required |
**kwargs |
|
See ZoneCommand. |
{} |
validate_temperature(temperature)
staticmethod
¶
Validate a temperature level.
Exceptions:
Type | Description |
---|---|
ValueError |
If temperature level is invalid. |
skydance.protocol.RGBWCommand
¶
Change color of a Zone.
__init__(self, *args, *, red, green, blue, white, **kwargs)
special
¶
Create a RGBWCommand.
All component levels are between 0-255, where higher number means more intensive color component.
At least one color component must be set to non-zero.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
|
See ZoneCommand. |
() |
red |
int |
A red level. |
required |
green |
int |
A green level. |
required |
blue |
int |
A blue level. |
required |
white |
int |
A white level. |
required |
**kwargs |
|
See ZoneCommand. |
{} |
validate_component(component, hint)
staticmethod
¶
Validate a component level.
Exceptions:
Type | Description |
---|---|
ValueError |
If component level is invalid. |
skydance.protocol.GetNumberOfZonesCommand
¶
Get number of zones available.
skydance.protocol.GetZoneInfoCommand
¶
Discover a zone according to it's number.
validate_zone(zone)
staticmethod
¶
Validate a zone number.
It may be invalid either because it is not a number or it may be outside of range defined by a SkyDance app.
Exceptions:
Type | Description |
---|---|
ValueError |
If zone number is invalid. |
Responses¶
skydance.protocol.Response
¶
A base response.
skydance.protocol.GetNumberOfZonesResponse
¶
Parse a response for GetNumberOfZonesCommand
.
See: GetNumberOfZonesCommand
.
number
property
readonly
¶
Return number of zones available.
skydance.protocol.GetZoneInfoResponse
¶
Parse a response for GetZoneInfoCommand
.
See: GetZoneInfoCommand
.