ollo69 / ha_tuya_custom Goto Github PK
View Code? Open in Web Editor NEWTuya Custom Component for testing
License: Apache License 2.0
Tuya Custom Component for testing
License: Apache License 2.0
Hi!
I have seen that it is not possible to keep the color set of the Tuya bulbs on Home Assistant and to change the color saturation (it is possible to do it only on the white temperature). In addition, the RGB color value shown in the card always remains at 255 255 255 whatever the color set (see photo).
I found an old post on github where the problem was solved.
I tried to replace the code, but the bulbs were no longer recognized.
I try to attach the code, with reference to the post, maybe together we can find the way.
home-assistant/core#28602 (comment)
Change
from. import DATA_TUYA, TuyaDevice
to
from. import DATA_TUYA, TuyaDevice, DOMAIN
Change the hs_color property to this:
@Property
def hs_color (self):
"" "Return the hs_color of the light." ""
if "entity_data" in self.hass.data [DOMAIN] and self.tuya.object_id () in self.hass.data [DOMAIN] ["entity_data"]:
return self.hass.data [DOMAIN] ["entity_data"] [self.tuya.object_id ()] ["color"]
else:
return tuple (map (int, self.tuya.hs_color ()))
and in the turn_on method change this:
if ATTR_HS_COLOR in kwargs:
self.tuya.set_color (kwargs [ATTR_HS_COLOR])
to this:
if ATTR_HS_COLOR in kwargs:
self.tuya.set_color (kwargs [ATTR_HS_COLOR])
if not "entity_data" in self.hass.data [DOMAIN]:
self.hass.data [DOMAIN] = {"entity_data": {}}
self.hass.data [DOMAIN] ["entity_data"] [self.tuya.object_id ()] = {"color": kwargs [ATTR_HS_COLOR]}
This keeps track of the current color in hass.data. This will obviously only work if you only control the lights through Home Assistant.
Forgive me as I'm clearly doing something wrong.
I installed this to get my colourwheel on my RGB spotlights.
Firstly i uninstalled the standard tuya integration.
Then I installed ha_tuya_custom
This is my config
tuya_custom:
username: <my@email>
password: !secret tuya_pw
devices_config:
- device_name: US Spotlight - Murdo # this is mandatory with at least one of the other keys
support_color: true # true or false, force color support for device
US Spotlight - Murdo <is the friendly name of an RGB spotlight which previously worked (without RGB)
I cannot get any of the previous devices to show with or without the device name. Nothing shows up anywhere in HA.
I have no errors in logs.
What did I do wrong please?
Hi,
Thanks again for your great work.
I have couple of Tuya temperature and humidity sensors, that are detected by either the Tuya integration, or yours, as a switch and not as a sensor.
I created a free account on iot.tuya.com and there all my sensors are shown as "Temperature and Humidity Sensor", though in the details info page there are no Standard Function Set parameters shown.
I saw that most of you seems to be reusing the abandoned tuyaha v0.1.3 package, is there any chance to have these sensors detected correctly in HA and have the temp and humidity readings?
Thanks & cheers
First, let me say that your Custom Tuya integration works great with my SmartLife thermostat (InkBird C929). Just having a problem factoring the current temperature value.
I determined that I need to divide the displayed value by 3.47 to match the true temp. However, despite the comment stating that "any positive number" can be entered, it appears that it only actually accepts an integer (in my case, either 3 or 4).
Here is my configuration.yaml entry:
tuya_custom:
devices_config:
- device_name: "C929 Thermostat" # this is mandatory with at least one of the other keys
unit_of_measurement: "F" # "F" or "C", not set to use value provided from cloud
temp_divider: 10 # any positive number, all temperature values will be divided by this value
curr_temp_divider: 3.47 # **any positive number**, only current temperature values will be divided by this value
ext_temp_sensor: sensor.temperature # a sensor that provide ambient temp used when not provided by device
Hey,
Since version HASS 2021.5, Tuya Custom no longer shows in the integration dashboard.
Please add this ability for monitoring the smoke detector in HA
climate attributes 'temperature' and 'current_temperature' seem to always send back the same value, the target temperature for both
( FYI : in the current main tuya integration, current_temperature was always null. I switched to ha_tuya_custom in hopes to find a fix for this but... while there now is a reported value, the reported value is wrong )
Thanks for the excellent work. With your custom component I no longer have latency problems!
I have another request: would it be possible to integrate the change in brightness of the bulbs?
The brightness of 100% of the bulb set via the Smart Life app or Alexa corresponds to 1000 in the Home Assistant.
If I change the brightness from Home Assistant, the cursor stops and switches to TILT.
Also, the color palette is not displayed.
Is it possible to implement these functions?
Thanks in advance
RGB + CW - White = blue =/
what supported feature I need to add in this bulb? Because if I chose in center os collor pallet, white will be blue =(
I have a TCL air conditioner that uses the smart life platform.
The temperature is not working. Currently it is set at 71 degrees and the component in HA is showing 160.
If I change the temp in HA to 142, the temperature on the unit shows 61
If I change the temp in HA to 147, the temperature on the unit shows 64
If I change the temp in HA to 200, the temperature on the unit shows 64
If I change the temp in HA to 210, the temperature on the unit shows 72
If I set the temp on the AC to 88, HA shows 162
Temperatures are in Fahrenheit.
I have cards with tuya scenes:
`
cards:
when I click on card I have error about error activate service scene/turn_off. Service not found. But when I hold press on card and click Activate this service is run. Where I make error?
Hello,
Testing with my climate I have seen that if I manually dial the thermostat a temperature takes more than 5 min to be reflected in the climate.xxxxx
It's normal? with tuya intration the gap is "only" 1 minute
Thanks,
I can't find anywhere to set the specified light options.
There is no such options under Integration->Tuya Custom -> Options .
Neither under each device or entity.
I went from Tuya component to tuya_custom a few days ago and it initially worked great, but since yesterday I can't connect to the account and I got a Get accesstoken failed error. Username or password error. I have verified the username and password and it is correct. I have reinstalled the Tuya component, and it works fine.
I´m using custom component installed using hacs, and is working much better now, no delay when using HA.. The only issue i found is with cover switches, HA is always reporting that covers are oppening, when they aren´t oppening.
Maybe this happen because of the undefined state of the cover switch. When the covers are stopped, the switch should stay in undefined state, that way i can open or close. Right now they keep forcing the open state, that way if i want to open, i need to use the stop command first and only then i can use the open command.
Other thing is that closing state is not showing up, i can close, but the state is not showed in HA.
Hi. I have alarm, that can work with tuya. I see it alarm in tuya application, but I dont see it in Home Assistant. I can send to you any information for support it, If you can add alarm support in tuya integration for HA.
Tested to install a fresh setup on both RaspPi3b+ and Virtual machine running Linux on a Laptop.
Everything is the latest version, including tuya_custom. Get the same problem on both.
Smartlife app is instant and I have a 100Gb fiber with a netgear nighthawk router.
The Lights are working instant! but the switches are randomly delayed up to 30s.
The logfile: "Updating tuya_custom switch took longer than the scheduled update interval 0:00:15"
Any ide on what can cause this and am I the only one with this problem?
Hi,
I'm using MOES Zigbee Radiator Actuator HY368 with Tuya app and it shows up in HA. I've added following to my config:
tuya_custom:
devices_config:
- device_name: Kitchen
unit_of_measurement: "C"
temp_divider: 10
Temperature shows up but when I adjust it it goes red, sometimes goes back briefly to what it was and then thermostat (entity) goes unavailable.
Please let me know how can I help to fix it.
Hello.
I have RGBCW bulbs.
When I control them with HA and I switch from white (cold-warm) mode to RGB mode, brightness changes in wrong way.
HA shows brightness change, but bulb doesn't change brightness, only color.
If I create a new scene and I set bulb to warm white the bulb changes accordingly. But when I use that scene, the bulb is set to color (I think it remembers last setting)
What's wrong?
Hello everyone. I have a garage port sensor, but it does not appear in HA.
Is this an API restriction? Is there not a solution to help me?
Thanking you in advance
My Sensor : WOFEA
Release HA : 0.115.2
Hi. I'm trying to integrate a dimmer with 2 Gang but I can't. I only managed to access one of the two ways. I have switches with 2 Gang in which in home assistant each way is detected as an independent device but in the case of the dimmer only one way is detected. I am attaching the device API information obtained from the Tuya developer page. is that currently supported by the integration? how should it be configured? thank you very much!
In Home Assistant I have
I just got this wake up light. It integrates in the smartlife app and is completely controllable there. Both, the default tuya integration and this custom_tuya integration, create no entity when connecting it to my smartlife account. Does this wake up light not act like a "light" entity? Is there any chance to get it working?
Logger: custom_components.tuya_custom
Source: custom_components/tuya_custom/init.py:431
Integration: Tuya Custom (documentation)
First occurred: 2:46:13 PM (3 occurrences)
Last logged: 2:51:13 PM
Method [QueryDevice] for device ebb47b582f8112591ai6kq fails using poll interval 60.0 - error: you can query once in 120 seconds
I have an ElectriQ dehumidifier configured and working in the Tuya Android app but I can't get it to show in Home Assistant.
I get the same results in both the official integration and the Tuya Custom integration, which is that my login credentials are accepted but no devices ever appear.
Having read about the difficulties with the Tuya API, could the custom integration be engineered to include a "detection" section to capture the required detail from devices configured in the Tuya app so that they can be successfully used in Home Assistant?
Using a Sasswell (Tuya) thermostat
It appears to be showing Celsius as Fahrenheit, and it's also doubled. I've tried some of the known "Fixes" for this error but that does not appear to work out.
Halving current temp is 22.25 Celsius which is the correct temp in the house (72 F)
Looks like the math needs changed here to - (Current temp /2)× 9/5) + 32 as a dirty fix. I'm sure there's a better way to do it though.
I've been trying to debug this problem, but I've hit a roadblock. It looks like there may be a custom API developed for HA on the TUYA servers. If that's the case, then the problem lies in the API server and not HA. I've posted about the issue here in more detail:
Hey having a bit of a issue with using the Device parameters (configuration.yaml) function of this to try to add a temperature readout to my AC
tuya_custom: devices_config: - device_name: Pinguino unit_of_measurement: "C" temp_divider: 1 curr_temp_divider: 1 ext_temp_sensor: sensor.temperature_6
OR
tuya_custom: devices_config: - device_name: climate.pinguino_ac unit_of_measurement: "C" temp_divider: 1 curr_temp_divider: 1 ext_temp_sensor: sensor.temperature_6
either way the settings of this unit show as
`hvac_modes:
I have a Pinguino Portable AC that I have connected to SmarLife it shows up in the Integrations section as a device but there is no entity created for me to control in home assistant.
Previously I was using the normal tuya integration & an entity was created but it was broken was hoping this would correct that problem.
I have several Tuya lights.
When I change the brightness on them (either in HA, or by voice via Google Home) the brightness is lowered automatically after 5 minutes.
Light status at 10:08 AM, just after manually changing them
Light status at 10:13, all brightness levels are lowered, without any manual intervention
There are no automation in place to set the brightness (only for one of them, but it sets the brightness either to 1 or to 255, not to a level in between), so this can not be the cause.
Sometimes the change can be within a minute, sometimes it can be after 5, but it is changed every time.
When I switch on a light, the brightness is set at about 20%, while the light is at 100%.
Is is possible to have the correct value of brightness?
Moreover, I use supported_features: 63, the light is correctly seen as RGB, I can change the colour, but I cannot read the hue and saturation as parameters of the light.
Why?
Hi, I'm using this repo/integration since 2 weeks and I'm really happy with the efforts to fix the current Tuya integration issues. Thanks for that!
From the documentation it's not really clear what I have to enter as device_name
when providing custom device information via configuration.yaml, in my understanding it should be one of these, but I'm not sure which is correct:
light.kitchen
kitchen
KitchenLight
Could you please clarify on this topic and maybe update the documentation?
I am not getting the color options wheel in my tuya lights. This is also a known issue with original integration. If you put the lights into a group that supports color change the color-changing will work (currently that's the only way you can update their color in HA without the tuya app)
There is a fix that's discussed here: home-assistant/core#28602 (comment)
which did work for me if i manually patch the light.py file. Here is the direct link to the file from the post above:
https://gist.github.com/gadgetchnnel/c29503d7f1acbda17c64a70bb985de69
Would be awesome to have this fixed in your integration :)
Hi,
I have found that the Scripts that I use to set the brightness and color on Home Assistant, even if I immediately turn on the bulbs with the chosen intensity and color, but the change of state is displayed on Home Assistant after many seconds of waiting.
Another curiosity, if the brightness and color are set by script, for example by setting to 75, after a few seconds from switching on, the brightness in the bulb control panel is set to 255, while in reality the brightness of the bulb remains unchanged (75).
The code, very simple, is the following:
light_salon_red_on:
alias: Red Salon Lights ON
sequence:
If you do not set the brightness or color in the script, the status change display is shown immediately by Home Assistant.
Is it possible to speed up the status change also leaving the possibility to set brightness and color from Home Assistant?
When I turn the bulb white using HA it uses only the RGB LED's and is a very dim bluish white even at 100% brightness. If I turn it white using the Tuya app it uses the white LED's and is much brighter.
Once I turn it white using the Tuya app it will use the white LED until I change colors with HA, then it will revert to using the RGB LED's to make white again whenever I try controlling with HA. I have to go back into the Tuya app to get it back to the white LED.
This issue occurs both when using the color wheel picker in HA and using Alexa via Nabu Casa to try to change light colors. When I say Alexa, turn the light white it will use the RGB white.
The bulbs I'm using are these Merkury bulbs https://www.amazon.com/dp/B0792LR3KS/
If I change the the bulb color via the Tuya app it does not get updated in HA. If I change the bulb in HA, it's almost instantly updated in the Tuya app. Any way to get state changes in HA if HA doesn't change things?
Hi, I have a tuya climate thermostat which only shows the options as Off or AUTO. No Temperature or way to set temperature.
The info must be in the API I guess through as the item is connected to my Home Assistant and if I push that device out through HomeKit to Apple IOS, my phone on HOME app can control the temperature, via the Tuya or Local Tuya or Custom Tuya integration.
The device in developer tools shows
hvac_modes: off, auto
min_temp: 7
max_temp: 35
target_temp_step: 1
current_temperature: null
friendly_name: Underfloor Heating
supported_features: 0
Is there anything to try to have this in Home Assistant with more control or is this simplythe way it is
Cheers
Rich
Home Assistant 2021.6.2
Tuya Custom v0.1.6 (installed via HACS)
I'm not able to access to configuration page:
2021-06-05 11:26:46 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
resp = await self._request_handler(request)
File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 119, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 76, in forwarded_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 24, in request_context_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 144, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 135, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 190, in post
return await super().post(request)
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 63, in wrapper
result = await method(view, request, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 72, in post
result = await self._flow_mgr.async_init(
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 153, in async_init
flow, result = await task
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 179, in _async_init
result = await self._async_handle_step(flow, flow.init_step, data, init_done)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 260, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
File "/config/custom_components/tuya_custom/config_flow.py", line 271, in async_step_init
if self.config_entry.state != config_entries.ENTRY_STATE_LOADED:
AttributeError: module 'homeassistant.config_entries' has no attribute 'ENTRY_STATE_LOADED'
If the integration cannot determine the hvac_modes of a climate device from the API, it defaults to: off, heat_cool
if modes is None:
if HVAC_MODE_HEAT_COOL not in self.operations:
self.operations.append(HVAC_MODE_HEAT_COOL)
return
For my device, a heater, that's actually wrong and it should be HVAC_MODE_HEAT. It would therefore be good if the default value could be set via the config rather than hard-coded to HVAC_MODE_HEAT_COOL.
Tuya original and Tuya custom integration behave the same.
After reload of the hassio server temperature is shown on climate entity.
Besides wrong temperature showing which can be adjusted also setting of temperature does not work
Switch on and switch off of the thermostat works normally.
If I want to set the temperature to different value then immediately thermostat becomes unavailable in hassio lovelace.
Thank you in advance for possible suggestions.
Regards
Robert
1st of all, congrats for your excellent work, with your Tuya custom component I finally managed to have my Tuya thermostat appearing almost correctly in HA.
I managed to set all parameters, so all temperature values are shown correctly (in °C in my case) and desired temperature can be set in halves of °C and I can see the changes in the Tuya app also (or the other way around), not instantly, but it's OK, though there are few minor issues:
I understand that the code is more general and it includes HVAC devices, but it's not clear to me from the code if you are reading the device mode somehow, or you simply assume it could be something like "ON/OFF/AUTO/Heat/Cool/Ventilation".
Cheers
Hi,
Is there a way to add the Music option and the Group option?
I mean to set the whole group a music function and color function.
Thanks.
Hi. I was a bit confused when setting up the config for this component that the "friendly name" is used to identify devices instead of the entity id. I would assume that the entity is more stable and more standardised so I was wondering why the name is used instead. Probably there are good reasons for this design choice, in this case please just close the issue.
Thanks for this custom component. Nice to see that some of the flaws in the tuya integration are getting fixed here.
I have some problem getting status from my switches in HA 0.113.0. I can turn on/off from HA without problem, but when I turn on/off manually from switch, I have a 30-90 seconds delay in get the status...
This is what I get from HA logs:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 272, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 465, in async_device_update
await self.hass.async_add_executor_job(
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/tuya_custom/__init__.py", line 264, in update
self._tuya.update()
File "/config/custom_components/tuya_custom/tuyaha/devices/switch.py", line 16, in update
return self._update(use_discovery=True)
File "/config/custom_components/tuya_custom/tuyaha/devices/base.py", line 36, in _update
devices = self.api.discovery()
File "/config/custom_components/tuya_custom/tuyaha/tuyaapi.py", line 150, in discovery
response = self._request("Discovery", "discovery")
File "/config/custom_components/tuya_custom/tuyaha/tuyaapi.py", line 212, in _request
response = self.requestSession.post(
File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 578, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
hi
you have some wrong with this link because it comes up with https://github.com/ollo69/ha_tuya_custom its says Invalid Add-on repository!
I don.t know why that is
thanks Oliver
Hello,
I cannot add repository https://github.com/ollo69/ha_tuya_custom
, getting error "Invalid Add-on repository!"
Is the address correct?
What would it mean to also integrate tuya smartlock to this integration?
Why this is not done so far?
I switched from the official Tuya integration to this custom integration to fix the various well known issues seen in the logs. That fixed the log errors but introduced a new problem - climate devices now cannot be switched off.
There are two ways to turn off a climate device, either set "hvac_mode" to "off" via service climate.set_hvac_mode or use service "climate.turn_off". Both of those fail. What actually happens is the device turns off and then back on.
I have tracked it down to a missing ELSE in the file "climate.py". See below.
def set_hvac_mode(self, hvac_mode):
"""Set new target operation mode."""
if hvac_mode == HVAC_MODE_OFF:
self._tuya.turn_off()
if not self._tuya.state():
self._tuya.turn_on()
if self._has_operation:
self._tuya.set_operation_mode(HA_STATE_TO_TUYA.get(hvac_mode))
Notice how it turns if off and then back on! The fix is as follows:
def set_hvac_mode(self, hvac_mode):
"""Set new target operation mode."""
if hvac_mode == HVAC_MODE_OFF:
self._tuya.turn_off()
elif not self._tuya.state():
self._tuya.turn_on()
if self._has_operation:
self._tuya.set_operation_mode(HA_STATE_TO_TUYA.get(hvac_mode))
The above fix means it now can be turned off using either service climate.set_hvac_mode or climate.turn_off.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.