-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for the IAM-T1 Air Quality Sensor #35
base: main
Are you sure you want to change the base?
Changes from all commits
b95d207
42a6e7d
d422925
a31b8ab
9f7bcd6
adbb3e8
c16474c
76399c7
a51ec9b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,8 @@ | |
from home_assistant_bluetooth import BluetoothServiceInfo | ||
from sensor_state_data import SensorLibrary | ||
|
||
IAMT1_SERVICE_UUID = "0000ffe4-0000-1000-8000-00805f9b34fb" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't believe this is the right service. The device I have uses service FFE0 with characteristic FFE4. |
||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
BBQ_LENGTH_TO_TYPE = { | ||
|
@@ -70,6 +72,9 @@ def _start_update(self, service_info: BluetoothServiceInfo) -> None: | |
dev_type, _ = bbq_data | ||
self.set_device_name(f"{local_name} {short_address(address)}") | ||
self.set_device_type(f"{local_name[0]}{dev_type[1:]}") | ||
elif IAMT1_SERVICE_UUID in service_info.service_uuids: | ||
self.set_device_name(f"{local_name} {short_address(address)}") | ||
Comment on lines
+75
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't expect this to work. The T1 I have doesn't advertise this service (or any service) so I would expect The manufacturer data (0x3154 "AC-6200a135990\0" or maybe they meant "1TAC-..."?) feels like it may be a more reliable identifier (plus the device name?) (FFE0 is also not an assigned service. It's a service that a lot of devices squat on without registering. So its existence doesn't tell you anything other than the device developer was sloppy, and possibly just following a random tutorial or copied HOPERF modules.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my attempts I also use the "T1AC" (endianness) to identify the IAM-T1. But I wouldn't use the number after that as I think that it is the serial number or at least device specific (mine have other digits). EDIT: I looked at my code again and this is how I currently identify the IAM-T1 def is_iam_t1(service_info: BluetoothServiceInfo) -> bool:
return 0x3154 in service_info.manufacturer_data.keys() |
||
self.set_device_type(f"{local_name}") | ||
else: | ||
return | ||
|
||
|
@@ -121,3 +126,20 @@ def _start_update(self, service_info: BluetoothServiceInfo) -> None: | |
key=f"temperature_probe_{num}", | ||
name=f"Temperature Probe {num}", | ||
) | ||
elif ( | ||
lower_name == "iam-t1" and IAMT1_SERVICE_UUID in service_info.service_uuids | ||
): | ||
service_data = service_info.service_data[IAMT1_SERVICE_UUID] | ||
temp = int.from_bytes(service_data[5:7], "big") / 10 | ||
temp_sign = service_data[4] & 0xF | ||
temp = temp if temp_sign == 0 else -temp | ||
self.update_predefined_sensor(SensorLibrary.TEMPERATURE__CELSIUS, temp) | ||
humidity = int.from_bytes(service_data[7:9], "big") / 10 | ||
self.update_predefined_sensor(SensorLibrary.HUMIDITY__PERCENTAGE, humidity) | ||
co2_ppm = int.from_bytes(service_data[9:11], "big") | ||
self.update_predefined_sensor( | ||
SensorLibrary.CO2__CONCENTRATION_PARTS_PER_MILLION, co2_ppm | ||
) | ||
pressure_hpa = int.from_bytes(service_data[11:13], "big") | ||
self.update_predefined_sensor(SensorLibrary.PRESSURE__HPA, pressure_hpa) | ||
# TODO Battery |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0000ffe4
will match other devices as well as0000-1000-8000-00805f9b34fb
is the base part of the base UUID https://github.com/Bluetooth-Devices/bluetooth-data-tools/blob/8fdc7cade9c3b87dfdd77cb741d1fd83fbc154ea/src/bluetooth_data_tools/gap.py#L8There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a match for the device name as well.