Skip to content

Commit

Permalink
Update to version 0.1.1
Browse files Browse the repository at this point in the history
Added new product_id for Fingerbot Plus
Fixed problem in options flow.
Updated strings.json
  • Loading branch information
PlusPlus-ua committed Apr 26, 2023
1 parent 09ed967 commit 057ea7a
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 61 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,17 @@ and this project adheres to [Semantic Versioning].
## [0.1.0] - 2023-04-22

- Initial release

## [0.1.1] - 2023-04-26

### Added

- Added new product_id for Fingerbot Plus (#1)

### Fixed

- Fixed problem in options flow.

### Changed

- Updated strings.json
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The integration works locally, but connection to Tuya BLE device requires device

* Fingerbots (category_id 'szjqr')
+ Fingerbot (product_id 'yrnk7mnn'), original device, first in category, powered by CR2 battery.
+ Fingerbot Plus (product_id 'yiihr7zh'), almost same as original, has sensor button for manual control.
+ Fingerbot Plus (product_ids 'blliqpsj', 'yiihr7zh'), almost same as original, has sensor button for manual control.
+ CubeTouch II (product_id 'xhf790if'), bult-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 Down
10 changes: 6 additions & 4 deletions custom_components/tuya_ble/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ class TuyaBLECategoryButtonMapping:
[
TuyaBLEFingerbotModeMapping(dp_id=1),
],
"yiihr7zh": # Fingerbot Plus
[
TuyaBLEFingerbotModeMapping(dp_id=2),
],
**dict.fromkeys(
["blliqpsj", "yiihr7zh"], # Fingerbot Plus
[
TuyaBLEFingerbotModeMapping(dp_id=2),
],
),
"yrnk7mnn": # Fingerbot
[
TuyaBLEFingerbotModeMapping(dp_id=2),
Expand Down
4 changes: 4 additions & 0 deletions custom_components/tuya_ble/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,7 @@ async def get_device_credentials(
self._data.update(credentials)

return result

@property
def data(self) -> dict[str, Any]:
return self._data
18 changes: 11 additions & 7 deletions custom_components/tuya_ble/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
import voluptuous as vol
from tuya_iot import AuthType

from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
OptionsFlowWithConfigEntry,
)
from homeassistant.components.bluetooth import (
BluetoothServiceInfoBleak,
async_discovered_service_info,
Expand Down Expand Up @@ -144,12 +148,12 @@ def _show_login_form(
)


class TuyaBLEOptionsFlow(OptionsFlow):
class TuyaBLEOptionsFlow(OptionsFlowWithConfigEntry):
"""Handle a Tuya BLE options flow."""

def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize options flow."""
self.config_entry = config_entry
super().__init__(config_entry)

async def async_step_init(
self, user_input: dict[str, Any] | None = None
Expand All @@ -172,21 +176,20 @@ async def async_step_login(
self.config_entry.entry_id
]
if entry:
data = await _try_login(
login_data = await _try_login(
entry.manager,
user_input,
errors,
placeholders,
)
if data:
if login_data:
credentials = await entry.manager.get_device_credentials(
address, True, True
)
if credentials:
return self.async_create_entry(
title=self.config_entry.title,
data=self.config_entry.data,
options=data,
data=entry.manager.data,
)
else:
errors["base"] = "device_not_registered"
Expand All @@ -205,6 +208,7 @@ class TuyaBLEConfigFlow(ConfigFlow, domain=DOMAIN):

def __init__(self) -> None:
"""Initialize the config flow."""
super().__init__()
self._discovery_info: BluetoothServiceInfoBleak | None = None
self._discovered_devices: dict[str, BluetoothServiceInfoBleak] = {}
self._data: dict[str, Any] = {}
Expand Down
32 changes: 17 additions & 15 deletions custom_components/tuya_ble/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(self, hass: HomeAssistant, device: TuyaBLEDevice) -> None:
@property
def connected(self) -> bool:
return not self._disconnected

@callback
def _async_handle_connect(self) -> None:
if self._unsub_disconnect is not None:
Expand Down Expand Up @@ -172,20 +172,22 @@ class TuyaBLECategoryInfo:
up_position=5,
down_position=6,
hold_time=3,
reverse_positions=4,
reverse_positions=4,
),
),
"yiihr7zh": # device product_id
TuyaBLEProductInfo(
name="Fingerbot Plus",
fingerbot=TuyaBLEFingerbotInfo(
switch=2,
mode=8,
up_position=15,
down_position=9,
hold_time=10,
reverse_positions=11,
),
**dict.fromkeys(
["blliqpsj", "yiihr7zh"], # device product_ids
TuyaBLEProductInfo(
name="Fingerbot Plus",
fingerbot=TuyaBLEFingerbotInfo(
switch=2,
mode=8,
up_position=15,
down_position=9,
hold_time=10,
reverse_positions=11,
),
)
),
"yrnk7mnn": # device product_id
TuyaBLEProductInfo(
Expand All @@ -196,9 +198,9 @@ class TuyaBLECategoryInfo:
up_position=15,
down_position=9,
hold_time=10,
reverse_positions=11,
reverse_positions=11,
),
),
),
},
),
"wsdcg": TuyaBLECategoryInfo(
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.0"
"version": "0.1.1"
}
26 changes: 14 additions & 12 deletions custom_components/tuya_ble/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,20 @@ class TuyaBLECategoryNumberMapping:
),
),
],
"yiihr7zh": # Fingerbot Plus
[
TuyaBLENumberMapping(
dp_id=9,
description=TuyaBLEDownPositionDescription(),
),
TuyaBLEHoldTimeMapping(dp_id=10),
TuyaBLENumberMapping(
dp_id=15,
description=TuyaBLEUpPositionDescription(),
),
],
**dict.fromkeys(
["blliqpsj", "yiihr7zh"], # Fingerbot Plus
[
TuyaBLENumberMapping(
dp_id=9,
description=TuyaBLEDownPositionDescription(),
),
TuyaBLEHoldTimeMapping(dp_id=10),
TuyaBLENumberMapping(
dp_id=15,
description=TuyaBLEUpPositionDescription(),
),
],
),
"yrnk7mnn": # Fingerbot
[
TuyaBLENumberMapping(
Expand Down
10 changes: 6 additions & 4 deletions custom_components/tuya_ble/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,12 @@ class TuyaBLECategorySelectMapping:
[
TuyaBLEFingerbotModeMapping(dp_id=2),
],
"yiihr7zh": # Fingerbot Plus
[
TuyaBLEFingerbotModeMapping(dp_id=8),
],
**dict.fromkeys(
["blliqpsj", "yiihr7zh"], # Fingerbot Plus
[
TuyaBLEFingerbotModeMapping(dp_id=8),
],
),
"yrnk7mnn": # Fingerbot
[
TuyaBLEFingerbotModeMapping(dp_id=8),
Expand Down
10 changes: 6 additions & 4 deletions custom_components/tuya_ble/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,12 @@ class TuyaBLECategorySensorMapping:
),
TuyaBLEBatteryMapping(dp_id=8),
],
"yiihr7zh": # Fingerbot Plus
[
TuyaBLEBatteryMapping(dp_id=12),
],
**dict.fromkeys(
["blliqpsj", "yiihr7zh"], # Fingerbot Plus
[
TuyaBLEBatteryMapping(dp_id=12),
],
),
"yrnk7mnn": # Fingerbot
[
TuyaBLEBatteryMapping(dp_id=12),
Expand Down
7 changes: 6 additions & 1 deletion custom_components/tuya_ble/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"step": {
"device": {
"data": {
"address": "Bluetooth address"
"address": "Tuya BLE device"
},
"description": "Select Tuya BLE device to setup. Device must be registered in the cloud using the mobile application. It's better to unbind the device from Tuya Bluetooth gateway, if any."
},
Expand Down Expand Up @@ -131,6 +131,11 @@
}
},
"options": {
"error": {
"device_not_registered": "Device is not registered in Tuya cloud",
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
"login_error": "Login error ({code}): {msg}"
},
"step": {
"login": {
"data": {
Expand Down
26 changes: 14 additions & 12 deletions custom_components/tuya_ble/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,21 @@ class TuyaBLECategorySwitchMapping:
TuyaBLEFingerbotSwitchMapping(dp_id=1),
TuyaBLEReversePositionsMapping(dp_id=4),
],
"yiihr7zh": # Fingerbot Plus
[
TuyaBLEFingerbotSwitchMapping(dp_id=2),
TuyaBLEReversePositionsMapping(dp_id=11),
TuyaBLESwitchMapping(
dp_id=17,
description=SwitchEntityDescription(
key="manual_control",
icon="mdi:gesture-tap-box",
entity_category=EntityCategory.CONFIG,
**dict.fromkeys(
["blliqpsj", "yiihr7zh"], # Fingerbot Plus
[
TuyaBLEFingerbotSwitchMapping(dp_id=2),
TuyaBLEReversePositionsMapping(dp_id=11),
TuyaBLESwitchMapping(
dp_id=17,
description=SwitchEntityDescription(
key="manual_control",
icon="mdi:gesture-tap-box",
entity_category=EntityCategory.CONFIG,
),
),
),
],
],
),
"yrnk7mnn": # Fingerbot
[
TuyaBLEFingerbotSwitchMapping(dp_id=2),
Expand Down
6 changes: 6 additions & 0 deletions custom_components/tuya_ble/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@
}
},
"options": {
"error": {
"device_not_registered": "Device is not registered in Tuya cloud",
"invalid_auth": "Invalid authentication",
"login_error": "Login error ({code}): {msg}"
},
"flow_title": "{name}",
"step": {
"login": {
"data": {
Expand Down

0 comments on commit 057ea7a

Please sign in to comment.