Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add changes from upstream #10

Merged
merged 97 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
8c597bb
Fix for AttributeError: 'TuyaMessage' object has no attribute 'releas…
sibowler Oct 16, 2022
831ae55
#711 Implemented m/p HVAC mode set
Daandeve Jan 24, 2022
a2e04b4
Merge pull request #712 from Daandeve/master
rospogrigio Nov 14, 2022
4a5bf83
Introduced pytuya with support for 3.4 protocol
rospogrigio Jan 7, 2023
5fbf5b3
Introduced 3.4 protocol option in config flow
rospogrigio Jan 7, 2023
24853b5
Fixed HEARTBEAT command
rospogrigio Jan 7, 2023
9d94f16
Added debugging
rospogrigio Jan 7, 2023
9efbcce
Fixed requested DPs for type_0d devices
rospogrigio Jan 8, 2023
f23a945
Fixed negotiation and sequence numbers for protocol 3.4
rospogrigio Jan 9, 2023
ecf66f7
Fixed sequence numbering on status update
rospogrigio Jan 9, 2023
0865aa6
Merge branch 'rospogrigio:master' into fix_semaphore_release_error
sibowler Jan 9, 2023
966c3ec
Fixed tox issues
rospogrigio Jan 9, 2023
f990e84
Fixed tox issues
rospogrigio Jan 9, 2023
33c92dc
Updated README.md and info.md
rospogrigio Jan 9, 2023
9c6daec
Merge branch 'protocol_3.4' of github.com:rospogrigio/localtuya into …
rospogrigio Jan 9, 2023
cdcfd1d
Fixed tox issues
rospogrigio Jan 9, 2023
d8acf60
Fix for version not being set yet when calling _setup_dispatcher
rospogrigio Jan 10, 2023
33e0033
Introduced the possibility to select which devices should have the py…
rospogrigio Jan 10, 2023
bc89105
Introduced device debugging option in README.md and info.md
rospogrigio Jan 10, 2023
957cf25
Introduced pytuya with support for 3.4 protocol
rospogrigio Jan 7, 2023
c6a9460
Introduced 3.4 protocol option in config flow
rospogrigio Jan 7, 2023
0fb6199
Fixed HEARTBEAT command
rospogrigio Jan 7, 2023
a3914cc
Added debugging
rospogrigio Jan 7, 2023
960f07b
Fixed requested DPs for type_0d devices
rospogrigio Jan 8, 2023
edc6752
Fixed negotiation and sequence numbers for protocol 3.4
rospogrigio Jan 9, 2023
c9d6bc5
Fixed sequence numbering on status update
rospogrigio Jan 9, 2023
3bf69d6
Fixed tox issues
rospogrigio Jan 9, 2023
39ef76b
Fixed tox issues
rospogrigio Jan 9, 2023
95b3113
Updated README.md and info.md
rospogrigio Jan 9, 2023
2f0f507
Fixed tox issues
rospogrigio Jan 9, 2023
0f3160f
Fix for version not being set yet when calling _setup_dispatcher
rospogrigio Jan 10, 2023
c379645
Introduced abort in config flow if all entities are deselected when e…
rospogrigio Jan 10, 2023
20ab401
Introduced IT and PT translations
rospogrigio Jan 10, 2023
1e3b047
Merge branch 'master' into device_debugging_option
rospogrigio Jan 10, 2023
1f85551
Merge pull request #1227 from rospogrigio/device_debugging_option
rospogrigio Jan 10, 2023
828000b
Update manifest.json for 5.0.0
rospogrigio Jan 10, 2023
f4164cd
New tuyadebug.tgz now supporting protocol 3.4
rospogrigio Jan 10, 2023
b9c0e5e
Update bug_report.md
rospogrigio Jan 12, 2023
c15fcaa
Fix for unknown state of covers/shutters
rospogrigio Jan 12, 2023
98cc44f
New tuyadebug.tgz now including a tinytuya test
rospogrigio Jan 12, 2023
da6e929
Merge branch 'master' into fix_semaphore_release_error
sibowler Jan 23, 2023
4d3a6cc
Force to int
CloCkWeRX Jan 23, 2023
dccb328
Adjust input to avoid putting a string into an int
CloCkWeRX Jan 23, 2023
8ff194e
Adjust input to avoid putting a string into an int
CloCkWeRX Jan 23, 2023
77ac5a8
Swap to int
CloCkWeRX Jan 23, 2023
613bde4
Improved logging
rospogrigio Jan 24, 2023
7a97fdf
Improved stability and Fix local_key update to not be thwarted by ret…
rospogrigio Jan 24, 2023
adab66d
Merge branch 'sibowler-fix_semaphore_release_error' into stability_fixes
rospogrigio Jan 24, 2023
86eabbd
Merge branch 'sibowler-fix_semaphore_release_error' into stability_fixes
rospogrigio Jan 24, 2023
6371c97
Merge branch 'CloCkWeRX-fix-casting-issue' into stability_fixes
rospogrigio Jan 29, 2023
cd97287
Merge branch 'stability_fixes' of github.com:rospogrigio/localtuya-ho…
rospogrigio Jan 29, 2023
cf3221d
Introduced update of local_key when editing a device
rospogrigio Feb 6, 2023
06d54f9
Merge branch 'stability_fixes' of github.com:rospogrigio/localtuya in…
rospogrigio Feb 6, 2023
a47e7f7
Merge branch 'stability_fixes' of github.com:rospogrigio/localtuya in…
rospogrigio Feb 6, 2023
c909349
Improved logging
rospogrigio Feb 6, 2023
999d50e
Merge branch 'stability_fixes' of github.com:rospogrigio/localtuya-ho…
rospogrigio Feb 6, 2023
6d0e407
Tox fixes
rospogrigio Feb 7, 2023
febbf42
Tox fixes
rospogrigio Feb 7, 2023
f51d833
Tox fixes
rospogrigio Feb 7, 2023
fa301d1
Fix for not reconnecting after 'giving up'
rospogrigio Feb 7, 2023
d4af0f6
Tox fixes
rospogrigio Feb 7, 2023
6b9f3df
Tox fixes, reduced to 3.9 only
rospogrigio Feb 7, 2023
904f4fe
Add entities during 'Edit a device'
jlikeme Mar 16, 2023
7cb065b
revert the default region
jlikeme Mar 16, 2023
1691c5f
Fix depreciated async_get_registry
May 20, 2023
55338e2
Merge pull request #1 from oven-lab/oven-lab-Fix-depreciated-async_ge…
May 20, 2023
d241f03
Add HACS validation
May 20, 2023
e79520e
Remove extra key
May 20, 2023
861dcc5
Update manifest.json
May 20, 2023
de88ee5
Remove extra key
May 20, 2023
651dc8b
Update hacs.json
May 20, 2023
a47cdc4
Add Hassfest validation
May 20, 2023
2dbff47
Alphabetize manifest.json
May 20, 2023
7329aef
Delete combined.yaml
May 20, 2023
f2134b8
Update tox.yaml
May 20, 2023
8af1836
Update tox.ini
May 20, 2023
a987d35
Merge pull request #1400 from oven-lab/master
rospogrigio May 24, 2023
9df62b7
Merge branch 'master' into feat-add-entities
rospogrigio May 24, 2023
9d92cad
Reduced logging level for 'Command %d timed out waiting for sequence …
rospogrigio May 24, 2023
928f8e9
Merge branch 'master' into feat-add-entities
rospogrigio May 24, 2023
5f91417
Fixed tox errors
rospogrigio May 24, 2023
53e1ad8
Updated manifest.json
rospogrigio May 24, 2023
9d5984e
Fix for socket.send() exceptions in the logs
rospogrigio Jun 7, 2023
ba5670f
Fixing pylint error
rospogrigio Jun 7, 2023
253039a
fix bug when climate entity is using default min/max temp and temp un…
ncd7 Aug 18, 2023
28b9e46
Allow calling localtuya.set_dp service by non-admin users
ov1d1u Nov 20, 2022
05bf3bd
Fixed initialization with API but no internet.
Nealium Jul 26, 2023
29965bf
Handle 3.4 protocol, fix CI (#1251)
dulyts Sep 12, 2023
1ba8361
Allow port reuse so that other integrations can read the same port (#…
CodeFoodPixels Sep 12, 2023
dfb45bf
Fixing tox issues
rospogrigio Sep 15, 2023
e77f73b
Replaced SUPPORT_* with enums, set minimum HA version in HACS configu…
elad-bar Jan 5, 2024
08e8f3b
Add support for more ac/fan modes (#1389)
simontegelid Apr 15, 2024
565c971
added dict get() instead of assuming keys exist; now handles config_f…
rsnodgrass Oct 10, 2022
03fecd0
feat: add climate entity support for Comfortbilt stoves
noahajac Nov 19, 2022
c43aaa2
refactor: change information for fork
noahajac Nov 25, 2022
7843544
feat: add support for alarm
noahajac Dec 2, 2022
802bcbc
Merge branch 'master' into rospogrigio-master
noahajac May 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 13 additions & 17 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ assignees: ''
Provide details about your environment.
-->
- Localtuya version: <!-- plugin version from HACS, master, commit id -->
- Last working localtuya version (if known and relevant):
- Home Assistant Core version: <!-- Configuration => Info -->
- [] Are you using the Home Assistant Tuya Cloud component ? <!-- if yes, put a x between the two [] => [x] -->
- [] Are you using the Tuya App in parallel ? <!-- if yes, put a x between the two [] => [x] -->
- [] Does the device work using the Home Assistant Tuya Cloud component ? <!-- if yes, put a x between the two [] => [x] -->
- [] Does the device work using the Tinytuya (https://github.com/jasonacox/tinytuya) command line tool ? <!-- if yes, put a x between the two [] => [x] -->
- [] Was the device working with earlier versions of localtuya ? Which one? <!-- if yes, put a x between the two [] => [x] -->
- [] Are you using the Tuya/SmartLife App in parallel ? <!-- if yes, put a x between the two [] => [x] -->

## Steps to reproduce
<!--
Expand All @@ -37,32 +38,27 @@ assignees: ''
2.
3.

## Configuration `configuration.yaml` or `config_flow`
<!--
Fill this with the yaml or config_flow configuration of the failing device. Even if it seems unimportant to you.
Remove personal information and local key.
-->
```yaml

```

## DP dump
<!--
Paste here a DP dump, see https://github.com/rospogrigio/localtuya/wiki/HOWTO-get-a-DPs-dump
You can also try to qualify your device using the procedure described https://github.com/rospogrigio/localtuya/wiki/Qualifying-a-device
-->

## Provide Home Assistant taceback/logs
## Provide Home Assistant traceback/logs
<!--
Provide traces if they are relevant. If the problem is reproducible, try to set the log level to debug for this component at least:
In Dev Tools => Services:
Provide logs if they are relevant. In detail, it is useful to be able to compare working with non-working situations, such as HA logs compared to the output of the tuyadebug script or the tinytuya CLI tool.
To increase the debugging level of HA for the devices, check the "enable debug" button when configuring the device, and set the log level to debug for this component at least:
In configuration.yaml:

logger.set_level
custom_components.localtuya: debug

custom_components.localtuya.pytuya: debug
-->
```txt

```
put your log output between these markers
```


## Additional information
<!-- Put here any information that you think it may be relevant -->
26 changes: 0 additions & 26 deletions .github/workflows/combined.yaml

This file was deleted.

7 changes: 4 additions & 3 deletions .github/workflows/tox.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Tox PR CI

on: [pull_request]
on:
pull_request:
workflow_dispatch:

jobs:
build:
Expand All @@ -14,8 +16,7 @@ jobs:
platform:
- ubuntu-latest
python-version:
- 3.7
- 3.8
- 3.9
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: HACS Validate

on:
push:
pull_request:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
validate-hacs:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v3"
- name: HACS validation
uses: "hacs/action@main"
with:
category: "integration"
- name: Hassfest validation
uses: home-assistant/actions/hassfest@master
35 changes: 32 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The following Tuya device types are currently supported:

Energy monitoring (voltage, current, watts, etc.) is supported for compatible devices.

> **Currently, only Tuya protocols 3.1, 3.3, and 3.4.**
> **Currently, Tuya protocols from 3.1 to 3.4 are supported.**

This repository's development began as code from [@NameLessJedi](https://github.com/NameLessJedi), [@mileperhour](https://github.com/mileperhour) and [@TradeFace](https://github.com/TradeFace). Their code was then deeply refactored to provide proper integration with Home Assistant environment, adding config flow and other features. Refer to the "Thanks to" section below.

Expand Down Expand Up @@ -161,6 +161,32 @@ You can obtain Energy monitoring (voltage, current) in two different ways:
unit_of_measurement: 'W'
```

# Climates

There are a multitude of Tuya based climates out there, both heaters,
thermostats and ACs. The all seems to be integrated in different ways and it's
hard to find a common DP mapping. Below are a table of DP to product mapping
which are currently seen working. Use it as a guide for your own mapping and
please contribute to the list if you have the possibility.

| DP | Moes BHT 002 | Qlima WMS S + SC52 (AB;AF) | Avatto |
|-----|---------------------------------------------------------|---------------------------------------------------------|--------------------------------------------|
| 1 | ID: On/Off<br>{true, false} | ID: On/Off<br>{true, false} | ID: On/Off<br>{true, false} |
| 2 | Target temperature<br>Integer, scaling: 0.5 | Target temperature<br>Integer, scaling 1 | Target temperature<br>Integer, scaling 1 |
| 3 | Current temperature<br>Integer, scaling: 0.5 | Current temperature<br>Integer, scaling: 1 | Current temperature<br>Integer, scaling: 1 |
| 4 | Mode<br>{0, 1} | Mode<br>{"hot", "wind", "wet", "cold", "auto"} | ? |
| 5 | Eco mode<br>? | Fan mode<br>{"strong", "high", "middle", "low", "auto"} | ? |
| 15 | Not supported | Supported, unknown<br>{true, false} | ? |
| 19 | Not supported | Temperature unit<br>{"c", "f"} | ? |
| 23 | Not supported | Supported, unknown<br>Integer, eg. 68 | ? |
| 24 | Not supported | Supported, unknown<br>Integer, eg. 64 | ? |
| 101 | Not supported | Outdoor temperature<br>Integer. Scaling: 1 | ? |
| 102 | Temperature of external sensor<br>Integer, scaling: 0.5 | Supported, unknown<br>Integer, eg. 34 | ? |
| 104 | Supported, unknown<br>{true, false(?)} | Not supported | ? |

[Moes BHT 002](https://community.home-assistant.io/t/moes-bht-002-thermostat-local-control-tuya-based/151953/47)
[Avatto thermostat](https://pl.aliexpress.com/item/1005001605377377.html?gatewayAdapt=glo2pol)

# Debugging

Whenever you write a bug report, it helps tremendously if you include debug logs directly (otherwise we will just ask for them and it will take longer). So please enable debug logs like this and include them in your issue:
Expand All @@ -170,8 +196,11 @@ logger:
default: warning
logs:
custom_components.localtuya: debug
custom_components.localtuya.pytuya: debug
```

Then, edit the device that is showing problems and check the "Enable debugging for this device" button.

# Notes:

* Do not declare anything as "tuya", such as by initiating a "switch.tuya". Using "tuya" launches Home Assistant's built-in, cloud-based Tuya integration in lieu of localtuya.
Expand All @@ -183,8 +212,6 @@ logger:

* Everything listed in https://github.com/rospogrigio/localtuya-homeassistant/issues/15

* Support devices that use Tuya protocol v.3.4

# Thanks to:

NameLessJedi https://github.com/NameLessJedi/localtuya-homeassistant and mileperhour https://github.com/mileperhour/localtuya-homeassistant being the major sources of inspiration, and whose code for switches is substantially unchanged.
Expand All @@ -193,6 +220,8 @@ TradeFace, for being the only one to provide the correct code for communication

sean6541, for the working (standard) Python Handler for Tuya devices.

jasonacox, for the TinyTuya project from where I could import the code to communicate with devices using protocol 3.4.

postlund, for the ideas, for coding 95% of the refactoring and boosting the quality of this repo to levels hard to imagine (by me, at least) and teaching me A LOT of how things work in Home Assistant.

<a href="https://www.buymeacoffee.com/rospogrigio" target="_blank"><img src="https://bmc-cdn.nyc3.digitaloceanspaces.com/BMC-button-images/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" ></a>
Expand Down
22 changes: 12 additions & 10 deletions custom_components/localtuya/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,16 @@ def _device_discovered(device):
)
new_data[ATTR_UPDATED_AT] = str(int(time.time() * 1000))
hass.config_entries.async_update_entry(entry, data=new_data)
device = hass.data[DOMAIN][TUYA_DEVICES][device_id]
if not device.connected:
device.async_connect()

elif device_id in hass.data[DOMAIN][TUYA_DEVICES]:
# _LOGGER.debug("Device %s found with IP %s", device_id, device_ip)
_LOGGER.debug("Device %s found with IP %s", device_id, device_ip)

device = hass.data[DOMAIN][TUYA_DEVICES].get(device_id)
if not device:
_LOGGER.warning(f"Could not find device for device_id {device_id}")
elif not device.connected:
device.async_connect()

device = hass.data[DOMAIN][TUYA_DEVICES][device_id]
if not device.connected:
device.async_connect()

def _shutdown(event):
"""Clean up resources when shutting down."""
Expand All @@ -167,7 +168,7 @@ async def _async_reconnect(now):
_handle_reload,
)

hass.helpers.service.async_register_admin_service(
hass.services.async_register(
DOMAIN, SERVICE_SET_DP, _handle_set_dp, schema=SERVICE_SET_DP_SCHEMA
)

Expand Down Expand Up @@ -255,8 +256,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
res = await tuya_api.async_get_access_token()
if res != "ok":
_LOGGER.error("Cloud API connection failed: %s", res)
_LOGGER.info("Cloud API connection succeeded.")
res = await tuya_api.async_get_devices_list()
else:
_LOGGER.info("Cloud API connection succeeded.")
res = await tuya_api.async_get_devices_list()
hass.data[DOMAIN][DATA_CLOUD] = tuya_api

async def setup_entities(device_ids):
Expand Down
Loading
Loading