Skip to content

Commit

Permalink
v 0.1.6 Update to version 0.1.6
Browse files Browse the repository at this point in the history
### Added

- Added new product_ids for Fingerbot and Fingerbot Plus.

### Changed

- Updated sources to conform Python 3.11
  • Loading branch information
PlusPlus-ua committed Jun 1, 2023
1 parent 034f997 commit bb7be81
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 51 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,14 @@ and this project adheres to [Semantic Versioning].
- Added new product_ids for Fingerbot.
- Added event "fingerbot_button_pressed" which is fired on Fingerbot Plus touch button press.
- First attempt to add support of climate entity.

## [0.1.6] - 2023-06-01

### Added

- Added new product_ids for Fingerbot and Fingerbot Plus.

### Changed

- Updated sources to conform Python 3.11

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The integration works locally, but connection to Tuya BLE device requires device
## Supported devices list

* Fingerbots (category_id 'szjqr')
+ Fingerbot (product_ids 'ltak7e1p', 'yrnk7mnn', 'nvr2rocq'), original device, first in category, powered by CR2 battery.
+ Fingerbot (product_ids 'ltak7e1p', 'y6kttvd6', 'yrnk7mnn', 'nvr2rocq', 'bnt7wajf', 'rvdceqjh', '5xhbk964'), original device, first in category, powered by CR2 battery.
+ Adaprox Fingerbot (product_id 'y6kttvd6'), built-in battery with USB type C charging.
+ Fingerbot Plus (product_ids 'blliqpsj', 'yiihr7zh'), almost same as original, has sensor button for manual control.
+ CubeTouch 1s (product_id '3yqdo5yt'), built-in battery with USB type C charging.
Expand Down
14 changes: 9 additions & 5 deletions custom_components/tuya_ble/button.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""The Tuya BLE integration."""
from __future__ import annotations

from dataclasses import dataclass
from dataclasses import dataclass, field

import logging
from typing import Callable
Expand Down Expand Up @@ -50,8 +50,10 @@ def is_fingerbot_in_push_mode(

@dataclass
class TuyaBLEFingerbotModeMapping(TuyaBLEButtonMapping):
description: ButtonEntityDescription = ButtonEntityDescription(
key="push",
description: ButtonEntityDescription = field(
default_factory=lambda: ButtonEntityDescription(
key="push",
)
)
is_available: TuyaBLEButtonIsAvailable = is_fingerbot_in_push_mode

Expand All @@ -72,13 +74,15 @@ class TuyaBLECategoryButtonMapping:
],
),
**dict.fromkeys(
["blliqpsj", "yiihr7zh"], # Fingerbot Plus
["blliqpsj", "ndvkgsrm", "yiihr7zh"], # Fingerbot Plus
[
TuyaBLEFingerbotModeMapping(dp_id=2),
],
),
**dict.fromkeys(
["ltak7e1p", "y6kttvd6", "yrnk7mnn", "nvr2rocq", "bnt7wajf"], # Fingerbot
["ltak7e1p", "y6kttvd6", "yrnk7mnn",
"nvr2rocq", "bnt7wajf", "rvdceqjh",
"5xhbk964"], # Fingerbot
[
TuyaBLEFingerbotModeMapping(dp_id=2),
],
Expand Down
7 changes: 6 additions & 1 deletion custom_components/tuya_ble/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
ClimateEntityDescription,
ClimateEntity,
)
from homeassistant.components.climate.const import PRESET_AWAY, PRESET_NONE, ClimateEntityFeature, HVACMode
from homeassistant.components.climate.const import (
ClimateEntityFeature,
HVACMode,
PRESET_AWAY,
PRESET_NONE,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import UnitOfTemperature
from homeassistant.core import HomeAssistant, callback
Expand Down
18 changes: 10 additions & 8 deletions custom_components/tuya_ble/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ def _async_handle_update(self, updates: list[TuyaBLEDataPoint]) -> None:
if info.fingerbot and info.fingerbot.manual_control != 0:
for update in updates:
if (update.id == info.fingerbot.switch and
update.changed_by_device):
update.changed_by_device):
self.hass.bus.fire(
FINGERBOT_BUTTON_EVENT,
FINGERBOT_BUTTON_EVENT,
{
CONF_ADDRESS: self._device.address,
CONF_DEVICE_ID: self._device.device_id,
Expand Down Expand Up @@ -211,7 +211,7 @@ class TuyaBLECategoryInfo:
),
),
**dict.fromkeys(
["blliqpsj", "yiihr7zh"], # device product_ids
["blliqpsj", "ndvkgsrm", "yiihr7zh"], # device product_ids
TuyaBLEProductInfo(
name="Fingerbot Plus",
fingerbot=TuyaBLEFingerbotInfo(
Expand All @@ -226,7 +226,9 @@ class TuyaBLECategoryInfo:
)
),
**dict.fromkeys(
["ltak7e1p", "y6kttvd6", "yrnk7mnn", "nvr2rocq", "bnt7wajf"], # device product_ids
["ltak7e1p", "y6kttvd6", "yrnk7mnn",
"nvr2rocq", "bnt7wajf", "rvdceqjh",
"5xhbk964"], # device product_ids
TuyaBLEProductInfo(
name="Fingerbot",
fingerbot=TuyaBLEFingerbotInfo(
Expand Down Expand Up @@ -314,12 +316,12 @@ def get_device_info(device: TuyaBLEDevice) -> DeviceInfo | None:
product_info = get_product_info_by_ids(
device.category,
device.product_id
)
product_name : str
)
product_name: str
if product_info:
product_name = product_info.name
product_name = product_info.name
else:
product_name = device.name
product_name = device.name
result = DeviceInfo(
connections={(dr.CONNECTION_BLUETOOTH, device.address)},
hw_version=device.hardware_version,
Expand Down
2 changes: 1 addition & 1 deletion custom_components/tuya_ble/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"documentation": "https://www.home-assistant.io/integrations/tuya_ble",
"requirements": ["tuya-iot-py-sdk==0.6.6", "pycountry"],
"iot_class": "local_push",
"version": "0.1.5"
"version": "0.1.6"
}
14 changes: 9 additions & 5 deletions custom_components/tuya_ble/number.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""The Tuya BLE integration."""
from __future__ import annotations

