rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
2.74k stars 533 forks source link

Door sensors and water valves.. #673

Open atv2016 opened 2 years ago

atv2016 commented 2 years ago

Will battery powered door sensors be supported any time soon?

what about smart water valves? I can help with testing if needed.

J4YRD commented 2 years ago

After having some pretty good success with a heap of lights and switches I have just picked up 4 x battery powered door sensors, but am getting this error (is this the problem you are asking about?):

This error originated from a custom integration.

Logger: custom_components.localtuya.config_flow
Source: custom_components/localtuya/pytuya/__init__.py:637
Integration: LocalTuya (documentation, issues)
First occurred: 10:14:57 PM (2 occurrences)
Last logged: 10:18:46 PM

Unexpected exception
Traceback (most recent call last):
  File "/config/custom_components/localtuya/config_flow.py", line 279, in async_step_basic_info
    self.dps_strings = await validate_input(self.hass, user_input)
  File "/config/custom_components/localtuya/config_flow.py", line 185, in validate_input
    interface = await pytuya.connect(
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 637, in connect
    _, protocol = await loop.create_connection(
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1056, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1041, in create_connection
    sock = await self._connect_sock(
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 955, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 502, in sock_connect
    return await fut
  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 537, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.68.184', 6668)
leeyuentuen commented 2 years ago

For the water valve i've use Localtuya on this forked project: https://github.com/leeyuentuen/localtuya

  • host: 172.16.0.xxx device_id: 5656xxxxxxxxxxxxxxxx local_key: f9dxxxxxxx friendly_name: "Local xxx Valve" protocol_version: "3.3" scan_interval: 1 entities:
    • platform: switch friendly_name: Local xxx Valve id: 1
    • platform: number friendly_name: Local xxxx Valve Countdown id: 9
leeyuentuen commented 2 years ago

For the battery device like the door sensor, it is not possible at the moment to use them in Localtuya (if it used the wifi version). On the door opens, it will just send very quick a signal (MQTT message) to the tuya server. Unless we pick up the message and reroute it to our own server, then we can reproduce the MQTT message

on the ZigBee version, it should work on that same forked project.