Tuya plugs no longer deliver power data for integration to kWh / metering - and the Pi-Hole mystery

I had setup a fleet of 10 Tuya Power sockets with the tuya local integration.

And they worked - but when I had finally implemented the last steps of

  • energy consumption via Riemann Integration and
  • metering (counter for hourly, daily, weekly, monthly energy consumption, that reset itself)
  • sample size (20 for tuy)
  • plus the stats (average consumption, median)

I observed just after midnight while waiting for the reset of the counter, that on no device the watt did change anymore - straight horizontal lines, no up and down anymore.

Something was wrong. Cause watt might stayed close to constant but still had its peaks and up and downs before, regardgless which device … even echo show during video play has a changing power / watt demand.

But the power graphs showed straight horizontal line regardless what I turned off like Echo Show. I even turned off the laptop and all other devices: still horizontal lines and a frozen power gauge.

And when I hovered along the line with the mouse I did not find measure points or data while hovering a long the line.

Then I did a restart of Home Assistant - without any change,
I did a restart of the Pi itself. No progress.
I did a reboot of the router - no change at all.

Due to midnight I went to bed and hoped for the better on the next morning, a bit of self healing. Did not happen. Even more worse: internet did not work either the next morning.

That was the point when I knew it was not cause by the plugs nor the HomeAssistant installation. All the issues must have been caused by 1 error in the Pi-hole installation or better even more. The Pi-hole itself had not mention any issues , warnings or things to check, looked quite normal except that ftl did not work anymore.

Therefore check your pi-hole log with

sudo nano /var/log/pihole-FTL.log

and then you will find things like database corruption, malformed, database is locked

[2021-06-11 17:53:00.320 755/T759] Encountered step error in get_max_query_ID(): database disk image is malformed
[2021-06-11 17:53:00.320 755/T759] Error while trying to close database: database is locked
[2021-06-11 17:53:00.320 755/T759] SQLite3 message: database corruption at line 67162 of [5d4c65779d] (11)
[2021-06-11 17:53:00.320 755/T759] SQLite3 message: statement aborts at 11: [INSERT INTO queries VALUES (NULL,?,?,?,?,?$
[2021-06-11 17:53:00.320 755/T759] Encountered error while trying to store queries in long-term database: database disk$
[2021-06-11 17:53:00.354 755/T759] WARN: Command "ip address show" failed!
[2021-06-11 17:53:00.354 755/T759]       Message: Success
[2021-06-11 17:53:00.354 755/T759] Error while trying to close database: database is locked
[2021-06-11 17:53:48.481 755/T756] IPv4 telnet error: Too many open files (24)

you can try a pihole database repair

sudo service pihole-FTL stop
sudo pihole -g -r


  • simply delete the database
  • check if your addlists.list has proper content (or edit and paste missing entries)
  • rebuild gravity with
    pihole -g

Since then I had no such issues anymore.
Hope that helps those running the tuya local integration and suffer from similiar issues, bad plug readings and so on.