Ejemplo n.º 1
0
class GenericOnOffOpcode(IntEnum):
    ONOFF_GET = 0x8201
    ONOFF_SET = 0x8202
    ONOFF_SET_UNACKNOWLEDGED = 0x8203
    ONOFF_STATUS = 0x8204


# fmt: on
GenericOnOffGet = Struct()

GenericOnOffSetMinimal = Struct("onoff" / Int8ul, "tid" / Int8ul)

GenericOnOffSetOptional = Struct(
    "onoff" / Int8ul,
    "tid" / Int8ul,
    "transition_time" / TransitionTimeAdapter(TransitionTime, allow_unknown=False),
    "delay" / Delay(Int8ul),
)

GenericOnOffSet = Select(GenericOnOffSetOptional, GenericOnOffSetMinimal)

GenericOnOffStatusMinimal = Struct("present_onoff" / Int8ul)

GenericOnOffStatusOptional = Struct(
    "present_onoff" / Int8ul,
    "target_onoff" / Int8ul,
    "remaining_time" / TransitionTimeAdapter(TransitionTime, allow_unknown=True),
)

GenericOnOffStatus = Select(GenericOnOffStatusOptional, GenericOnOffStatusMinimal)
Ejemplo n.º 2
0
LightCTLSetMinimal = Struct(Embedded(LightCTLDefault), "tid" / Int8ul)

LightCTLSetOptional = Struct(Embedded(LightCTLSetMinimal),
                             Embedded(OptionalSetParameters))

LightCTLSet = Select(LightCTLSetOptional, LightCTLSetMinimal)

LightCTLStatusMinimal = Struct(
    "present_ctl_lightness" / Int16ul,
    "present_ctl_temperature" / Int16ul,
)

LightCTLStatusOptional = Struct(
    Embedded(LightCTLStatusMinimal), "target_ctl_lightness" / Int16ul,
    "target_ctl_temperature" / Int16ul, "remaining_time" /
    TransitionTimeAdapter(TransitionTime, allow_unknown=True))

LightCTLStatus = Select(LightCTLStatusOptional, LightCTLStatusMinimal)

LightCTLTemperatureStatusMinimal = Struct(
    "present_ctl_temperature" / Int16ul,
    "present_ctl_delta_uv" / Int16ul,
)

LightCTLTemperatureStatusOptional = Struct(
    Embedded(LightCTLTemperatureStatusMinimal),
    "target_ctl_temperature" / Int16ul, "target_ctl_delta_uv" / Int16ul,
    "remaining_time" /
    TransitionTimeAdapter(TransitionTime, allow_unknown=True))

LightCTLTemperatureStatus = Select(LightCTLTemperatureStatusOptional,
Ejemplo n.º 3
0
    SCENE_NOT_FOUND = 0x02


# fmt: off
SceneGet = Struct()

SceneRecallMinimal = Struct(
    "scene_number" / ExprValidator(Int16ul, obj_ > 0),
    "tid" / Int8ul,
)

SceneRecallWithTransition = Struct(
    "scene_number" / ExprValidator(Int16ul, obj_ > 0),
    "tid" / Int8ul,
    "transition_time" /
    TransitionTimeAdapter(TransitionTime, allow_unknown=False),
    "delay" / Delay(Int8ul),
)

SceneRecall = NamedSelect(optional=SceneRecallWithTransition,
                          minimal=SceneRecallMinimal)

SceneStatusMinimal = Struct(
    "status_code" / EnumAdapter(Int8ul, SceneStatusCode),
    "current_scene" / Int16ul)

SceneStatusWithTargetScene = Struct(
    "status_code" / EnumAdapter(Int8ul, SceneStatusCode),
    "current_scene" / Int16ul,
    "target_scene" / Int16ul,
    "remaining_time" /