libdeye package¶
Submodules¶
libdeye.cli module¶
CLI tool for testing libdeye library during development.
- async libdeye.cli.authenticate(session: ClientSession, username: str, password: str, auth_token: str | None = None) DeyeCloudApi[source]¶
Authenticate with Deye Cloud API.
- async libdeye.cli.get_classic_mqtt_info(api: DeyeCloudApi) None[source]¶
Get and display Classic platform MQTT information.
- async libdeye.cli.get_device_state(api: DeyeCloudApi, device_id: str) None[source]¶
Get the current state of a device.
- async libdeye.cli.get_fog_mqtt_info(api: DeyeCloudApi) None[source]¶
Get and display Fog platform MQTT information.
- async libdeye.cli.list_devices(api: DeyeCloudApi) None[source]¶
List all devices associated with the account.
- async libdeye.cli.list_products(api: DeyeCloudApi) None[source]¶
List all available products from Deye.
- libdeye.cli.load_env_file(env_file: str = '.env') dict[str, str][source]¶
Load environment variables from a .env file.
- async libdeye.cli.monitor_device(api: DeyeCloudApi, device_id: str) None[source]¶
Monitor a device for state updates.
- async libdeye.cli.print_auth_token(api: DeyeCloudApi) None[source]¶
Print the authentication token.
- libdeye.cli.print_device_state(state: DeyeDeviceState) None[source]¶
Print the state of a device.
- async libdeye.cli.refresh_token(api: DeyeCloudApi) None[source]¶
Force refresh the authentication token.
- async libdeye.cli.run_cli(args: Namespace, username: str, password: str, auth_token: str | None, device_id: str | None) None[source]¶
Run the CLI with the given arguments.
- async libdeye.cli.set_device_state(api: DeyeCloudApi, device_id: str, power: bool | None = None, mode: DeyeDeviceMode | None = None, fan_speed: DeyeFanSpeed | None = None, target_humidity: int | None = None, anion: bool | None = None, water_pump: bool | None = None, oscillating: bool | None = None, child_lock: bool | None = None) None[source]¶
Set the state of a device.
libdeye.cloud_api module¶
Deye Cloud API related stuffs
- class libdeye.cloud_api.DeyeApiRequestFogPlatformDeviceCommands[source]¶
Bases:
TypedDictDevice Command for the Fog platform sent to the API
- class libdeye.cloud_api.DeyeApiResponseClassicPlatformMqttInfo[source]¶
Bases:
TypedDictMQTT information for the Deye platform returned by the API
- class libdeye.cloud_api.DeyeApiResponseDeviceInfo[source]¶
Bases:
TypedDictDevice information returned by the API
- platform: DeyeIotPlatform¶
- class libdeye.cloud_api.DeyeApiResponseEnvelope[source]¶
Bases:
TypedDictMessage envelope for all API responses
- class libdeye.cloud_api.DeyeApiResponseEnvelopeMeta[source]¶
Bases:
TypedDictMeta information for the API message envelope
- class libdeye.cloud_api.DeyeApiResponseFogPlatformDeviceProperties[source]¶
Bases:
TypedDictDevice properties for the Fog platform returned by the API
- class libdeye.cloud_api.DeyeApiResponseFogPlatformMqttInfo[source]¶
Bases:
TypedDictMQTT information for the Fog platform returned by the API
- class libdeye.cloud_api.DeyeApiResponseFogPlatformMqttTopics[source]¶
Bases:
TypedDictMQTT topics returned by the API
- class libdeye.cloud_api.DeyeApiResponseProductDefinition[source]¶
Bases:
TypedDictProduct definition information returned by the API
- class libdeye.cloud_api.DeyeApiResponseProductType[source]¶
Bases:
TypedDictProduct type information returned by the API
- class libdeye.cloud_api.DeyeCloudApi(session: ClientSession, username: str, password: str, auth_token: str | None = None)[source]¶
Bases:
objectInteract with Deye Cloud APIs.
- async get_device_list() list[DeyeApiResponseDeviceInfo][source]¶
Get all connected devices for current user
- async get_deye_platform_mqtt_info() DeyeApiResponseClassicPlatformMqttInfo[source]¶
Get MQTT server info / credentials for current user (Deye platform)
- async get_fog_platform_device_properties(device_id: str) DeyeApiResponseFogPlatformDeviceProperties[source]¶
Get properties for a device on the Fog platform
- async get_fog_platform_mqtt_info() DeyeApiResponseFogPlatformMqttInfo[source]¶
Get MQTT server info / credentials for current user (Fog platform)
- async get_product_list() list[DeyeApiResponseProductType][source]¶
Get all available products
- async poll_fog_platform_device_properties(device_id: str) None[source]¶
Poll properties for a device on the Fog platform
- async refresh_token_if_near_expiry(force: bool = False) None[source]¶
Get a new auth token by calling /refreshToken if the current auth token is about to be expired. This will be automatically called for each API call.
- Parameters:
force – If True, refresh the token regardless of expiry time.
- exception libdeye.cloud_api.DeyeCloudApiCannotConnectError[source]¶
Bases:
ExceptionError to indicate we cannot connect.
- exception libdeye.cloud_api.DeyeCloudApiInvalidAuthError[source]¶
Bases:
ExceptionError to indicate there is invalid auth.
- class libdeye.cloud_api.DeyeIotPlatform(value)[source]¶
Bases:
IntEnumIoT platform of devices
- Classic = 1¶
- Fog = 2¶
- libdeye.cloud_api.ensure_valid_response_code(result: DeyeApiResponseEnvelope) None[source]¶
Raise errors if we don’t have a valid result[“meta”][“code”]
libdeye.const module¶
Constants for the Deye Cloud API.
- class libdeye.const.DeyeDeviceMode(value)[source]¶
Bases:
IntEnumAll supported mode
- AIR_PURIFIER_MODE = 2¶
- AUTO_MODE = 3¶
- CLOTHES_DRYER_MODE = 1¶
- MANUAL_MODE = 0¶
- SLEEP_MODE = 6¶
- UNKNOWN_MODE = 4¶
- UNKNOWN_MODE_2 = 5¶
- class libdeye.const.DeyeFanSpeed(value)[source]¶
Bases:
IntEnumAll supported fan speed
- FULL = 4¶
- HIGH = 3¶
- LOW = 1¶
- MIDDLE = 2¶
- STOPPED = 0¶
- class libdeye.const.DeyeProductConfig[source]¶
Bases:
TypedDictFeature config for a specific Deye product
- fan_speed: list[DeyeFanSpeed]¶
- mode: list[DeyeDeviceMode]¶
- class libdeye.const.DeyeProductPartialConfig[source]¶
Bases:
TypedDictFeature config for a specific Deye product (partial)
- fan_speed: list[DeyeFanSpeed]¶
- mode: list[DeyeDeviceMode]¶
- libdeye.const.get_product_feature_config(product_id: str) DeyeProductConfig[source]¶
Get supported features of the product
libdeye.device_command module¶
Utilities for device command parsing
- class libdeye.device_command.DeyeDeviceCommand(anion_switch: bool = False, water_pump_switch: bool = False, power_switch: bool = False, oscillating_switch: bool = False, child_lock_switch: bool = False, fan_speed: DeyeFanSpeed = DeyeFanSpeed.LOW, mode: DeyeDeviceMode = DeyeDeviceMode.MANUAL_MODE, target_humidity: int = 60)[source]¶
Bases:
objectA class to store the command to control the device
- to_json_diff(baseline: DeyeDeviceCommand | DeyeDeviceState) dict[str, int][source]¶
Get JSON with only properties that differ from the baseline.
libdeye.device_state module¶
Utilities for device state parsing
- class libdeye.device_state.DeyeDeviceState(state: str | DeyeApiResponseFogPlatformDeviceProperties)[source]¶
Bases:
objectA class to store the device state.
- copy() DeyeDeviceState[source]¶
Return an independent copy of this state.
- to_command() DeyeDeviceCommand[source]¶
Convert to a command that can be used to let the device get into this state
- class libdeye.device_state.DeyeDeviceStateFlag(value)[source]¶
Bases:
IntFlagBit flags used in the state string
- ANION_SWITCH = 1¶
- CHILD_LOCK_SWITCH = 1024¶
- DEFROSTING_STATE = 8192¶
- ELECTROMAGNETIC_STATE = 4¶
- ENVIRONMENT_DEGREE = 16¶
- FAN_RUNNING_STATE = 32768¶
- OSCILLATING_SWITCH = 512¶
- POWEROFF_SWITCH = 2048¶
- POWERON_SWITCH = 4096¶
- POWER_SWITCH = 256¶
- PRESS_STATE = 8¶
- WATER_PUMP_SWITCH = 2¶
- WATER_TANK_FULL_STATE = 16384¶
libdeye.mqtt_client module¶
MQTT related stuffs
- class libdeye.mqtt_client.BaseDeyeMqttClient(cloud_api: DeyeCloudApi, tls_context: SSLContext | None = None)[source]¶
Bases:
ABCBase class for MQTT clients connected to Deye MQTT servers.
- abstractmethod async publish_command(product_id: str, device_id: str, command: DeyeDeviceCommand, properties: dict[str, int] | None = None) None[source]¶
Publish commands to a device
- abstractmethod async query_device_state(product_id: str, device_id: str) DeyeDeviceState[source]¶
Query the latest device state.
- class libdeye.mqtt_client.DeyeClassicMqttClient(cloud_api: DeyeCloudApi, tls_context: SSLContext | None = None)[source]¶
Bases:
BaseDeyeMqttClientMQTT client for the Classic platform.
- async publish_command(product_id: str, device_id: str, command: DeyeDeviceCommand | bytes, properties: dict[str, int] | None = None) None[source]¶
Publish commands to a device
- async query_device_state(product_id: str, device_id: str) DeyeDeviceState[source]¶
Query the latest device state.
- class libdeye.mqtt_client.DeyeFogMqttClient(cloud_api: DeyeCloudApi, tls_context: SSLContext | None = None)[source]¶
Bases:
BaseDeyeMqttClientMQTT client for the Fog platform.
- async publish_command(product_id: str, device_id: str, command: DeyeDeviceCommand, properties: dict[str, int] | None = None) None[source]¶
For Fog platform, commands are not published via MQTT. Instead, use the cloud API to send commands.
- async query_device_state(product_id: str, device_id: str) DeyeDeviceState[source]¶
Query the latest device state.