from dataclasses import dataclass
from dataclasses import dataclass, field

import logging
from typing import Any, Callable
Expand Down Expand Up @@ -100,7 +100,9 @@ class TuyaBLEHoldTimeDescription(NumberEntityDescription):

@dataclass
class TuyaBLEHoldTimeMapping(TuyaBLENumberMapping):
description: NumberEntityDescription = TuyaBLEHoldTimeDescription()
description: NumberEntityDescription = field(
default_factory=lambda: TuyaBLEHoldTimeDescription()
)
is_available: TuyaBLENumberIsAvailable = is_fingerbot_in_push_mode


Expand Down Expand Up @@ -182,7 +184,7 @@ class TuyaBLECategoryNumberMapping:
],
),
**dict.fromkeys(
["blliqpsj", "yiihr7zh"], # Fingerbot Plus
["blliqpsj", "ndvkgsrm", "yiihr7zh"], # Fingerbot Plus
[
TuyaBLENumberMapping(
dp_id=9,
Expand All @@ -196,7 +198,9 @@ class TuyaBLECategoryNumberMapping:
],
),
**dict.fromkeys(
["ltak7e1p", "y6kttvd6", "yrnk7mnn", "nvr2rocq", "bnt7wajf"], # Fingerbot
["ltak7e1p", "y6kttvd6", "yrnk7mnn",
"nvr2rocq", "bnt7wajf", "rvdceqjh",
"5xhbk964"], # Fingerbot
[
TuyaBLENumberMapping(
dp_id=9,
Expand Down Expand Up @@ -236,7 +240,7 @@ class TuyaBLECategoryNumberMapping:
),
],
},
),
),
"wsdcg": TuyaBLECategoryNumberMapping(
products={
"ojzlzzsw": # Soil moisture sensor
Expand Down
18 changes: 11 additions & 7 deletions custom_components/tuya_ble/select.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""The Tuya BLE integration."""
from __future__ import annotations

from dataclasses import dataclass
from dataclasses import dataclass, field

import logging

Expand Down Expand Up @@ -44,10 +44,12 @@ class TemperatureUnitDescription(SelectEntityDescription):

@dataclass
class TuyaBLEFingerbotModeMapping(TuyaBLESelectMapping):
description: SelectEntityDescription = SelectEntityDescription(
key="fingerbot_mode",
entity_category=EntityCategory.CONFIG,
options=[FINGERBOT_MODE_PUSH, FINGERBOT_MODE_SWITCH],
description: SelectEntityDescription = field(
default_factory=lambda: SelectEntityDescription(
key="fingerbot_mode",
entity_category=EntityCategory.CONFIG,
options=[FINGERBOT_MODE_PUSH, FINGERBOT_MODE_SWITCH],
)
)


Expand Down Expand Up @@ -103,13 +105,15 @@ class TuyaBLECategorySelectMapping:
],
),
**dict.fromkeys(
["blliqpsj", "yiihr7zh"], # Fingerbot Plus
["blliqpsj", "ndvkgsrm", "yiihr7zh"], # Fingerbot Plus
[
TuyaBLEFingerbotModeMapping(dp_id=8),
],
),
**dict.fromkeys(
["ltak7e1p", "y6kttvd6", "yrnk7mnn", "nvr2rocq", "bnt7wajf"], # Fingerbot
["ltak7e1p", "y6kttvd6", "yrnk7mnn",
"nvr2rocq", "bnt7wajf", "rvdceqjh",
"5xhbk964"], # Fingerbot
[
TuyaBLEFingerbotModeMapping(dp_id=8),
],
Expand Down
34 changes: 20 additions & 14 deletions custom_components/tuya_ble/sensor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""The Tuya BLE integration."""
from __future__ import annotations

from dataclasses import dataclass
from dataclasses import dataclass, field

import logging
from typing import Callable
Expand Down Expand Up @@ -63,22 +63,26 @@ class TuyaBLESensorMapping:

@dataclass
class TuyaBLEBatteryMapping(TuyaBLESensorMapping):
description: SensorEntityDescription = SensorEntityDescription(
key="battery",
device_class=SensorDeviceClass.BATTERY,
native_unit_of_measurement=PERCENTAGE,
entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.MEASUREMENT,
description: SensorEntityDescription = field(
default_factory=lambda: SensorEntityDescription(
key="battery",
device_class=SensorDeviceClass.BATTERY,
native_unit_of_measurement=PERCENTAGE,
entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.MEASUREMENT,
)
)


@dataclass
class TuyaBLETemperatureMapping(TuyaBLESensorMapping):
description: SensorEntityDescription = SensorEntityDescription(
key="temperature",
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT,
description: SensorEntityDescription = field(
default_factory=lambda: SensorEntityDescription(
key="temperature",
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT,
)
)


Expand Down Expand Up @@ -186,13 +190,15 @@ class TuyaBLECategorySensorMapping:
],
),
**dict.fromkeys(
["blliqpsj", "yiihr7zh"], # Fingerbot Plus
["blliqpsj", "ndvkgsrm", "yiihr7zh"], # Fingerbot Plus
[
TuyaBLEBatteryMapping(dp_id=12),
],
),
**dict.fromkeys(
["ltak7e1p", "y6kttvd6", "yrnk7mnn", "nvr2rocq", "bnt7wajf"], # Fingerbot
["ltak7e1p", "y6kttvd6", "yrnk7mnn",
"nvr2rocq", "bnt7wajf", "rvdceqjh",
"5xhbk964"], # Fingerbot
[
TuyaBLEBatteryMapping(dp_id=12),
],
Expand Down
24 changes: 15 additions & 9 deletions custom_components/tuya_ble/switch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""The Tuya BLE integration."""
from __future__ import annotations

from dataclasses import dataclass
from dataclasses import dataclass, field

import logging
from typing import Any, Callable
Expand Down Expand Up @@ -52,18 +52,22 @@ def is_fingerbot_in_switch_mode(

@dataclass
class TuyaBLEFingerbotSwitchMapping(TuyaBLESwitchMapping):
description: SwitchEntityDescription = SwitchEntityDescription(
key="switch",
description: SwitchEntityDescription = field(
default_factory=lambda: SwitchEntityDescription(
key="switch",
)
)
is_available: TuyaBLESwitchIsAvailable = is_fingerbot_in_switch_mode


@dataclass
class TuyaBLEReversePositionsMapping(TuyaBLESwitchMapping):
description: SwitchEntityDescription = SwitchEntityDescription(
key="reverse_positions",
icon="mdi:arrow-up-down-bold",
entity_category=EntityCategory.CONFIG,
description: SwitchEntityDescription = field(
default_factory=lambda: SwitchEntityDescription(
key="reverse_positions",
icon="mdi:arrow-up-down-bold",
entity_category=EntityCategory.CONFIG,
)
)
is_available: TuyaBLESwitchIsAvailable = is_fingerbot_in_switch_mode

Expand Down Expand Up @@ -133,7 +137,7 @@ class TuyaBLECategorySwitchMapping:
],
),
**dict.fromkeys(
["blliqpsj", "yiihr7zh"], # Fingerbot Plus
["blliqpsj", "ndvkgsrm", "yiihr7zh"], # Fingerbot Plus
[
TuyaBLEFingerbotSwitchMapping(dp_id=2),
TuyaBLEReversePositionsMapping(dp_id=11),
Expand All @@ -148,7 +152,9 @@ class TuyaBLECategorySwitchMapping:
],
),
**dict.fromkeys(
["ltak7e1p", "y6kttvd6", "yrnk7mnn", "nvr2rocq", "bnt7wajf"], # Fingerbot
["ltak7e1p", "y6kttvd6", "yrnk7mnn",
"nvr2rocq", "bnt7wajf", "rvdceqjh",
"5xhbk964"], # Fingerbot
[
TuyaBLEFingerbotSwitchMapping(dp_id=2),
TuyaBLEReversePositionsMapping(dp_id=11),
Expand Down

0 comments on commit bb7be81

Please sign in to comment.