NorthernMan54 / homebridge-tasmota

Plugin for Tasmota devices leveraging Home Assistant auto discovery
Apache License 2.0
35 stars 9 forks source link

Heap out of memory while first device discovering #47

Closed mkarras closed 11 months ago

mkarras commented 11 months ago

Describe Your Problem:

While discovering the first device (in sum there are 4 plugs) the server crashes with heap out of memory. I also noticed that there are really long logs (when debug mode active) regarding the history of the device (first log below). The second log below shows the discovery of first and only device. It was working before so my assumption is that some in memory loading history data are causing the issue. Do I need to clean up the history somewhere e.g. by restarting the devices that send it? Or do I need to disable the feature "enable support for sensor data history logging" completely or something else in the Tasmota settings or mqtt? Also there are some warnings like "Warning: Unhandled Tasmota sensor type energy". Anything wrong with that? I am grateful for every help and tip!

Logs:

...
{"power":0,"time":1694595985},{"power":0,"time":1694596585},{"power":0,"time":1694597690},{"power":0,"time":1694598290},{"power":0,"time":1694599128},{"power":0,"time":1694599728},{"power":0,"time":1694600328},{"power":0,"time":1694600928},{"power":0,"time":1694601528},{"power":0,"time":1694602128},{"power":0,"time":1694602728}]}
[07/10/2023, 05:44:42] [Tasmota] History Loaded from Persistant Storage
07/10/2023, 05:49:21] [Tasmota] Found existing accessory: Weihnachtsbaum ENERGY TotalStartTime
[07/10/2023, 05:49:21] [Tasmota] Creating service: Weihnachtsbaum ENERGY TotalStartTime sensor
[07/10/2023, 05:49:21] [Tasmota] Warning: missing dev_cla Weihnachtsbaum ENERGY TotalStartTime
[07/10/2023, 05:49:22] [Tasmota] Found existing accessory: Weihnachtsbaum ENERGY Total
[07/10/2023, 05:49:22] [Tasmota] Creating service: Weihnachtsbaum ENERGY Total sensor
[07/10/2023, 05:49:22] [Tasmota] Warning: Unhandled Tasmota sensor type energy
[07/10/2023, 05:49:22] [Tasmota] Found existing accessory: Weihnachtsbaum ENERGY Yesterday
[07/10/2023, 05:49:22] [Tasmota] Creating service: Weihnachtsbaum ENERGY Yesterday sensor
[07/10/2023, 05:49:22] [Tasmota] Warning: Unhandled Tasmota sensor type energy
[07/10/2023, 05:49:23] [Tasmota] Found existing accessory: Weihnachtsbaum ENERGY Today
[07/10/2023, 05:49:23] [Tasmota] Creating service: Weihnachtsbaum ENERGY Today sensor
[07/10/2023, 05:49:23] [Tasmota] Warning: Unhandled Tasmota sensor type energy
[07/10/2023, 05:49:23] [Tasmota] Found existing accessory: Weihnachtsbaum ENERGY Power
[07/10/2023, 05:49:23] [Tasmota] Creating service: Weihnachtsbaum ENERGY Power sensor
[07/10/2023, 05:49:23] [Tasmota] ** Fakegato-storage AddWriter : Weihnachtsbaum ENERGY Power
[07/10/2023, 05:49:23] [Tasmota] Loading...
[07/10/2023, 05:49:23] [Tasmota] ** Fakegato-storage read FS file: /var/lib/homebridge/raspberrypi_14308B_ENERGY_Power_persist.json
[07/10/2023, 05:49:23] [Tasmota] ** Fakegato-timer Subscription : Weihnachtsbaum ENERGY Power
[07/10/2023, 05:49:23] [Tasmota] Registring Events Weihnachtsbaum ENERGY Power
[07/10/2023, 05:49:23] [Tasmota] Platform Weihnachtsbaum ENERGY Power
[07/10/2023, 05:49:23] [Tasmota] Creating fakegato service for tele/plug1/SENSOR Weihnachtsbaum ENERGY Power 14308B_ENERGY_Power
[07/10/2023, 05:49:23] [Tasmota] Creating statusUpdate listener for tele/plug1/SENSOR Weihnachtsbaum ENERGY Power
[07/10/2023, 05:49:24] [Tasmota] Found existing accessory: Weihnachtsbaum ENERGY ApparentPower
[07/10/2023, 05:49:24] [Tasmota] Creating service: Weihnachtsbaum ENERGY ApparentPower sensor
[07/10/2023, 05:49:24] [Tasmota] Warning: Unhandled Tasmota power sensor type _energy_apparentpower
[07/10/2023, 05:49:24] [Tasmota] Found existing accessory: Weihnachtsbaum ENERGY ReactivePower
[07/10/2023, 05:49:24] [Tasmota] Creating service: Weihnachtsbaum ENERGY ReactivePower sensor
[07/10/2023, 05:49:24] [Tasmota] Warning: Unhandled Tasmota power sensor type _energy_reactivepower
[07/10/2023, 05:49:24] [Tasmota] Found existing accessory: Weihnachtsbaum ENERGY Factor
[07/10/2023, 05:49:24] [Tasmota] Creating service: Weihnachtsbaum ENERGY Factor sensor
[07/10/2023, 05:49:24] [Tasmota] Warning: Unhandled Tasmota sensor type power_factor
[07/10/2023, 05:49:25] [Tasmota] Found existing accessory: Weihnachtsbaum ENERGY Voltage
[07/10/2023, 05:49:25] [Tasmota] Creating service: Weihnachtsbaum ENERGY Voltage sensor
[07/10/2023, 05:49:25] [Tasmota] Warning: Unhandled Tasmota sensor type voltage
[07/10/2023, 05:49:25] [Tasmota] Found existing accessory: Weihnachtsbaum ENERGY Current
[07/10/2023, 05:49:25] [Tasmota] Creating service: Weihnachtsbaum ENERGY Current sensor
[07/10/2023, 05:49:25] [Tasmota] Warning: Unhandled Tasmota sensor type current

