miio.integrations.zimi.clock.alarmclock module
- class miio.integrations.zimi.clock.alarmclock.AlarmClock(ip: str | None = None, token: str | None = None, start_id: int = 0, debug: int = 0, lazy_discover: bool = True, timeout: int | None = None, *, model: str | None = None)[source]
Bases:
Device
Implementation of Xiao AI Smart Alarm Clock.
Note, this device is not very responsive to the requests, so it may take several seconds /tries to get an answer.
- actions() DescriptorCollection[ActionDescriptor]
Return device actions.
- alarmops()[source]
Method to create, query, and delete alarms (not implemented).
The alarm_ops method is the one used to create, query and delete all types of alarms (reminders, alarms, countdowns):
-> 192.168.0.128 data= {"id":263,"method":"alarm_ops", "params":{"operation":"create","data":[ {"type":"alarm","event":"testlabel","reminder":"","smart_clock":0, "ringtone":"a2.mp3","volume":100,"circle":"once","status":"on", "repeat_ringing":0,"delete_datetime":1564291980000, "disable_datetime":"","circle_extra":"", "datetime":1564291980000} ],"update_datetime":1564205639326}} <- 192.168.0.57 data= {"result":[{"id":1,"ack":"OK"}],"id":263} # query per index, starts from 0 instead of 1 as the ids it seems -> 192.168.0.128 data= {"id":264,"method":"alarm_ops", "params":{"operation":"query","req_type":"alarm", "update_datetime":1564205639593,"index":0}} <- 192.168.0.57 data= {"result": [0,[ {"i":"1","c":"once","d":"2019-07-28T13:33:00+0800","s":"on", "n":"testlabel","a":"a2.mp3","dd":1} ], "America/New_York" ],"id":264} # result [code, list of alarms, timezone] -> 192.168.0.128 data= {"id":265,"method":"alarm_ops", "params":{"operation":"query","index":0,"update_datetime":1564205639596, "req_type":"reminder"}} <- 192.168.0.57 data= {"result":[0,[],"America/New_York"],"id":265}
- clock_system() HourlySystem [source]
Returns either 12 or 24 depending on which system is in use.
- configure_wifi(ssid, password, uid=0, extra_params=None)
Configure the wifi settings.
- descriptors() DescriptorCollection[Descriptor]
Return a collection containing all descriptors for the device.
- classmethod get_device_group()
- get_properties(properties, *, property_getter='get_prop', max_properties=None)
Request properties in slices based on given max_properties.
This is necessary as some devices have limitation on how many properties can be queried at once.
If max_properties is None, all properties are requested at once.
- info(*, skip_cache=False) DeviceInfo
Get (and cache) miIO protocol information from the device.
This includes information about connected wlan network, and hardware and software versions.
- Parameters:
bool (skip_cache) – Skip the cache
- near_wakeup()[source]
Status for near wakeup.
Get the status:
-> 192.168.0.128 data= {"id":235,"method":"get_near_wakeup_status", "params":[]} <- 192.168.0.57 data= {"result":["disable"],"id":235}
Set the status:
-> 192.168.0.128 data= {"id":254,"method":"set_near_wakeup_status", "params":["enable"]} <- 192.168.0.57 data= {"result":["OK"],"id":254} -> 192.168.0.128 data= {"id":255,"method":"set_near_wakeup_status", "params":["disable"]} <- 192.168.0.57 data= {"result":["OK"],"id":255}
- raw_command(command, parameters)
Send a raw command to the device. This is mostly useful when trying out commands which are not implemented by a given device instance.
- send(command: str, parameters: Any | None = None, retry_count: int | None = None, *, extra_parameters=None) Any
Send a command to the device.
Basic format of the request: {“id”: 1234, “method”: command, “parameters”: parameters}
extra_parameters allows passing elements to the top-level of the request. This is necessary for some devices, such as gateway devices, which expect the sub-device identifier to be on the top-level.
- send_handshake()
Send initial handshake to the device.
- sensors() DescriptorCollection[PropertyDescriptor]
Return read-only properties.
- set_hourly_system(hs: HourlySystem)[source]
- set_night_mode()[source]
Set the night mode (not implemented).
Enable night mode:
-> 192.168.0.128 data= {"id":248,"method":"set_night_mode", "params":[1,"21:00","6:00"]} <- 192.168.0.57 data= {"result":["OK"],"id":248}
Disable night mode:
-> 192.168.0.128 data= {"id":249,"method":"set_night_mode", "params":[0,"21:00","6:00"]} <- 192.168.0.57 data= {"result":["OK"],"id":249}
- set_ring(alarm_type: AlarmType, ring: RingTone)[source]
Set alarm tone (not implemented).
Raw payload example:
-> 192.168.0.128 data= {"id":236,"method":"set_ring", "params":[{"ringtone":"a1.mp3","smart_clock":"","type":"alarm"}]} <- 192.168.0.57 data= {"result":["OK"],"id":236}
- settings() DescriptorCollection[PropertyDescriptor]
Return settable properties.
- status() DeviceStatus
Return device status.
- supports_miot() bool
Return True if the device supports miot commands.
This requests a single property (siid=1, piid=1) and returns True on success.
- update_state()
Return current update state.
- retry_count = 3
- supported_models = ['zimi.clock.myk01']
- timeout = 5
- class miio.integrations.zimi.clock.alarmclock.AlarmType(value)[source]
Bases:
Enum
An enumeration.
- Alarm = 'alarm'
- Reminder = 'reminder'
- Timer = 'timer'
- class miio.integrations.zimi.clock.alarmclock.HourlySystem(value)[source]
Bases:
Enum
An enumeration.
- Twelve = 12
- TwentyFour = 24
- class miio.integrations.zimi.clock.alarmclock.Nightmode(data)[source]
Bases:
DeviceStatus
- descriptors() DescriptorCollection[PropertyDescriptor]
Return the dict of sensors exposed by the status container.
Use @sensor and @setting decorators to define properties.
- embed(name: str, other: DeviceStatus)
Embed another status container to current one.
This makes it easy to provide a single status response for cases where responses from multiple I/O calls is wanted to provide a simple interface for downstreams.
Internally, this will prepend the name of the other class to the attribute names, and override the __getattribute__ to lookup attributes in the embedded containers.
- property end
- property start
- class miio.integrations.zimi.clock.alarmclock.RingTone(data)[source]
Bases:
DeviceStatus
- descriptors() DescriptorCollection[PropertyDescriptor]
Return the dict of sensors exposed by the status container.
Use @sensor and @setting decorators to define properties.
- embed(name: str, other: DeviceStatus)
Embed another status container to current one.
This makes it easy to provide a single status response for cases where responses from multiple I/O calls is wanted to provide a simple interface for downstreams.
Internally, this will prepend the name of the other class to the attribute names, and override the __getattribute__ to lookup attributes in the embedded containers.