tuya / tuya-home-assistant

Home Assistant integration for controlling Powered by Tuya (PBT) devices using Tuya Open API, maintained by the Home Assistant Community and Tuya Developer Team.
MIT License
879 stars 207 forks source link

Blind Cover not available in Home Assistant #173

Open AndreAuth opened 3 years ago

AndreAuth commented 3 years ago

Describe the bug Blind Cover is not available in Home Assistant. I cant click on up or down. In the Tuya V1 everything works fine.

Expected behavior The blinds should be available.

Screenshots If applicable, add screenshots to help explain your problem.

Home Assistant Version

Device info (please complete the following information, which can be found in log): like this: { "active_time": 1598543221, "biz_type": 0, "category": "cl", "create_time": 1598543221, "icon": "smart/icon/1505377938_0.jpg", "id": "4040071368c63aeb126a", "ip": "xxx", "lat": "xxx", "local_key": "cc909c9fa2889e87", "lon": "xxx", "model": "SM-SW102-C", "name": "Rollo Links", "online": true, "owner_id": "5813918", "product_id": "rD7uqAAgQOpSA2Rx", "product_name": "Wi-Fi Curtian Switch", "status": [ { "code": "control", "value": "open" } ], "sub": false, "time_zone": "+01:00", "uid": "eu1567921178772u1rvO", "update_time": 1626216299, "uuid": "4040071368c63aeb126a" },

Device specifications (please complete the following information, which can be found in log): Same device's id, like this:

2021-07-19 14:22:42 DEBUG (SyncWorker_5) [tuya iot] Request: method = GET, url = https://openapi.tuyaeu.com/v1.0/devices/4040071368c63aeb126a/specifications, params = None, body = None, headers = {'client_id': 'xxxx', 'sign': '798F945331EA59B7F91B57F0BA1FBF66A5D557FEC4150B0DE25063D0D0D42C60', 'sign_method': 'HMAC-SHA256', 'access_token': 'xxxx', 't': '1626697362499', 'lang': 'en'} 2021-07-19 14:22:42 DEBUG (SyncWorker_5) [tuya iot] Response: { "result": { "category": "cl", "functions": [ { "code": "control", "type": "Enum", "values": "{\"range\":[\"open\",\"stop\",\"close\"]}" } ], "status": [ { "code": "control", "type": "Enum", "values": "{\"range\":[\"open\",\"close\",\"stop\"]}" } ] }, "success": true, "t": 1626697362550 }

Additional context Add any other context or logs about the problem here.

AndreAuth commented 3 years ago

On startUp i also get this Error:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 383, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 588, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 666, in add_to_platform_finish self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 419, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 453, in _async_write_ha_state state = self._stringify_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 425, in _stringify_state state = self.state File "/usr/src/homeassistant/homeassistant/components/cover/init.py", line 208, in state closed = self.is_closed File "/usr/src/homeassistant/homeassistant/components/cover/init.py", line 265, in is_closed return self._attr_is_closed AttributeError: 'TuyaHaCover' object has no attribute '_attr_is_closed'

rjmarques commented 3 years ago

Piggybacking on this thread, I have the exact same home assistant version and log error for my blind cover. Just a slightly different device.

{
"active_time": 1626809325,
"biz_type": 18,
"category": "cl",
"create_time": 1626809325,
"icon": "smart/program_category_icon/cl.png",
"id": "00408365e8db84c63765",
"ip": "********",
"lat": "",
"local_key": "*********",
"lon": "",
"name": "Blinds Controller",
"online": true,
"owner_id": "*********",
"product_id": "3r8gc33pnqsxfe1g",
"product_name": "Blinds Controller",
"status": [
{
"code": "control",
"value": "close"
},
{
"code": "percent_control",
"value": 78
},
{
"code": "percent_state",
"value": 78
},
{
"code": "control_back",
"value": false
},
{
"code": "work_state",
"value": "closing"
},
{
"code": "countdown",
"value": "cancel"
},
{
"code": "countdown_left",
"value": 0
}
rjmarques commented 3 years ago

Update: The problem has gone away with the latest version of the integration.

Now only one problem remains. If I move the slider in the UI to 100% (fully closed) then after the operation is complete, the value reported to home-assistant jumps back to 0 (and so does the slider). Moreover, if I set the slider at 70% the value reported to home-assistant then becomes 30%.

I think the issue comes from this function. In the case of my blinds, it should not do 100 - position.

burnworld3d commented 3 years ago

@rjmarques You can try with: https://github.com/Deejayfool/hass-shutter-card It can be installed using HACS, and it allows you to reverse the position: invert_percentage = true

@AndreAuth i think your device needs to be standarized, as it's missing the "percent_control" enum. Open a ticket with tuya team so they can add it, after is added, your devices will work and you will be able to close this issue.

Regards

rjmarques commented 3 years ago

Thanks for the suggestion @burnworld3d. I tried it and it behaves exactly the same as the default cover card.

I don't think this is a UI issue, however. The code that I linked above is the actual entity code and I believe it's only flipping the percentage in one place? Should it not be consistent and do it either everywhere or nowhere?