<--- Last few GCs --->

[13007:0x3eb4218]    31290 ms: Scavenge 120.6 (127.9) -> 120.2 (127.9) MB, 2.4 / 0.0 ms  (average mu = 0.240, current mu = 0.228) allocation failure 
[13007:0x3eb4218]    31307 ms: Scavenge 120.6 (127.9) -> 120.6 (128.2) MB, 6.5 / 0.0 ms  (average mu = 0.240, current mu = 0.228) allocation failure 
[13007:0x3eb4218]    31316 ms: Scavenge 120.7 (128.2) -> 120.7 (128.2) MB, 3.2 / 0.0 ms  (average mu = 0.240, current mu = 0.228) allocation failure 

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
[07/10/2023, 05:49:25] [HB Supervisor] Homebridge Process Ended. Code: null, Signal: SIGABRT
[07/10/2023, 05:49:30] [HB Supervisor] Restarting Homebridge...

Tasmota Device Config:

Device type: NOUS A1T

Environment:

NorthernMan54 commented 11 months ago

I think the history service could be a memory hog, as it stores the data in memory, so disabling the feature might reduce the RAM footprint.

The warnings Warning: Unhandled Tasmota sensor type energy are indicating that a discovered sensor is not supported by the plugin. And can be ignored.

Are you using child bridges ? It also may reduce the memory footprint, as each plugin would run in its own process.

mkarras commented 11 months ago

Thank you for the quick response. 🙂 I set the max memory usage to 256MB and this helped already. Now I also use your recommendation with a child bridge. Actually now it uses more memory in total, but with that the main bridge is not more effected when something crashes with the plugin. When the memory it allows I will use even more child bridges making everything more stable and responsive.

Thank you for your help and tips. 👍🏼

NorthernMan54 commented 11 months ago

Your welcome