-
Notifications
You must be signed in to change notification settings - Fork 281
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
Tuya entities sometimes don't start (Hue always does) + suggestion #3032
Comments
Yes this might be very well due to loading order. Could you please try applying this patch to your Restart, and see if everything works and keeps working after multiple restarts. |
I did the change and first did a restart of HASS, everything kept working. It would seem that with a hot reboot everything starts up just a little faster so Powercalc sees the devices, while with a VM/HASS OS restart they just aren't ready in time. But given the above, I'm quite confident this then could be solved by introducing a small delay in starting Powercalc (or do a second reload after a few seconds). Can I put a timeout somewhere in the code maybe to try (and if so how/where)? |
Reading your initial bug report again you don't have any entities at all added to HA, which is kinda strange. Could you enabled debug logs and share logs after startup? You could try placing We just need to figure out what exactly is unavailable during setup which prevents powercalc to create / register the entities correctly. Hopefully the logs will provide insights. |
Lucky strike, the first cold reboot after turning on debugging everything worked, then did a second cold reboot and then it didn't. Enclosed the 2 debug logs (one working one not) for comparison Edit log removed |
Very strange, as I also see these entries in not working log:
Which indicate the sensor should be created. Could you try adding following to this line: https://github.com/bramstroker/homeassistant-powercalc/blob/master/custom_components/powercalc/sensor.py#L366? _LOGGER.debug("Adding entities: %s", [entity.entity_id for entity in entities_to_add]) |
I changed it like this (hope that's what you ment and I did it right)
The log download gave 2 (see enclosed). They are both from the same startup, as I can see in the TS, whereby the Hue entities did but the Tuya didn't come up. ** Edit: remove logs ** |
@Dream1975 Sorry, you should not put the log inside the |
Changed it and made a new log of a start with no Tuya entities ** Edit: remove logs ** |
@Dream1975 I see following in the logs:
Also the new |
Indeed, with a startup that has the problem for your example sensor.fl06_fittinglamp_gang_bg1_power is not there (like FL02 in the screenprint in my first post). WHen I do the 3 dots and reload it is immediately there like FL01 in the screenprint (as is it with some starts). Thank you and I'll wait patiently (it has been like this since I started using Powercalc so am in no hurry. |
I noticed something new today. When all the Powercalc sensors are working, but then I reload the Tuya integration (to update devices) they are gone again. So the startup issue is probably related (that Powercalc doe make the entities but in the startup procedure Tuya is sometimes just before and sometimes just behind it). |
Very interesting find. Could you test creating a HA helper, for example |
What do you mean with this exactly |
With all devices I mean the Tuya devices helpers created by Powercalc (all others are fine, even manual made integrals linked to Tuya devices). "Do you mean the helper entity is also removed from the system, and not working anymore?" |
Fyi I have ordered a 10 bucks tuya plug, so I can setup that integration to see if I can reproduce. Also working on a reload service: #3079 |
Whoah, that's great. Hope you didn't buy it only for this issue and can/will use it anyway. If not, let me know and I'll gladly reimburse you for it. Ps. You might also need a Tuya light with it to test. If so let me know and I can send you one (I have spares, I also live in NL). |
@Dream1975 I bought it particularly for debugging this issue ;-). Have no use for it. But I can return it of course, bought a amazon. |
@bramstroker no discord, but I see a mail address in your profile. So I can send you a mail you can reply on (I have to leave now, but will do that tonight or tomorrow then). Or..... you order one (or more) at https://nl.aliexpress.com/w/wholesale-tuya-light.html?spm=a2g0o.productlist.search.0 so you'll have a/several lights for your own use. I bought them for EUR 3,25 there with free shipping so might be better to reïmburse that as it is even cheaper as shipping costs within NL (unbelievable). Let me know which one you prefer and you'll get a mail from me by tomorrow. |
I have purchased tuya light for 2euro, with free shipping. |
System Health details
System Information
Home Assistant Community Store
Home Assistant Cloud
Home Assistant Supervisor
Dashboards
Recorder
Checklist
Describe the issue
My issue is somewhat like issue 2962 only mine is not since a recent release but has always been so (that's why I made a separate issue).
I have both lights from Tuya and Philips. When HASS starts from scratch (VM in off state and then turned on) half the time all lights have entities and half the time only the HUE ones (which has them always).
It would seem something like Powercalc is checking for the Tuya devices too early and therefore doesn't see them available (thus not making a sensor, as shown in the screen print below). Which could be logical as the Tuya integration also communicates with Tuya cloud in setting up the devices. It could very well be that this process is still happening when Powercalc also checks the devices.
Ps. If I press the 3 dots and select reload, the entity is made immediately (only that has to be done for all lights, which are quite a few).
So my questions:
Reproduction steps
Debug logs
Diagnostics dump or YAML config
No response
The text was updated successfully, but these errors were encountered: