Skip to content

Commit

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

- Added support of 'Irrigation computer', thanks to @SanMiggel.
- Added new product_ids for Smart locks, thanks to @drewpo28.

### Changed

- Connection to the device is postponed now. Previously some out of range device might prevents HA from fully booting.
- Improved connection stability.
  • Loading branch information
PlusPlus-ua committed Jul 9, 2023
1 parent 1d2e593 commit 6037ac5
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 33 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,14 @@ and this project adheres to [Semantic Versioning].

- Improved connection stability.

## [0.1.8] - 2023-07-09

### Added

- Added support of 'Irrigation computer', thanks to @SanMiggel.
- Added new product_ids for Smart locks, thanks to @drewpo28.

### Changed

- Connection to the device is postponed now. Previously some out of range device might prevents HA from fully booting.
- Improved connection stability.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@ The integration works locally, but connection to Tuya BLE device requires device
+ CO2 Detector (product_id '59s19z5m').

* Smart Locks (category_id 'ms')
+ Smart Lock (product_id 'ludzroix'), first attempt to support for now.
+ Smart Lock (product_id 'ludzroix', 'isk2p555').

* Climate (category_id 'wk')
+ Thermostatic Radiator Valve (product_ids 'drlajpqc', 'nhj2j7su').

* Smart water bottle (category_id 'znhsb')
+ Smart water bottle (product_id 'cdlandip')

* Irrigation computer (category_id 'ggq')
+ Irrigation computer (product_id '6pahkcau')

## Support project

I am working on this integration in Ukraine. Our country was subjected to brutal aggression by Russia. The war still continues. The capital of Ukraine - Kyiv, where I live, and many other cities and villages are constantly under threat of rocket attacks. Our air defense forces are doing wonders, but they also need support. So if you want to help the development of this integration, donate some money and I will spend it to support our air defense.
Expand Down
4 changes: 4 additions & 0 deletions custom_components/tuya_ble/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
product_info = get_device_product_info(device)

coordinator = TuyaBLECoordinator(hass, device)

'''
try:
await device.update()
except BLEAK_EXCEPTIONS as ex:
raise ConfigEntryNotReady(
f"Could not communicate with Tuya BLE device with address {address}"
) from ex
'''
hass.add_job(device.update())

@callback
def _async_update_ble(
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==22.3.5"],
"iot_class": "local_push",
"version": "0.1.7"
"version": "0.1.8"
}
31 changes: 15 additions & 16 deletions custom_components/tuya_ble/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
}
},
"select": {
"beep_volume": {
"name": "Lock Volume"
},
"fingerbot_mode": {
"name": "Mode",
"state": {
Expand All @@ -89,12 +92,12 @@
},
"temperature_unit": {
"name": "Temperature unit"
},
"beep_volume": {
"name": "Lock Volume"
}
},
"sensor": {
"alarm_lock": {
"name": "Alarm"
},
"battery": {
"name": "Battery"
},
Expand Down Expand Up @@ -127,9 +130,15 @@
"humidity": {
"name": "Humidity"
},
"low_battery": {
"name": "Low Battery"
},
"moisture": {
"name": "Moisture"
},
"residual_electricity": {
"name": "Battery"
},
"signal_strength": {
"name": "Signal strength"
},
Expand All @@ -142,20 +151,11 @@
"water_intake": {
"name": "Water intake"
},
"residual_electricity": {
"name": "Battery"
},
"alarm_lock": {
"name": "Alarm"
},
"wrong_finger": {
"name": "Wrong Fingerprint"
},
"wrong_password": {
"name": "Wrong Password"
},
"low_battery": {
"name": "Low battery"
}
},
"switch": {
Expand All @@ -171,6 +171,9 @@
"child_lock": {
"name": "Child Lock"
},
"lock_motor_state": {
"name": "Motor State"
},
"low_battery_alarm": {
"name": "Low battery alarm"
},
Expand Down Expand Up @@ -203,11 +206,7 @@
},
"window_check": {
"name": "Window Check"
},
"lock_motor_state": {
"name": "Motor State"
}

},
"text": {
"program": {
Expand Down
30 changes: 15 additions & 15 deletions custom_components/tuya_ble/tuya_ble/tuya_ble.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,21 +267,7 @@ async def initialize(self) -> None:
_LOGGER.debug("%s: Initializing", self.address)
if await self._update_device_info():
self._decode_advertisement_data()

await self.update()
'''
async def _start_session(self) -> None:
_LOGGER.debug("%s: Sending device info request", self.address)
await self._send_packet(TuyaBLECode.FUN_SENDER_DEVICE_INFO, bytes(0))
await self.pair()
# gives an ability to receive and handle timestamp request
# and first datapoints
await asyncio.sleep(0.5)
await self.update()
'''

def _build_pairing_request(self) -> bytes:
result = bytearray()

Expand Down Expand Up @@ -554,6 +540,8 @@ async def _execute_disconnect(self) -> None:
async def _ensure_connected(self) -> None:
"""Ensure connection to device is established."""
global global_connect_lock
if self._expected_disconnect:
return
if self._connect_lock.locked():
_LOGGER.debug(
"%s: Connection already in progress,"
Expand Down Expand Up @@ -692,7 +680,11 @@ async def _reconnect(self) -> None:
async with self._seq_num_lock:
self._current_seq_num = 1
try:
if self._expected_disconnect:
return
await self._ensure_connected()
if self._expected_disconnect:
return
_LOGGER.debug("%s: Reconnect, connection ensured", self.address)
except BLEAK_EXCEPTIONS: # BleakNotFoundError:
_LOGGER.debug(
Expand Down Expand Up @@ -813,7 +805,11 @@ async def _send_packet(
# retry: int | None = None,
) -> None:
"""Send packet to device and optional read response."""
if self._expected_disconnect:
return
await self._ensure_connected()
if self._expected_disconnect:
return
await self._send_packet_while_connected(code, data, 0, wait_for_response)

async def _send_response(
Expand Down Expand Up @@ -905,7 +901,11 @@ async def _int_send_packet_while_connected(
raise

async def _resend_packets(self, packets: list[bytes]) -> None:
if self._expected_disconnect:
return
await self._ensure_connected()
if self._expected_disconnect:
return
await self._int_send_packet_while_connected(packets)

async def _send_packets_locked(self, packets: list[bytes]) -> None:
Expand Down

0 comments on commit 6037ac5

Please sign in to comment.