bluetooth_clocks.devices package#
Device-specific Bluetooth clock support.
Each submodule in this package implements support for a specific type of Bluetooth clock.
Each class in these submodules implements support for a specific model Bluetooth clock.
For instance, the bluetooth_clocks.devices.thermopro
module has classes
bluetooth_clocks.devices.thermopro.TP358
and
bluetooth_clocks.devices.thermopro.TP393
for the ThermoPro TP358 and
TP393, respectively.
Submodules#
bluetooth_clocks.devices.current_time_service module#
Bluetooth clock support for devices implementing the Current Time Service.
This includes the PineTime with InfiniTime firmware.
- class bluetooth_clocks.devices.current_time_service.CurrentTimeService(device: BLEDevice)[source]#
Bases:
BluetoothClock
Bluetooth clock support for devices implementing the Current Time Service.
This implements the standardized Bluetooth service Current Time Service (https://www.bluetooth.com/specifications/specs/current-time-service-1-1/).
- CHAR_UUID: ClassVar[UUID] = UUID('00002a2b-0000-1000-8000-00805f9b34fb')#
The UUID of the characteristic used to read/write the time.
- SERVICE_UUID: ClassVar[UUID] = UUID('00001805-0000-1000-8000-00805f9b34fb')#
The UUID of the service used to read/write the time.
- TIME_GET_FORMAT: ClassVar[str | None] = '<HBBBBBBB'#
The format string to convert bytes read from the Current Time Service to a time.
This starts with an unsigned short in little-endian format, followed by seven bytes.
- TIME_SET_FORMAT: ClassVar[str] = '<HBBBBBBBB'#
The format string to convert a time to bytes written to the device.
This starts with an unsigned short in little-endian format, followed by eight bytes.
- WRITE_WITH_RESPONSE: ClassVar[bool] = True#
Writing the time to the Current Time Service needs write with response.
- get_bytes_from_time(timestamp: float, ampm: bool = False) bytes [source]#
Generate the bytes to set the time on the Current Time Service.
- Parameters:
- Returns:
The bytes needed to set the time of the device to timestamp.
- Return type:
- get_time_from_bytes(time_bytes: bytes) float [source]#
Convert bytes read from the Current Time Service to a timestamp.
- Parameters:
time_bytes (bytes) – The raw bytes read from the device.
- Raises:
InvalidTimeBytesError – If time_bytes don’t have the right format.
- Returns:
The time encoded as a Unix timestamp.
- Return type:
- class bluetooth_clocks.devices.current_time_service.InfiniTime(device: BLEDevice)[source]#
Bases:
CurrentTimeService
Bluetooth clock support for the PineTime with InfiniTime firmware.
- LOCAL_NAME: ClassVar[str | None] = 'InfiniTime'#
The local name used to recognize this type of device.
- LOCAL_NAME_STARTS_WITH: ClassVar[bool | None] = False#
The local name should exactly match LOCAL_NAME.
bluetooth_clocks.devices.pvvx module#
Bluetooth clock support for devices running the PVVX firmware.
- class bluetooth_clocks.devices.pvvx.PVVX(device: BLEDevice)[source]#
Bases:
BluetoothClock
Bluetooth clock support for devices running the PVVX firmware.
- CHAR_UUID: ClassVar[UUID] = UUID('00001f1f-0000-1000-8000-00805f9b34fb')#
The UUID of the characteristic used to read/write the time.
- SERVICE_DATA_UUID = UUID('0000181a-0000-1000-8000-00805f9b34fb')#
UUID of the service data the PVVX device is advertising.
- SERVICE_UUID: ClassVar[UUID] = UUID('00001f10-0000-1000-8000-00805f9b34fb')#
The UUID of the service used to read/write the time.
- TIME_SET_FORMAT: ClassVar[str] = '<BL'#
The format string to convert a time to bytes written to the PVVX device.
- WRITE_WITH_RESPONSE: ClassVar[bool] = False#
Writing the time to the PVVX device needs write without response.
- get_bytes_from_time(timestamp: float, ampm: bool = False) bytes [source]#
Generate the bytes to set the time on the PVVX device.
- Parameters:
- Returns:
The bytes needed to set the time of the device to timestamp.
- Return type:
bluetooth_clocks.devices.qingping module#
Bluetooth clock support for Qingping clocks.
- class bluetooth_clocks.devices.qingping.CGC1(device: BLEDevice)[source]#
Bases:
BluetoothClock
Bluetooth clock support for the Qingping BT Clock Lite (CGC1).
- CHAR_UUID: ClassVar[UUID] = UUID('00000001-0000-1000-8000-00805f9b34fb')#
The UUID of the characteristic used to write the time.
- LOCAL_NAME: ClassVar[str | None] = 'Qingping BT Clock Lite'#
The local name used to recognize this type of device.
- LOCAL_NAME_STARTS_WITH: ClassVar[bool | None] = False#
The local name should exactly match LOCAL_NAME.
- SERVICE_UUID: ClassVar[UUID] = UUID('22210000-554a-4546-5542-46534450464d')#
The UUID of the service used to write the time.
- TIME_GET_FORMAT: ClassVar[str | None] = None#
The Qingping BT Clock Lite doesn’t support reading the time.
- TIME_SET_FORMAT: ClassVar[str] = '<BBL'#
The format string to convert a time to bytes written to the device.
This starts with two bytes, followed by an unsigned long in little-endian format.
- WRITE_WITH_RESPONSE: ClassVar[bool] = True#
We use write with response to write the time to the Qingping BT Clock Lite.
Note: The device also supports write without response.
bluetooth_clocks.devices.thermopro module#
Bluetooth clock support for ThermoPro sensors with clock.
- class bluetooth_clocks.devices.thermopro.TP358(device: BLEDevice)[source]#
Bases:
TPXXX
Bluetooth clock support for the ThermoPro TP358.
- class bluetooth_clocks.devices.thermopro.TP393(device: BLEDevice)[source]#
Bases:
TPXXX
Bluetooth clock support for the ThermoPro TP393.
- class bluetooth_clocks.devices.thermopro.TPXXX(device: BLEDevice)[source]#
Bases:
BluetoothClock
Bluetooth clock support for ThermoPro sensors with clock.
This class isn’t meant to be instantiated. Subclasses implement support for specific ThermoPro device types by giving values to the class variables DEVICE_TYPE, LOCAL_NAME, and LOCAL_NAME_STARTS_WITH.
- CHAR_UUID: ClassVar[UUID] = UUID('00010203-0405-0607-0809-0a0b0c0d2b11')#
The UUID of the characteristic used to write the time.
- SERVICE_UUID: ClassVar[UUID] = UUID('00010203-0405-0607-0809-0a0b0c0d1910')#
The UUID of the service used to write the time.
- TIME_SET_FORMAT: ClassVar[str] = 'BBBBBBBBBB'#
The format string to convert a time to bytes written to the device.
These are ten bytes.
- WRITE_WITH_RESPONSE: ClassVar[bool] = False#
Writing the time to ThermoPro devices needs write without response.
bluetooth_clocks.devices.xiaomi module#
Bluetooth clock support for Xiaomi devices.
- class bluetooth_clocks.devices.xiaomi.LYWSD02(device: BLEDevice)[source]#
Bases:
BluetoothClock
Bluetooth clock support for the Xiaomi LYWSD02.
- CHAR_UUID: ClassVar[UUID] = UUID('ebe0ccb7-7a0a-4b0c-8a1a-6ff2997da3a6')#
The UUID of the characteristic used to write the time.
- LOCAL_NAME_STARTS_WITH: ClassVar[bool | None] = False#
The local name should exactly match LOCAL_NAME.
- SERVICE_UUID: ClassVar[UUID] = UUID('ebe0ccb0-7a0a-4b0c-8a1a-6ff2997da3a6')#
The UUID of the service used to write the time.
- TIME_GET_FORMAT: ClassVar[str | None] = '<Lb'#
The format string to convert bytes read from the device to a time.
- TIME_SET_FORMAT: ClassVar[str] = '<Lb'#
The format string to convert a time to bytes written to the device.
- WRITE_WITH_RESPONSE: ClassVar[bool] = False#
Writing the time to the device needs write without response.
- get_bytes_from_time(timestamp: float, ampm: bool = False) bytes [source]#
Generate the bytes to set the time on the Xiaomi LYWSD02.
- Parameters:
- Returns:
The bytes needed to set the time of the device to timestamp.
- Return type:
- get_time_from_bytes(time_bytes: bytes) float [source]#
Convert bytes read from the Xiaomi LYWSD02 to a timestamp.
- Parameters:
time_bytes (bytes) – The raw bytes read from the device.
- Raises:
InvalidTimeBytesError – If time_bytes don’t have the right format.
- Returns:
The time encoded as a Unix timestamp.
- Return type: