lovelace-valetudo-map-card icon indicating copy to clipboard operation
lovelace-valetudo-map-card copied to clipboard

High CPU usage with live map

Open alceasan opened this issue 4 years ago • 6 comments

Whenever starts a clean from my vacuum, CPU usage on homeassistant container goes up to 100% inmediatly when viewing the card.

I'm not sure if it's the same problem as this issue on another live map for vacuum project: Live map camera loads CPU #66, it seems that the browser tries to get an updated image every 10-15 milliseconds.

alceasan avatar Jun 24 '20 13:06 alceasan

The CPU usage of the container itself? That doesn't sound like it could be related to the card at all, as it's purely JavaScript so purely runs in the browser.

Does the problem really go away if you remove the card? Or does it go away if you remove the parts in configuration.yml? And do you use MQTT or not?

TheLastProject avatar Jun 26 '20 03:06 TheLastProject

Here are some stats, they all are from the homeassistant container itself, for the record I'm using two vaccums with valetudo:

  • Just after reboot with the MQTT variables for mapping enabled (they are excluded from recorder): ~ $ ha core stats blk_read: 0 blk_write: 0 cpu_percent: 6.09 memory_limit: 968859648 memory_percent: 14.68 memory_usage: 142196736 network_rx: 0 network_tx: 0

  • After editing lovelace including both vacuum map cards: ~ $ ha core stats blk_read: 0 blk_write: 0 cpu_percent: 106.19 memory_limit: 968859648 memory_percent: 18.73 memory_usage: 181497856 network_rx: 0 network_tx: 0

  • After that, cpu usage goes down again in a couple of minutes if I close the browser tab, on similar values as start.

  • Opening HomeAssistant again and accesing lovelace map card again, cpu usage stays low if no vacuum activity.

  • When one of the vacuums starts cleaning while I'm viewing the card: ~ $ ha core stats blk_read: 0 blk_write: 0 cpu_percent: 122.34 memory_limit: 968859648 memory_percent: 19.38 memory_usage: 187727872 network_rx: 0 network_tx: 0

  • If I close the browser, and while not viewing the card any longer, cpu slows down a little bit, but still very high: ~ $ ha core stats blk_read: 0 blk_write: 0 cpu_percent: 102.54 memory_limit: 968859648 memory_percent: 28.85 memory_usage: 279511040 network_rx: 0 network_tx: 0

  • When vacuum stops, CPU usage goes back to normal in a minute: ~ $ ha core stats blk_read: 0 blk_write: 0 cpu_percent: 9.33 memory_limit: 968859648 memory_percent: 28.65 memory_usage: 277618688 network_rx: 0 network_tx: 0

This is my current config of MQTT sensor for mapping:

  • platform: mqtt state_topic: "valetudo/one/state" json_attributes_topic: "valetudo/one/map_data" name: one_map value_template: 'OK' scan_interval: 15

  • platform: mqtt state_topic: "valetudo/two/state" json_attributes_topic: "valetudo/two/map_data" name: two_map value_template: 'OK' scan_interval: 15

alceasan avatar Jun 26 '20 07:06 alceasan

I think it's just HA collect data from mqtt sensor. I tried to increase scan_interval from the default 5 to 15 and it does lower the system load a bit (load from 5->3).

ntcong avatar Jul 08 '20 09:07 ntcong

Hi! First of all I want to say that I find this project fantastic!

But unfortunately I can confirm what @alceasan said. I use a Core i5 server with Hassio and libvirt. When I have the live map in Lovelace the CPU usage of both the VM and the host increases to 80-100%. If I close the browser, the load drops to 60 to 80%. If I remove the card (MQTT map-sensor still present), the utilization is at normal values around 0-5%. I also excluded the sensor from the recorder via exclude.

My configuration:

sensor:
[...]
- platform: mqtt
  state_topic: "valetudo/rockrobo/state"
  json_attributes_topic: "valetudo/rockrobo/map_data"
  name: rockrobo_map
  value_template: 'OK'
  scan_interval: 10

recorder:
  [...]
  exclude:
    entities:
      - sensor.rockrobo_map

lovelace:
- crop:
      bottom: -113
      left: 110
      right: -120
      top: 120
   entity: sensor.rockrobo_map
   map_scale: 1.5
   min_height: 0
   rotate: 0
   title: Reinigungskarte
   type: 'custom:valetudo-map-card'
   vacuum_entity: vacuum.rockrobo

rainer-geiger avatar Aug 29 '20 22:08 rainer-geiger

Hi, recently rooted my gen1 and installed valetudo. Have noticed similar behaviour when vacuuming and the live map is updated. In my case I used HA's autodiscovery. I guess that I should manually create the sensors to modify the scan interval, right?

forast3r avatar Mar 24 '21 19:03 forast3r

Hi I'm running HA in a docker on an i3 mini pc with a gen1 vacuum - just did a test and don't get this issue. Using MQTT.

oystermon avatar Apr 09 '22 12:04 oystermon