Description
System Health details
System Information
version | core-2025.1.4 |
---|---|
installation_type | Home Assistant OS |
dev | false |
hassio | true |
docker | true |
user | root |
virtualenv | false |
python_version | 3.13.1 |
os_name | Linux |
os_version | 6.6.73-haos |
arch | x86_64 |
timezone | Europe/Amsterdam |
config_dir | /config |
Home Assistant Community Store
GitHub API | ok |
---|---|
GitHub Content | ok |
GitHub Web | ok |
HACS Data | ok |
GitHub API Calls Remaining | 5000 |
Installed Version | 2.0.5 |
Stage | running |
Available Repositories | 1506 |
Downloaded Repositories | 13 |
Home Assistant Cloud
logged_in | false |
---|---|
can_reach_cert_server | ok |
can_reach_cloud_auth | ok |
can_reach_cloud | ok |
Home Assistant Supervisor
host_os | Home Assistant OS 14.2 |
---|---|
update_channel | stable |
supervisor_version | supervisor-2024.12.3 |
agent_version | 1.6.0 |
docker_version | 27.2.0 |
disk_total | 30.8 GB |
disk_used | 5.9 GB |
healthy | true |
supported | true |
host_connectivity | true |
supervisor_connectivity | true |
ntp_synchronized | true |
virtualization | kvm |
board | ova |
supervisor_api | ok |
version_api | ok |
installed_addons | Samba share (12.4.0), Terminal & SSH (9.16.0), Matter Server (7.0.0), Get HACS (1.3.1), Home Assistant Google Drive Backup (0.112.1), Mosquitto broker (6.5.0), SQLite Web (4.3.0) |
Dashboards
dashboards | 11 |
---|---|
resources | 1 |
views | 2 |
mode | storage |
Recorder
oldest_recorder_run | 19 januari 2025 om 23:57 |
---|---|
current_recorder_run | 30 januari 2025 om 10:53 |
estimated_db_size | 326.94 MiB |
database_engine | sqlite |
database_version | 3.47.1 |
Checklist
- I have read the FAQ to see if there is a known solution to my problem.I have enabled debug logging for my installation.I have filled out the issue template to the best of my ability.This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).This issue is not a duplicate issue of currently previous issues..
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:
- Any idea what is might be and if I can solve it (for example by delaying the Powercalc startup a little)?
- Can this reload maybe also be done for all lights at once somehow? Possibly even through an automation, then I can set one up to run every hour or so, ensuring all entities will become available eventually even if not direct at startup.
Reproduction steps
Debug logs
.
Diagnostics dump or YAML config
No response
Activity
bramstroker commentedon Jan 30, 2025
Yes this might be very well due to loading order.
Where sometimes Powercalc starts earlier than Tuya and sometimes the other way around.
I had another proposed fix in the past, which never ended up in a release yet, but might be a fix for your case.
Could you please try applying this patch to your
config/custom_components/powercalc/sensors/power.py
file?https://github.com/bramstroker/homeassistant-powercalc/pull/2926/files
Restart, and see if everything works and keeps working after multiple restarts.
Dream1975 commentedon Jan 30, 2025
I did the change and first did a restart of HASS, everything kept working.
Secondly, I did a complete reboot of the VM/HASS OS and the Tuya's were again without entity.
I reloaded only 2 lights by hand and then did a reload configuration which still didn't give entities (although the 2 started by hand kept on working), but...
after this, I did a restart of HASS (without restarting the VM) and then everything came back up again. Although I'm not sure if the change helped in that matter, as I've seen this before also.
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)?
bramstroker commentedon Jan 30, 2025
Reading your initial bug report again you don't have any entities at all added to HA, which is kinda strange.
My first suggestion for the patch, was only a potential fix for sensors keeping unavailable state after startup. But that does not apply to your problem.
Could you enabled debug logs and share logs after startup?
You could try placing
await asyncio.sleep(30)
on this line: https://github.com/bramstroker/homeassistant-powercalc/blob/master/custom_components/powercalc/sensor.py#L303.But that won't be something I will add in the integration code itself. There must be another solution, adding sleeps is never a correct solution.
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.
Would be nice to have a log when the entities are created, and one when the entities are not created.
That would allow us to compare.
Dream1975 commentedon Jan 30, 2025
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
bramstroker commentedon Jan 31, 2025
Very strange, as I also see these entries in not working log:
Which indicate the sensor should be created.
Seems something goes wrong between this and the actual creation of the entity in HA.
Could you try adding following to this line: https://github.com/bramstroker/homeassistant-powercalc/blob/master/custom_components/powercalc/sensor.py#L366?
Dream1975 commentedon Jan 31, 2025
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 **
bramstroker commentedon Jan 31, 2025
@Dream1975 Sorry, you should not put the log inside the
if
.But just above
async_add_entities
line. With same indenting as that.Dream1975 commentedon Jan 31, 2025
Changed it and made a new log of a start with no Tuya entities
** Edit: remove logs **
bramstroker commentedon Feb 1, 2025
@Dream1975 I see following in the logs:
Focussing on
sensor.fl06_fittinglamp_gang_bg1_power
atm, because that's the same as I checked in last log.Also the new
Adding entities
is being logged now, which means powercalc completed preparing the entities to be added and registered to HA, and delegates the entity creation to HA.After this
sensor.fl06_fittinglamp_gang_bg1_power
should be created, but it's not in your case, right?Seems something goes wrong in HA core, but I have no clue. Will ask some HA core dev if he has any idea what can be the cause.
Dream1975 commentedon Feb 1, 2025
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.
Dream1975 commentedon Feb 3, 2025
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).
bramstroker commentedon Feb 3, 2025
Very interesting find.
Maybe Tuya integration has some logic to remove all entities from a device.
Powercalc adds entities to the same device as Tuya. This device is managed by Tuya.
Could you test creating a HA helper, for example
Integral
? Pretty sure these are also added to same device as the source entity.When this is the case please try reloading Tuya again and see if those disappear as well.
Dream1975 commentedon Feb 3, 2025
Something interesting happens there also. When making the helper and connecting it to a Tuya sensor leads to the entities for all devices being gone also.
But I have other helpers also connected to Tuya devices (fe an energy integral vor the power on smart plugs) and these never had any issue. What I see in the Tuya integration if I compare:
The helper made in HASS itself is linked to the device

And if I look at a powercalc device (with, off course, making sure the entity is running) that sensor is not visible under the device
bramstroker commentedon Feb 3, 2025
What do you mean with this exactly
the entities for all devices being gone
?Do you mean the helper entity is also removed from the system, and not working anymore?
16 remaining items