# SPDX-License-Identifier: BSD-3-Clause
#
# Copyright 2026 Raritan Inc. All rights reserved.
#
# This is an auto-generated file.

#
# Section generated by IdlC from "ZigbeeDevice.idl"
#

import raritan.rpc
from raritan.rpc import Interface, Structure, ValueObject, Enumeration, typecheck, DecodeException
import raritan.rpc.idl

import raritan.rpc.zigbee


# interface
class ZigbeeDevice(Interface):
    idlType = "zigbee.ZigbeeDevice:1.0.0"

    CLUSTER_BASIC = 0x0

    CLUSTER_POWER_CONFIGURATION = 0x1

    CLUSTER_RSSI = 0xb

    CLUSTER_CONTACT_CLOSURE = 0xf

    CLUSTER_TEMPERATURE = 0x402

    CLUSTER_HUMIDITY = 0x405

    # structure
    class MetaData(Structure):
        idlType = "zigbee.ZigbeeDevice.MetaData:1.0.0"
        elements = ["sourceId", "clusters", "preferredSlot"]

        def __init__(self, sourceId=0, clusters=[], preferredSlot=0):
            typecheck.is_int(sourceId, AssertionError)
            for x0 in clusters:
                typecheck.is_int(x0, AssertionError)
            typecheck.is_int(preferredSlot, AssertionError)

            self.sourceId = sourceId
            self.clusters = clusters
            self.preferredSlot = preferredSlot

        @classmethod
        def decode(cls, json, agent, useDefaults=False):
            obj = cls(
                sourceId = json['sourceId'] if 'sourceId' in json or not useDefaults else 0,
                clusters = [x0 for x0 in json['clusters']] if 'clusters' in json or not useDefaults else [],
                preferredSlot = json['preferredSlot'] if 'preferredSlot' in json or not useDefaults else 0,
            )
            return obj

        def encode(self):
            json = {}
            json['sourceId'] = self.sourceId
            json['clusters'] = [x0 for x0 in self.clusters]
            json['preferredSlot'] = self.preferredSlot
            return json

    # structure
    class ClusterValue(Structure):
        idlType = "zigbee.ZigbeeDevice.ClusterValue:1.0.0"
        elements = ["id", "endpoint", "attribute", "timestamp", "value"]

        def __init__(self, id=0, endpoint=0, attribute=0, timestamp=None, value=""):
            typecheck.is_int(id, AssertionError)
            typecheck.is_int(endpoint, AssertionError)
            typecheck.is_int(attribute, AssertionError)
            typecheck.is_time(timestamp, AssertionError)
            if not typecheck._is_int(value):
                typecheck.is_string(value, AssertionError)

            self.id = id
            self.endpoint = endpoint
            self.attribute = attribute
            self.timestamp = timestamp
            self.value = value

        @classmethod
        def decode(cls, json, agent, useDefaults=False):
            obj = cls(
                id = json['id'] if 'id' in json or not useDefaults else 0,
                endpoint = json['endpoint'] if 'endpoint' in json or not useDefaults else 0,
                attribute = json['attribute'] if 'attribute' in json or not useDefaults else 0,
                timestamp = raritan.rpc.Time.decode(json['timestamp']) if 'timestamp' in json or not useDefaults else None,
                value = json['value'] if 'value' in json or not useDefaults else "",
            )
            return obj

        def encode(self):
            json = {}
            json['id'] = self.id
            json['endpoint'] = self.endpoint
            json['attribute'] = self.attribute
            json['timestamp'] = raritan.rpc.Time.encode(self.timestamp)
            json['value'] = str(self.value)
            return json

    # value object
    class ClusterDataEvent(raritan.rpc.idl.Event):
        idlType = "zigbee.ZigbeeDevice.ClusterDataEvent:1.0.0"

        def __init__(self, value=None, source=None):
            super(raritan.rpc.zigbee.ZigbeeDevice.ClusterDataEvent, self).__init__(source)
            if value is None:
                value = raritan.rpc.zigbee.ZigbeeDevice.ClusterValue()
            typecheck.is_struct(value, raritan.rpc.zigbee.ZigbeeDevice.ClusterValue, AssertionError)

            self.value = value

        def encode(self):
            json = super(raritan.rpc.zigbee.ZigbeeDevice.ClusterDataEvent, self).encode()
            json['value'] = raritan.rpc.zigbee.ZigbeeDevice.ClusterValue.encode(self.value)
            return json

        @classmethod
        def decode(cls, json, agent, useDefaults=False):
            obj = cls(
                value = raritan.rpc.zigbee.ZigbeeDevice.ClusterValue.decode(json['value'], agent, useDefaults=useDefaults) if 'value' in json or not useDefaults else raritan.rpc.zigbee.ZigbeeDevice.ClusterValue(),
                # for idl.Event
                source = Interface.decode(json['source'], agent) if 'source' in json or not useDefaults else None,
            )
            return obj

        def listElements(self):
            elements = ["value"]
            elements = elements + super(raritan.rpc.zigbee.ZigbeeDevice.ClusterDataEvent, self).listElements()
            return elements

    class _getMetaData(Interface.Method):
        name = 'getMetaData'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent, useDefaults=False):
            _ret_ = raritan.rpc.zigbee.ZigbeeDevice.MetaData.decode(rsp['_ret_'], agent, useDefaults=useDefaults)
            typecheck.is_struct(_ret_, raritan.rpc.zigbee.ZigbeeDevice.MetaData, DecodeException)
            return _ret_

    class _getClusterValues(Interface.Method):
        name = 'getClusterValues'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent, useDefaults=False):
            _ret_ = [raritan.rpc.zigbee.ZigbeeDevice.ClusterValue.decode(x0, agent, useDefaults=useDefaults) for x0 in rsp['_ret_']]
            for x0 in _ret_:
                typecheck.is_struct(x0, raritan.rpc.zigbee.ZigbeeDevice.ClusterValue, DecodeException)
            return _ret_
    def __init__(self, target, agent):
        super(ZigbeeDevice, self).__init__(target, agent)
        self.getMetaData = ZigbeeDevice._getMetaData(self)
        self.getClusterValues = ZigbeeDevice._getClusterValues(self)

#
# Section generated by IdlC from "ZigbeeManager.idl"
#

import raritan.rpc
from raritan.rpc import Interface, Structure, ValueObject, Enumeration, typecheck, DecodeException
import raritan.rpc.idl

import raritan.rpc.zigbee


# interface
class ZigbeeManager(Interface):
    idlType = "zigbee.ZigbeeManager:1.0.0"

    ERR_DEVICE_EXISTS = 1

    ERR_MAX_DEVICE_REACHED = 2

    ERR_DEVICE_NOT_FOUND = 3

    ERR_INVALID_PARAMS = 4

    ERR_INVALID_KEY = 5

    ERR_INVALID_CHANNEL = 6

    # enumeration
    class DongleState(Enumeration):
        idlType = "zigbee.ZigbeeManager.DongleState:1.0.0"
        values = ["NOT_INIT", "READY", "ERROR", "INIT_IN_PROGRESS", "FW_UPGRADE", "IN_MODEM_STATE"]

    DongleState.NOT_INIT = DongleState(0)
    DongleState.READY = DongleState(1)
    DongleState.ERROR = DongleState(2)
    DongleState.INIT_IN_PROGRESS = DongleState(3)
    DongleState.FW_UPGRADE = DongleState(4)
    DongleState.IN_MODEM_STATE = DongleState(5)

    # structure
    class MetaData(Structure):
        idlType = "zigbee.ZigbeeManager.MetaData:1.0.0"
        elements = ["firmwareVersion", "stackVersion"]

        def __init__(self, firmwareVersion="", stackVersion=""):
            if not typecheck._is_int(firmwareVersion):
                typecheck.is_string(firmwareVersion, AssertionError)
            if not typecheck._is_int(stackVersion):
                typecheck.is_string(stackVersion, AssertionError)

            self.firmwareVersion = firmwareVersion
            self.stackVersion = stackVersion

        @classmethod
        def decode(cls, json, agent, useDefaults=False):
            obj = cls(
                firmwareVersion = json['firmwareVersion'] if 'firmwareVersion' in json or not useDefaults else "",
                stackVersion = json['stackVersion'] if 'stackVersion' in json or not useDefaults else "",
            )
            return obj

        def encode(self):
            json = {}
            json['firmwareVersion'] = str(self.firmwareVersion)
            json['stackVersion'] = str(self.stackVersion)
            return json

    # structure
    class Settings(Structure):
        idlType = "zigbee.ZigbeeManager.Settings:1.0.0"
        elements = ["channel"]

        def __init__(self, channel=0):
            typecheck.is_int(channel, AssertionError)

            self.channel = channel

        @classmethod
        def decode(cls, json, agent, useDefaults=False):
            obj = cls(
                channel = json['channel'] if 'channel' in json or not useDefaults else 0,
            )
            return obj

        def encode(self):
            json = {}
            json['channel'] = self.channel
            return json

    # structure
    class DeviceRegistration(Structure):
        idlType = "zigbee.ZigbeeManager.DeviceRegistration:1.0.0"
        elements = ["sourceId", "key", "slot"]

        def __init__(self, sourceId=0, key="", slot=0):
            typecheck.is_int(sourceId, AssertionError)
            if not typecheck._is_int(key):
                typecheck.is_string(key, AssertionError)
            typecheck.is_int(slot, AssertionError)

            self.sourceId = sourceId
            self.key = key
            self.slot = slot

        @classmethod
        def decode(cls, json, agent, useDefaults=False):
            obj = cls(
                sourceId = json['sourceId'] if 'sourceId' in json or not useDefaults else 0,
                key = json['key'] if 'key' in json or not useDefaults else "",
                slot = json['slot'] if 'slot' in json or not useDefaults else 0,
            )
            return obj

        def encode(self):
            json = {}
            json['sourceId'] = self.sourceId
            json['key'] = str(self.key)
            json['slot'] = self.slot
            return json

    # value object
    class DeviceEvent(raritan.rpc.idl.Event):
        idlType = "zigbee.ZigbeeManager.DeviceEvent:1.0.0"

        def __init__(self, sourceId=0, source=None):
            super(raritan.rpc.zigbee.ZigbeeManager.DeviceEvent, self).__init__(source)
            typecheck.is_int(sourceId, AssertionError)

            self.sourceId = sourceId

        def encode(self):
            json = super(raritan.rpc.zigbee.ZigbeeManager.DeviceEvent, self).encode()
            json['sourceId'] = self.sourceId
            return json

        @classmethod
        def decode(cls, json, agent, useDefaults=False):
            obj = cls(
                sourceId = json['sourceId'] if 'sourceId' in json or not useDefaults else 0,
                # for idl.Event
                source = Interface.decode(json['source'], agent) if 'source' in json or not useDefaults else None,
            )
            return obj

        def listElements(self):
            elements = ["sourceId"]
            elements = elements + super(raritan.rpc.zigbee.ZigbeeManager.DeviceEvent, self).listElements()
            return elements

    # value object
    class DeviceAddedEvent(DeviceEvent):
        idlType = "zigbee.ZigbeeManager.DeviceAddedEvent:1.0.0"

        def __init__(self, sourceId=0, source=None):
            super(raritan.rpc.zigbee.ZigbeeManager.DeviceAddedEvent, self).__init__(sourceId, source)

        def encode(self):
            json = super(raritan.rpc.zigbee.ZigbeeManager.DeviceAddedEvent, self).encode()
            return json

        @classmethod
        def decode(cls, json, agent, useDefaults=False):
            obj = cls(
                # for zigbee.ZigbeeManager.DeviceEvent
                sourceId = json['sourceId'] if 'sourceId' in json or not useDefaults else 0,
                # for idl.Event
                source = Interface.decode(json['source'], agent) if 'source' in json or not useDefaults else None,
            )
            return obj

        def listElements(self):
            elements = []
            elements = elements + super(raritan.rpc.zigbee.ZigbeeManager.DeviceAddedEvent, self).listElements()
            return elements

    # value object
    class DeviceRemovedEvent(DeviceEvent):
        idlType = "zigbee.ZigbeeManager.DeviceRemovedEvent:1.0.0"

        def __init__(self, sourceId=0, source=None):
            super(raritan.rpc.zigbee.ZigbeeManager.DeviceRemovedEvent, self).__init__(sourceId, source)

        def encode(self):
            json = super(raritan.rpc.zigbee.ZigbeeManager.DeviceRemovedEvent, self).encode()
            return json

        @classmethod
        def decode(cls, json, agent, useDefaults=False):
            obj = cls(
                # for zigbee.ZigbeeManager.DeviceEvent
                sourceId = json['sourceId'] if 'sourceId' in json or not useDefaults else 0,
                # for idl.Event
                source = Interface.decode(json['source'], agent) if 'source' in json or not useDefaults else None,
            )
            return obj

        def listElements(self):
            elements = []
            elements = elements + super(raritan.rpc.zigbee.ZigbeeManager.DeviceRemovedEvent, self).listElements()
            return elements

    # value object
    class SettingsChangedEvent(raritan.rpc.idl.Event):
        idlType = "zigbee.ZigbeeManager.SettingsChangedEvent:1.0.0"

        def __init__(self, oldSettings=None, newSettings=None, source=None):
            super(raritan.rpc.zigbee.ZigbeeManager.SettingsChangedEvent, self).__init__(source)
            if oldSettings is None:
                oldSettings = raritan.rpc.zigbee.ZigbeeManager.Settings()
            if newSettings is None:
                newSettings = raritan.rpc.zigbee.ZigbeeManager.Settings()
            typecheck.is_struct(oldSettings, raritan.rpc.zigbee.ZigbeeManager.Settings, AssertionError)
            typecheck.is_struct(newSettings, raritan.rpc.zigbee.ZigbeeManager.Settings, AssertionError)

            self.oldSettings = oldSettings
            self.newSettings = newSettings

        def encode(self):
            json = super(raritan.rpc.zigbee.ZigbeeManager.SettingsChangedEvent, self).encode()
            json['oldSettings'] = raritan.rpc.zigbee.ZigbeeManager.Settings.encode(self.oldSettings)
            json['newSettings'] = raritan.rpc.zigbee.ZigbeeManager.Settings.encode(self.newSettings)
            return json

        @classmethod
        def decode(cls, json, agent, useDefaults=False):
            obj = cls(
                oldSettings = raritan.rpc.zigbee.ZigbeeManager.Settings.decode(json['oldSettings'], agent, useDefaults=useDefaults) if 'oldSettings' in json or not useDefaults else raritan.rpc.zigbee.ZigbeeManager.Settings(),
                newSettings = raritan.rpc.zigbee.ZigbeeManager.Settings.decode(json['newSettings'], agent, useDefaults=useDefaults) if 'newSettings' in json or not useDefaults else raritan.rpc.zigbee.ZigbeeManager.Settings(),
                # for idl.Event
                source = Interface.decode(json['source'], agent) if 'source' in json or not useDefaults else None,
            )
            return obj

        def listElements(self):
            elements = ["oldSettings", "newSettings"]
            elements = elements + super(raritan.rpc.zigbee.ZigbeeManager.SettingsChangedEvent, self).listElements()
            return elements

    # value object
    class StateChangedEvent(raritan.rpc.idl.Event):
        idlType = "zigbee.ZigbeeManager.StateChangedEvent:1.0.0"

        def __init__(self, oldState=None, newState=None, source=None):
            super(raritan.rpc.zigbee.ZigbeeManager.StateChangedEvent, self).__init__(source)
            if oldState is None:
                oldState = raritan.rpc.zigbee.ZigbeeManager.DongleState.NOT_INIT
            if newState is None:
                newState = raritan.rpc.zigbee.ZigbeeManager.DongleState.NOT_INIT
            typecheck.is_enum(oldState, raritan.rpc.zigbee.ZigbeeManager.DongleState, AssertionError)
            typecheck.is_enum(newState, raritan.rpc.zigbee.ZigbeeManager.DongleState, AssertionError)

            self.oldState = oldState
            self.newState = newState

        def encode(self):
            json = super(raritan.rpc.zigbee.ZigbeeManager.StateChangedEvent, self).encode()
            json['oldState'] = raritan.rpc.zigbee.ZigbeeManager.DongleState.encode(self.oldState)
            json['newState'] = raritan.rpc.zigbee.ZigbeeManager.DongleState.encode(self.newState)
            return json

        @classmethod
        def decode(cls, json, agent, useDefaults=False):
            obj = cls(
                oldState = raritan.rpc.zigbee.ZigbeeManager.DongleState.decode(json['oldState']) if 'oldState' in json or not useDefaults else raritan.rpc.zigbee.ZigbeeManager.DongleState.NOT_INIT,
                newState = raritan.rpc.zigbee.ZigbeeManager.DongleState.decode(json['newState']) if 'newState' in json or not useDefaults else raritan.rpc.zigbee.ZigbeeManager.DongleState.NOT_INIT,
                # for idl.Event
                source = Interface.decode(json['source'], agent) if 'source' in json or not useDefaults else None,
            )
            return obj

        def listElements(self):
            elements = ["oldState", "newState"]
            elements = elements + super(raritan.rpc.zigbee.ZigbeeManager.StateChangedEvent, self).listElements()
            return elements

    class _getMetaData(Interface.Method):
        name = 'getMetaData'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent, useDefaults=False):
            _ret_ = raritan.rpc.zigbee.ZigbeeManager.MetaData.decode(rsp['_ret_'], agent, useDefaults=useDefaults)
            typecheck.is_struct(_ret_, raritan.rpc.zigbee.ZigbeeManager.MetaData, DecodeException)
            return _ret_

    class _getDongleState(Interface.Method):
        name = 'getDongleState'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent, useDefaults=False):
            _ret_ = raritan.rpc.zigbee.ZigbeeManager.DongleState.decode(rsp['_ret_'])
            typecheck.is_enum(_ret_, raritan.rpc.zigbee.ZigbeeManager.DongleState, DecodeException)
            return _ret_

    class _getSettings(Interface.Method):
        name = 'getSettings'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent, useDefaults=False):
            _ret_ = raritan.rpc.zigbee.ZigbeeManager.Settings.decode(rsp['_ret_'], agent, useDefaults=useDefaults)
            typecheck.is_struct(_ret_, raritan.rpc.zigbee.ZigbeeManager.Settings, DecodeException)
            return _ret_

    class _setSettings(Interface.Method):
        name = 'setSettings'

        @staticmethod
        def encode(settings):
            typecheck.is_struct(settings, raritan.rpc.zigbee.ZigbeeManager.Settings, AssertionError)
            args = {}
            args['settings'] = raritan.rpc.zigbee.ZigbeeManager.Settings.encode(settings)
            return args

        @staticmethod
        def decode(rsp, agent, useDefaults=False):
            _ret_ = rsp['_ret_']
            typecheck.is_int(_ret_, DecodeException)
            return _ret_

    class _addDevices(Interface.Method):
        name = 'addDevices'

        @staticmethod
        def encode(sensors):
            for x0 in sensors:
                typecheck.is_struct(x0, raritan.rpc.zigbee.ZigbeeManager.DeviceRegistration, AssertionError)
            args = {}
            args['sensors'] = [raritan.rpc.zigbee.ZigbeeManager.DeviceRegistration.encode(x0) for x0 in sensors]
            return args

        @staticmethod
        def decode(rsp, agent, useDefaults=False):
            _ret_ = [x0 for x0 in rsp['_ret_']]
            for x0 in _ret_:
                typecheck.is_int(x0, DecodeException)
            return _ret_

    class _removeDevice(Interface.Method):
        name = 'removeDevice'

        @staticmethod
        def encode(sourceId):
            typecheck.is_int(sourceId, AssertionError)
            args = {}
            args['sourceId'] = sourceId
            return args

        @staticmethod
        def decode(rsp, agent, useDefaults=False):
            _ret_ = rsp['_ret_']
            typecheck.is_int(_ret_, DecodeException)
            return _ret_

    class _getRegisteredDevices(Interface.Method):
        name = 'getRegisteredDevices'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent, useDefaults=False):
            _ret_ = [Interface.decode(x0, agent) for x0 in rsp['_ret_']]
            for x0 in _ret_:
                typecheck.is_interface(x0, raritan.rpc.zigbee.ZigbeeDevice, DecodeException)
            return _ret_
    def __init__(self, target, agent):
        super(ZigbeeManager, self).__init__(target, agent)
        self.getMetaData = ZigbeeManager._getMetaData(self)
        self.getDongleState = ZigbeeManager._getDongleState(self)
        self.getSettings = ZigbeeManager._getSettings(self)
        self.setSettings = ZigbeeManager._setSettings(self)
        self.addDevices = ZigbeeManager._addDevices(self)
        self.removeDevice = ZigbeeManager._removeDevice(self)
        self.getRegisteredDevices = ZigbeeManager._getRegisteredDevices(self)
