Skip to content

Commit

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

- Added support of CUBETOUCH 1s, thanks @damiano75
- Added new product_ids for Fingerbot.
- Added new product_ids for Fingerbot Plus.
- First attempt to support Smart Lock device.

### Fixed

- Fixed possible disconnect of BLE device.
  • Loading branch information
PlusPlus-ua committed Apr 30, 2023
1 parent 9c3f484 commit 20b17b7
Show file tree
Hide file tree
Showing 11 changed files with 227 additions and 130 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,17 @@ and this project adheres to [Semantic Versioning].
### Changed

- Changed a way to obtain device credentials from Tuya IOT cloud, possible fix to (#2)

## [0.1.4] - 2023-04-30

### Added

- Added support of CUBETOUCH 1s, thanks @damiano75
- Added new product_ids for Fingerbot.
- Added new product_ids for Fingerbot Plus.
- First attempt to support Smart Lock device.

### Fixed

- Fixed possible disconnect of BLE device.

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

* Fingerbots (category_id 'szjqr')
+ Fingerbot (product_id 'yrnk7mnn'), original device, first in category, powered by CR2 battery.
+ Fingerbot (product_ids 'ltak7e1p', 'yrnk7mnn'), 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.
+ CubeTouch II (product_id 'xhf790if'), built-in battery with USB type C charging.

All features available in Home Assistant, except programming (series of actions) - it's not documented and looks useless because it could be implemented by Home Assistant scripts or automations.
Expand All @@ -33,3 +34,6 @@ The integration works locally, but connection to Tuya BLE device requires device

* CO2 sensors (category_id 'co2bj')
+ CO2 Detector (product_id '59s19z5m').

* Smart Locks (category_id 'ms')
+ Smart Lock (product_id 'ludzroix'), first attempt to support for now.
4 changes: 2 additions & 2 deletions custom_components/tuya_ble/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def is_fingerbot_in_push_mode(
self: TuyaBLEButton,
product: TuyaBLEProductInfo
) -> bool:
result: bool = False
result: bool = True
if product.fingerbot:
datapoint = self._device.datapoints[product.fingerbot.mode]
if datapoint:
Expand Down Expand Up @@ -78,7 +78,7 @@ class TuyaBLECategoryButtonMapping:
],
),
**dict.fromkeys(
["y6kttvd6", "yrnk7mnn"], # Fingerbot
["ltak7e1p", "y6kttvd6", "yrnk7mnn"], # Fingerbot
[
TuyaBLEFingerbotModeMapping(dp_id=2),
],
Expand Down
8 changes: 4 additions & 4 deletions custom_components/tuya_ble/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,16 @@ async def async_step_login(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Handle the Tuya IOT platform login step."""
data: dict[str, Any] | None = None
errors: dict[str, str] = {}
placeholders: dict[str, Any] = {}
credentials: TuyaBLEDeviceCredentials | None = None
address: str | None = self.config_entry.data.get(CONF_ADDRESS)

if user_input is not None:
entry: TuyaBLEData = self.hass.data[DOMAIN][
self.config_entry.entry_id
]
entry: TuyaBLEData | None = None
domain_data = self.hass.data.get(DOMAIN)
if domain_data:
entry = domain_data.get(self.config_entry.entry_id)
if entry:
login_data = await _try_login(
entry.manager,
Expand Down
10 changes: 9 additions & 1 deletion custom_components/tuya_ble/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ class TuyaBLECategoryInfo:
),
},
),
"ms": TuyaBLECategoryInfo(
products={
"ludzroix": # device product_id
TuyaBLEProductInfo(
name="Smart Lock",
),
},
),
"szjqr": TuyaBLECategoryInfo(
products={
"3yqdo5yt": # device product_id
Expand Down Expand Up @@ -202,7 +210,7 @@ class TuyaBLECategoryInfo:
)
),
**dict.fromkeys(
["y6kttvd6", "yrnk7mnn"], # device product_ids
["ltak7e1p", "y6kttvd6", "yrnk7mnn"], # device product_ids
TuyaBLEProductInfo(
name="Fingerbot",
fingerbot=TuyaBLEFingerbotInfo(
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.2"
"version": "0.1.4"
}
22 changes: 20 additions & 2 deletions custom_components/tuya_ble/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def is_fingerbot_in_push_mode(
self: TuyaBLENumber,
product: TuyaBLEProductInfo
) -> bool:
result: bool = False
result: bool = True
if product.fingerbot:
datapoint = self._device.datapoints[product.fingerbot.mode]
if datapoint:
Expand Down Expand Up @@ -143,6 +143,24 @@ class TuyaBLECategoryNumberMapping:
],
},
),
"ms": TuyaBLECategoryNumberMapping(
products={
"ludzroix": # Smart Lock
[
TuyaBLENumberMapping(
dp_id=8,
description=NumberEntityDescription(
key="residual_electricity",
native_max_value=100,
native_min_value=-1,
native_unit_of_measurement=PERCENTAGE,
native_step=1,
entity_category=EntityCategory.CONFIG,
),
),
]
}
),
"szjqr": TuyaBLECategoryNumberMapping(
products={
**dict.fromkeys(
Expand Down Expand Up @@ -178,7 +196,7 @@ class TuyaBLECategoryNumberMapping:
],
),
**dict.fromkeys(
["y6kttvd6", "yrnk7mnn"], # Fingerbot
["ltak7e1p", "y6kttvd6", "yrnk7mnn"], # Fingerbot
[
TuyaBLENumberMapping(
dp_id=9,
Expand Down
42 changes: 31 additions & 11 deletions custom_components/tuya_ble/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,25 @@ class TuyaBLECategorySelectMapping:
],
},
),
"wsdcg": TuyaBLECategorySelectMapping(
"ms": TuyaBLECategorySelectMapping(
products={
"ojzlzzsw": # Soil moisture sensor
"ludzroix": # Smart Lock
[
TuyaBLESelectMapping(
dp_id=9,
description=TemperatureUnitDescription(
dp_id=31,
description=SelectEntityDescription(
key="beep_volume",
options=[
UnitOfTemperature.CELSIUS,
UnitOfTemperature.FAHRENHEIT,
"mute",
"low",
"normal",
"high",
],
entity_registry_enabled_default=False,
)
entity_category=EntityCategory.CONFIG,
),
),
],
},
]
}
),
"szjqr": TuyaBLECategorySelectMapping(
products={
Expand All @@ -106,13 +109,30 @@ class TuyaBLECategorySelectMapping:
],
),
**dict.fromkeys(
["y6kttvd6", "yrnk7mnn"], # Fingerbot
["ltak7e1p", "y6kttvd6", "yrnk7mnn"], # Fingerbot
[
TuyaBLEFingerbotModeMapping(dp_id=8),
],
),
},
),
"wsdcg": TuyaBLECategorySelectMapping(
products={
"ojzlzzsw": # Soil moisture sensor
[
TuyaBLESelectMapping(
dp_id=9,
description=TemperatureUnitDescription(
options=[
UnitOfTemperature.CELSIUS,
UnitOfTemperature.FAHRENHEIT,
],
entity_registry_enabled_default=False,
)
),
],
},
),
}


Expand Down
21 changes: 20 additions & 1 deletion custom_components/tuya_ble/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,25 @@ class TuyaBLECategorySensorMapping:
]
}
),
"ms": TuyaBLECategorySensorMapping(
products={
"ludzroix": # Smart Lock
[
TuyaBLESensorMapping(
dp_id=21,
description=SensorEntityDescription(
key="alarm_lock",
device_class=SensorDeviceClass.ENUM,
options=[
"wrong_finger",
"wrong_password",
"low_battery",
],
),
),
]
}
),
"szjqr": TuyaBLECategorySensorMapping(
products={
**dict.fromkeys(
Expand Down Expand Up @@ -173,7 +192,7 @@ class TuyaBLECategorySensorMapping:
],
),
**dict.fromkeys(
["y6kttvd6", "yrnk7mnn"], # Fingerbot
["ltak7e1p", "y6kttvd6", "yrnk7mnn"], # Fingerbot
[
TuyaBLEBatteryMapping(dp_id=12),
],
Expand Down
46 changes: 21 additions & 25 deletions custom_components/tuya_ble/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def is_fingerbot_in_switch_mode(
self: TuyaBLESwitch,
product: TuyaBLEProductInfo
) -> bool:
result: bool = False
result: bool = True
if product.fingerbot:
datapoint = self._device.datapoints[product.fingerbot.mode]
if datapoint:
Expand Down Expand Up @@ -110,32 +110,28 @@ class TuyaBLECategorySwitchMapping:
],
},
),
"szjqr": TuyaBLECategorySwitchMapping(
"ms": TuyaBLECategorySwitchMapping(
products={
"3yqdo5yt": # CubeTouch 1s
"ludzroix": # Smart Lock
[
TuyaBLEFingerbotSwitchMapping(dp_id=1),
TuyaBLEReversePositionsMapping(dp_id=4),
TuyaBLESwitchMapping(
dp_id=9,
description=SwitchEntityDescription(
key="power_saving",
entity_category=EntityCategory.CONFIG,
),
),
TuyaBLESwitchMapping(
dp_id=10,
description=SwitchEntityDescription(
key="tap_enable",
entity_category=EntityCategory.CONFIG,
),
TuyaBLESwitchMapping(
dp_id=47,
description=SwitchEntityDescription(
key="lock_motor_state",
),
],
"xhf790if": # CubeTouch II
[
TuyaBLEFingerbotSwitchMapping(dp_id=1),
TuyaBLEReversePositionsMapping(dp_id=4),
],
),
]
}
),
"szjqr": TuyaBLECategorySwitchMapping(
products={
**dict.fromkeys(
["3yqdo5yt", "xhf790if"], # CubeTouch 1s and II
[
TuyaBLEFingerbotSwitchMapping(dp_id=1),
TuyaBLEReversePositionsMapping(dp_id=4),
],
),
**dict.fromkeys(
["blliqpsj", "yiihr7zh"], # Fingerbot Plus
[
Expand All @@ -152,7 +148,7 @@ class TuyaBLECategorySwitchMapping:
],
),
**dict.fromkeys(
["y6kttvd6", "yrnk7mnn"], # Fingerbot
["ltak7e1p", "y6kttvd6", "yrnk7mnn"], # Fingerbot
[
TuyaBLEFingerbotSwitchMapping(dp_id=2),
TuyaBLEReversePositionsMapping(dp_id=11),
Expand Down
Loading

0 comments on commit 20b17b7

Please sign in to comment.