Skip to content

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

A base command which controls a specific Zone.

__init__(self, *args, *, zone, **kwargs) special

Create a ZoneCommand.

Parameters:

Name Type Description Default
*args

See Command.

()
zone int

A zone number to control.

required
**kwargs

See Command.

{}

validate_zone(zone) staticmethod

Validate a zone number.

Exceptions:

Type Description
ValueError

If zone number is invalid.

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

Power all zones on/off.

__init__(self, *args, *, power, **kwargs) special

Create a MasterPowerCommand.

Parameters:

Name Type Description Default
*args

See Command.

()
power bool

A power on/off state.

required
**kwargs

See Command.

{}

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.

body: bytes property readonly

Return byte body which represents the command core.

The returned value exclude HEAD, frame number and TAIL.

__init__(self, raw) special

Create a Response.

Parameters:

Name Type Description Default
raw bytes

Raw bytes received as a response.

required

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.

name: str property readonly

Return a zone name.

type: ZoneType property readonly

Return a zone type.