home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.28k stars 30.6k forks source link

Strange CPU usage after some day without reboot (HA virtual machine) #87851

Closed avbor closed 1 year ago

avbor commented 1 year ago

The problem

My HA instance running in KVM virtual machine, VM created with official qcow2 (Home Assistant OS). Home Assistant 2023.2.3 Supervisor 2023.01.1 Operating System 9.5 Frontend 20230202.0 Database: latest version of MariaDB AddOn, DB size ~1.8Gb

After some (2-3) days without HA reboot I observe a very strange floating CPU load (inside VM):

screens from HA: image

Perhaps the problem is somewhere in the database, but I do not have enough knowledge to understand where: image

from external zabbix: image image

After restarting HA (only core) everything goes back to normal for the next couple of days. image

(I don't understand why, but my previous problem was closed due to unsupported configuration - https://github.com/home-assistant/core/issues/87831)

What version of Home Assistant Core has the issue?

core-2023.2.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

No response

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

bdraco commented 1 year ago

Can you post a MySQL process list from when the problem happens?

avbor commented 1 year ago

Sure, from phpMyAdmin would be okay? image

bdraco commented 1 year ago

Sure, from phpMyAdmin would be okay? image

Yes

home-assistant[bot] commented 1 year ago

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (recorder) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `recorder` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Change the title of the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign recorder` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


recorder documentation recorder source (message by IssueLinks)

avbor commented 1 year ago

@bdraco peaks every 5 minutes: image image

image

avbor commented 1 year ago

Small peaks every ~30 sec: image and image

Big peaks every ~5 min: image

This is all I was able to see with phpMyAdmin.

bdraco commented 1 year ago

Some of those queries are cut off can you do a full process list and post the full query as text?

bdraco commented 1 year ago

Also do you have any sql sensors set up ?

avbor commented 1 year ago

Some of those queries are cut off can you do a full process list and post the full query as text?

Every 5 min:


SELECT states.entity_id, states.state, states.last_changed_ts, states.last_updated_ts, states.attributes, state_attributes.shared_attrs FROM (SELECT max(states.state_id) AS max_state_id FROM states WHERE states.last_updated_ts >= 1676198403.071357e0 AND states.last_updated_ts < 1676296199.999999e0 AND states.entity_id IN ('sensor.average_carbon_dioxide_in_flat', 'sensor.average_pm25_in_flat', 'sensor.average_pm10_in_flat', 'sensor.average_temperature_in_flat', 'sensor.average_humidity_in_flat', 'sensor.average_voltage_in_flat', 'sensor.average_voltage_in_country_house', 'sensor.country_house_avg_temp_kids_rooms', 'sensor.country_house_avg_humidity_kids_rooms', 'sensor.kitchen_stove_temperature_min_max_bt', 'sensor.kitchen_stove_temperature_min_max_mean', 'sensor.kitchen_stove_temperature_median_min_max_mean', 'sensor.kitchen_stove_temperature_median_zb', 'sensor.kitchen_stove_temperature_median_bt', 'sensor.processor_use', 'sensor.memory_use_percent', 'sensor.memory_use', 'sensor.memory_free', 'sensor.energy_flat_main_power', 'sensor.country_house_living_room_dewpoint', 'sensor.country_house_kids_room_dewpoint', 'sensor.aleksandr_bmi', 'sensor.aleksandr_basal_metabolism', 'sensor.aleksandr_visceral_fat', 'sensor.aleksandr_weight', 'sensor.aleksandr_lean_body_mass', 'sensor.aleksandr_body_fat', 'sensor.aleksandr_protein', 'sensor.aleksandr_water', 'sensor.aleksandr_bone_mass', 'sensor.aleksandr_muscle_mass', 'sensor.aleksandr_metabolic_age', 'sensor.aleksandr_body_score', 'sensor.irina_bmi', 'sensor.irina_basal_metabolism', 'sensor.irina_visceral_fat', 'sensor.irina_weight', 'sensor.irina_lean_body_mass', 'sensor.irina_body_fat', 'sensor.irina_protein', 'sensor.irina_water', 'sensor.irina_bone_mass', 'sensor.irina_muscle_mass', 'sensor.irina_metabolic_age', 'sensor.irina_body_score', 'sensor.egor_bmi', 'sensor.egor_basal_metabolism', 'sensor.egor_visceral_fat', 'sensor.egor_weight', 'sensor.kirill_bmi', 'sensor.kirill_basal_metabolism', 'sensor.kirill_visceral_fat', 'sensor.kirill_weight', 'sensor.watchman_missing_entities', 'sensor.watchman_missing_services', 'sensor.ups_battery_charge', 'sensor.ups_battery_voltage', 'sensor.openweathermap_stupino_nivki_2_dew_point', 'sensor.openweathermap_stupino_nivki_2_temperature', 'sensor.openweathermap_stupino_nivki_2_feels_like_temperature', 'sensor.openweathermap_stupino_nivki_2_wind_speed', 'sensor.openweathermap_stupino_nivki_2_wind_bearing', 'sensor.openweathermap_stupino_nivki_2_humidity', 'sensor.openweathermap_stupino_nivki_2_pressure', 'sensor.openweathermap_stupino_nivki_2_cloud_coverage', 'sensor.openweathermap_stupino_nivki_2_rain', 'sensor.openweathermap_stupino_nivki_2_snow', 'sensor.openweathermap_stupino_nivki_2_uv_index', 'sensor.openweathermap_stupino_nivki_2_visibility', 'sensor.openweathermap_moskva_danilovskii_dew_point', 'sensor.openweathermap_moskva_danilovskii_temperature', 'sensor.openweathermap_moskva_danilovskii_feels_like_temperature', 'sensor.openweathermap_moskva_danilovskii_wind_speed', 'sensor.openweathermap_moskva_danilovskii_wind_bearing', 'sensor.openweathermap_moskva_danilovskii_humidity', 'sensor.openweathermap_moskva_danilovskii_pressure', 'sensor.openweathermap_moskva_danilovskii_cloud_coverage', 'sensor.openweathermap_moskva_danilovskii_rain', 'sensor.openweathermap_moskva_danilovskii_snow', 'sensor.openweathermap_moskva_danilovskii_uv_index', 'sensor.openweathermap_moskva_danilovskii_visibility', 'sensor.galaxy_tab_a_8_0_2019_battery', 'sensor.galaxy_tab_a_8_0_2019_internal_storage_free_space', 'sensor.galaxy_tab_a_8_0_2019_internal_storage_total_space', 'sensor.galaxy_tab_a_8_0_2019_free_memory', 'sensor.galaxy_tab_a_8_0_2019_total_memory', 'sensor.kb2003_uroven_zariada_akkumuliatora', 'sensor.kb2003_datchik_osveshchionnosti', 'sensor.kb2003_skorost_soedineniia_wifi', 'sensor.kb2003_chastota_wifi', 'sensor.kb2003_moshchnost_signala_wifi', 'sensor.kb2003_battery_temperature', 'sensor.kb2003_battery_power', 'sensor.sm_t295_hallway_battery_power', 'sensor.gosund_sp111_01_ampere', 'sensor.gosund_sp111_01_watt', 'sensor.gosund_sp111_05_ampere', 'sensor.gosund_sp111_05_watt', 'sensor.gosund_sp111_02_ampere', 'sensor.gosund_sp111_02_watt', 'sensor.gosund_sp111_06_ampere', 'sensor.gosund_sp111_06_watt', 'sensor.gosund_sp111_03_ampere', 'sensor.gosund_sp111_03_watt', 'sensor.gosund_sp111_08_ampere', 'sensor.gosund_sp111_08_watt', 'sensor.gosund_sp111_07_ampere', 'sensor.gosund_sp111_07_watt', 'sensor.gosund_sp111_04_ampere', 'sensor.gosund_sp111_04_watt', 'sensor.0x00158d000413b210_gas_density', 'sensor.tplink_smartplug_02_current_consumption', 'sensor.tplink_smartplug_02_voltage', 'sensor.tplink_smartplug_02_current', 'sensor.tplink_smartplug_01_current_consumption', 'sensor.tplink_smartplug_01_voltage', 'sensor.tplink_smartplug_01_current', 'sensor.gosund_sp111_09_ampere', 'sensor.gosund_sp111_09_watt', 'sensor.gosund_sp111_10_ampere', 'sensor.gosund_sp111_10_watt', 'sensor.esp32_miscale2_01_current_weight', 'sensor.esp32_miscale2_01_current_impedance', 'sensor.air_monitor_lite_cb3b_temperature', 'sensor.air_monitor_lite_cb3b_humidity', 'sensor.air_monitor_lite_cb3b_pm25', 'sensor.air_monitor_lite_cb3b_pm10', 'sensor.air_monitor_lite_cb3b_carbon_dioxide', 'sensor.air_monitor_lite_afb3_temperature', 'sensor.air_monitor_lite_afb3_humidity', 'sensor.air_monitor_lite_afb3_pm25', 'sensor.air_monitor_lite_afb3_pm10', 'sensor.air_monitor_lite_afb3_carbon_dioxide', 'sensor.air_monitor_lite_f6a7_temperature', 'sensor.air_monitor_lite_f6a7_humidity', 'sensor.air_monitor_lite_f6a7_pm25', 'sensor.air_monitor_lite_f6a7_pm10', 'sensor.air_monitor_lite_f6a7_carbon_dioxide', 'sensor.atc_03b4_temperature', 'sensor.atc_03b4_humidity', 'sensor.atc_03b4_battery', 'sensor.atc_3fc4_voltage', 'sensor.atc_4e9a_temperature', 'sensor.atc_4e9a_humidity', 'sensor.atc_4e9a_battery', 'sensor.atc_3d13_voltage', 'sensor.atc_bdae_temperature', 'sensor.atc_bdae_humidity', 'sensor.atc_bdae_battery', 'sensor.th_kukhnia_kholodilnik_niz_voltage', 'sensor.atc_84c8_voltage', 'sensor.th_kukhnia_za_oknom_temperature', 'sensor.th_kukhnia_za_oknom_humidity', 'sensor.th_kukhnia_za_oknom_battery', 'sensor.temperature_humidity_sensor_ac21_temperature', 'sensor.temperature_humidity_sensor_ac21_humidity', 'sensor.fda50693_a4e2_4fb1_afcf_c6eb07647825_10011_2_79ae_estimated_distance', 'sensor.fda50693_a4e2_4fb1_afcf_c6eb07647825_10011_1_2340_estimated_distance', 'sensor.ed5e33eb_0ca3_4263_a681_a68b1045a5e6_100_1_estimated_distance', 'sensor.0x158d00054859d5_battery', 'sensor.0x158d000802df91_temperature', 'sensor.0x158d000802df91_humidity', 'sensor.0x158d000802df91_battery', 'sensor.0x158d000802df91_pressure', 'sensor.0x158d00040e019e_temperature', 'sensor.0x158d00040e019e_humidity', 'sensor.0x158d00040e019e_battery', 'sensor.a4c1380b3a85_temperature', 'sensor.a4c1380b3a85_humidity', 'sensor.a4c1380b3a85_battery', 'sensor.a4c138c7ded2_temperature', 'sensor.a4c138c7ded2_humidity', 'sensor.a4c138c7ded2_battery', 'sensor.lumi_lumi_sensor_cube_power', 'sensor.lumi_lumi_sensor_cube_aqgl01_d92a2905_device_temperature', 'sensor.lumi_lumi_sen_ill_mgl01_power', 'sensor.lumi_lumi_sen_ill_mgl01_illuminance', 'sensor.ikea_of_sweden_tradfri_on_off_switch_46a690fe_power', 'sensor.ikea_of_sweden_tradfri_on_off_switch_06e49efe_power', 'sensor.adurolight_vms_adurolight_f604cd01_power', 'sensor.0x158d00039e2ecb_power', 'sensor.0x158d00039e2ecb_temperature', 'sensor.0x158d00039e2ecb_humidity', 'sensor.0x158d000309920a_battery', 'sensor.0x158d000309920a_illuminance', 'sensor.lumi_lumi_sensor_motion_aq2_0a920903_device_temperature', 'sensor.lumi_lumi_sensor_switch_b1115a04_power', 'sensor.lumi_lumi_sensor_switch_53115a04_power', 'sensor.lumi_lumi_sensor_swit_power', 'sensor.lumi_lumi_sensor_swit_8e46ab04_device_temperature', 'sensor.lumi_lumi_sensor_switch_31f65f03_power', 'sensor.lumi_lumi_sensor_motion_aq2_power', 'sensor.0x158d0003fac0ec_illuminance', 'sensor.lumi_lumi_sensor_motion_aq2_ecc0fa03_device_temperature', 'sensor.lumi_lumi_sens_power', 'sensor.0x158d0003931a55_temperature', 'sensor.0x158d0003931a55_humidity', 'sensor.lumi_lumi_sensor_switch_c59b5a03_power', 'sensor.0x158d0003230618_battery', 'sensor.0x158d0003230618_pressure', 'sensor.0x158d0003230618_temperature', 'sensor.0x158d0003230618_humidity', 'sensor.0x158d0003931b0e_battery', 'sensor.0x158d0003931b0e_temperature', 'sensor.0x158d0003931b0e_humidity', 'sensor.0x158d0003931aec_battery', 'sensor.0x158d0003931aec_temperature', 'sensor.0x158d0003931aec_humidity', 'sensor.lumi_lumi_sensor_switch_9efd3e03_power', 'sensor.lumi_lumi_sensor_motion_aq2_8eea4c04_power', 'sensor.0x158d00044cea8e_illuminance', 'sensor.lumi_lumi_sensor_motion_aq2_8eea4c04_device_temperature', 'sensor.lumi_lumi_sensor_magnet_power', 'sensor.lumi_lumi_sensor_magnet_673b0704_power', 'sensor.lumi_lumi_sensor_magnet_2547d503_power', 'sensor.lumi_lumi_sensor_magnet_74f99c03_power', 'sensor.lumi_th_kitchen_stove_power', 'sensor.lumi_th_kitchen_stove_temperature', 'sensor.lumi_th_kitchen_stove_humidity', 'sensor.lumi_lumi_sensor_magnet_50659603_power', 'sensor.blitzwolf_shp13_02_3ad702fe_electrical_measurement', 'sensor.blitzwolf_shp13_02_3ad702fe_electrical_measurement_rms_current', 'sensor.blitzwolf_shp13_02_3ad702fe_electrical_measurement_rms_voltage', 'sensor.tz3000_g5xawfcq_ts0121_3ad702fe_electrical_measurement_power_factor', 'sensor.lumi_lumi_sensor_switch_005dd103_power', 'sensor.lumi_lumi_sensor_motion_aq2_7b4e5f07_power', 'sensor.lumi_lumi_sensor_motion_aq2_7b4e5f07_illuminance', 'sensor.lumi_lumi_sensor_motion_aq2_7b4e5f07_device_temperature', 'sensor.lumi_lumi_sensor_magnet_724f4f04_power', 'sensor.lumi_lumi_sensor_switch_power', 'sensor.lumi_lumi_sensor_magnet_9bef9603_power', 'sensor.lumi_lumi_sensor_magnet_cd829803_power', 'sensor.lumi_lumi_sen_ill_mgl01_0d117d3c_power', 'sensor.0x4cf8cdf3c7d110d_illuminance', 'sensor.lumi_lumi_sensor_wleak_aq1_power', 'sensor.lumi_lumi_sensor_wleak_aq1_7cadd306_device_temperature', 'sensor.ikea_1_power', 'sensor.ikea_4_power', 'sensor.ikea_5_power', 'sensor.lumi_lumi_weather_power', 'sensor.lumi_lumi_weather_pressure', 'sensor.lumi_lumi_weather_temperature', 'sensor.lumi_lumi_weather_humidity', 'sensor.lumi_lumi_weather_4dad5507_power', 'sensor.lumi_lumi_weather_4dad5507_pressure', 'sensor.lumi_lumi_weather_4dad5507_temperature', 'sensor.lumi_lumi_weather_4dad5507_humidity', 'sensor.lumi_lumi_weather_bf387507_power', 'sensor.lumi_lumi_weather_bf387507_pressure', 'sensor.lumi_lumi_weather_bf387507_temperature', 'sensor.lumi_lumi_weather_bf387507_humidity', 'sensor.lumi_lumi_weather_824e9807_power', 'sensor.lumi_lumi_weather_824e9807_pressure', 'sensor.lumi_lumi_weather_824e9807_temperature', 'sensor.lumi_lumi_weather_824e9807_humidity', 'sensor.lumi_lumi_sensor_wleak_aq1_840d0304_power', 'sensor.lumi_lumi_sensor_wleak_aq1_840d0304_device_temperature', 'sensor.lumi_lumi_sensor_wleak_aq1_7de70004_power', 'sensor.lumi_lumi_sensor_wleak_aq1_7de70004_device_temperature', 'sensor.xiaomi_lumi_sen_ill_mgl01_battery', 'sensor.xiaomi_lumi_sen_ill_mgl01_illuminance', 'sensor.xiaomi_lumi_sen_ill_mgl01_battery_2', 'sensor.xiaomi_lumi_sen_ill_mgl01_illuminance_2', 'sensor.trust_battery', 'sensor.tz3000_g5xawfcq_ts0121_electricalmeasurement', 'sensor.tz3000_g5xawfcq_ts0121_electricalmeasurementrmscurrent', 'sensor.tz3000_g5xawfcq_ts0121_electricalmeasurementrmsvoltage', 'sensor.tz3000_g5xawfcq_ts0121_electricalmeasurementpowerfactor', 'sensor.blitzwolf_shp15_01_electricalmeasurement', 'sensor.blitzwolf_shp15_01_electricalmeasurementrmscurrent', 'sensor.blitzwolf_shp15_01_electricalmeasurementrmsvoltage', 'sensor.blitzwolf_shp15_01_electricalmeasurementpowerfactor', 'sensor.lumi_lumi_sensor_magnet_battery', 'sensor.lumi_lumi_sensor_magnet_devicetemperature', 'sensor.lumi_lumi_relay_c2acn01_electricalmeasurement', 'sensor.lumi_lumi_relay_c2acn01_electricalmeasurementrmsvoltage', 'sensor.lumi_lumi_relay_c2acn01_electricalmeasurementpowerfactor', 'sensor.lumi_lumi_relay_c2acn01_devicetemperature', 'sensor.tz3000_zloso4jk_ts011f_active_power', 'sensor.tz3000_zloso4jk_ts011f_rms_current', 'sensor.tz3000_zloso4jk_ts011f_rms_voltage', 'sensor.tz3000_zloso4jk_ts011f_power_factor', 'sensor.ikea_of_sweden_tradfri_on_off_switch_battery', 'sensor.atc_3fc4_temperature', 'sensor.atc_3fc4_humidity', 'sensor.atc_3fc4_battery', 'sensor.temperature_humidity_sensor_ac21_battery', 'sensor.temperature_humidity_sensor_ac21_voltage', 'sensor.a4c138d358e9_humidity', 'sensor.a4c138d358e9_temperature', 'sensor.a4c138d358e9_battery', 'sensor.a4c1384e2b64_humidity', 'sensor.a4c1384e2b64_temperature', 'sensor.a4c1384e2b64_battery', 'sensor.aleksandr_body_type', 'sensor.irina_body_type', 'sensor.atc_03b4_voltage', 'sensor.atc_4e9a_voltage', 'sensor.atc_3d13_temperature', 'sensor.atc_3d13_humidity', 'sensor.atc_3d13_battery', 'sensor.atc_bdae_voltage', 'sensor.atc_8716_temperature', 'sensor.atc_8716_humidity', 'sensor.atc_8716_battery', 'sensor.atc_84c8_temperature', 'sensor.atc_84c8_humidity', 'sensor.atc_84c8_battery', 'sensor.atc_7f83_voltage', 'sensor.e2c56db5_dffb_48d2_b060_d0f5a71096e0_0_0_estimated_distance', 'sensor.74278bda_b644_4520_8f0c_720eaf059935_0_124_377c_estimated_distance', 'sensor.400225dd_3d15_4a4b_9db3_93c4b2d01eda_0_0_08ff_estimated_distance', 'sensor.389fbc46_bfb4_4d29_a089_bb5b343d069c_100_1_f15f_estimated_distance', 'sensor.74278bda_b644_4520_8f0c_720eaf059935_0_30053_6896_estimated_distance', 'sensor.ikea_3_battery_2') GROUP BY states.entity_id) AS anon_1, states LEFT OUTER JOIN state_attributes ON states.attributes_id = state_attributes.attributes_id WHERE states.state_id = anon_1.max_state_id

Also do you have any sql sensors set up ?

Yes, i have some for HA DB: image

SELECT COUNT(*) AS "rows" FROM events;
SELECT COUNT(*) AS "rows" FROM states;
SELECT COUNT(*) AS "rows" FROM statistics;
SELECT SUM(table_rows) AS "total_rows" FROM information_schema.tables WHERE table_schema = "homeassistant";
SELECT table_schema "database", Round(Sum(data_length + index_length) / 1048576, 2) AS "value" FROM information_schema.tables WHERE table_schema="homeassistant" GROUP BY table_schema;
bdraco commented 1 year ago

Which version of MariaDB are you running? Are you using addon version 2.5.2?

bdraco commented 1 year ago
SELECT COUNT(*) AS "rows" FROM events;
SELECT COUNT(*) AS "rows" FROM states;
SELECT COUNT(*) AS "rows" FROM statistics;

These queries are selecting the entire database. I suspect they are part of the issue.

You can use estimated rows instead which should be instant http://www.tocker.ca/fastest-way-to-count-rows-in-a-table.html

avbor commented 1 year ago

Which version of MariaDB are you running? Are you using addon version 2.5.2?

Yeap - 2.5.2 - latest official addon =)

These queries are selecting the entire database. I suspect they are part of the issue.

load bursts every 30 seconds, yes.

But they absolutely do not explain the load occurring once every 5 minutes, which appears only after a couple of days without restarting the HA. And why this load disappears for a while after the HA reset. image

bdraco commented 1 year ago

The 5m load spikes are statistics being compiled. If you send me another database dump I can see if I can optimize that query some more

avbor commented 1 year ago

The 5m load spikes are statistics being compiled. If you send me another database dump I can see if I can optimize that query some more

Ok, but why is it not constant, but only appears after a couple of days? I sent a link to the database dump by mail.

bdraco commented 1 year ago

Ok, but why is it not constant, but only appears after a couple of days?

There are probably multiple issues going on. Assuming that is a graph of all the processes load, can you send a profiler.start when its using more cpu and when its not?

bdraco commented 1 year ago

Loading the db into my test instance now

avbor commented 1 year ago

can you send a profiler.start

Can you tell me how to do it?

bdraco commented 1 year ago
  1. Install the profiler integration
  2. Call this service in the dev tools https://www.home-assistant.io/integrations/profiler/#service-profilerstart
  3. Check the persistent notifications
  4. Download the callgrind.out.XXX file

Email or post it here (nothing sensitive in it, just function call timings)

bdraco commented 1 year ago
SELECT states.entity_id, states.state, states.last_changed_ts, states.last_updated_ts, states.attributes, state_attributes.shared_attrs FROM (SELECT max(states.state_id) AS max_state_id FROM states WHERE states.last_updated_ts >= 1676198403.071357e0 AND states.last_updated_ts < 1676296199.999999e0 AND states.entity_id IN ('sensor.average_carbon_dioxide_in_flat', 'sensor.average_pm25_in_flat', 'sensor.average_pm10_in_flat', 'sensor.average_temperature_in_flat', 'sensor.average_humidity_in_flat', 'sensor.average_voltage_in_flat', 'sensor.average_voltage_in_country_house', 'sensor.country_house_avg_temp_kids_rooms', 'sensor.country_house_avg_humidity_kids_rooms', 'sensor.kitchen_stove_temperature_min_max_bt', 'sensor.kitchen_stove_temperature_min_max_mean', 'sensor.kitchen_stove_temperature_median_min_max_mean', 'sensor.kitchen_stove_temperature_median_zb', 'sensor.kitchen_stove_temperature_median_bt', 'sensor.processor_use', 'sensor.memory_use_percent', 'sensor.memory_use', 'sensor.memory_free', 'sensor.energy_flat_main_power', 'sensor.country_house_living_room_dewpoint', 'sensor.country_house_kids_room_dewpoint', 'sensor.aleksandr_bmi', 'sensor.aleksandr_basal_metabolism', 'sensor.aleksandr_visceral_fat', 'sensor.aleksandr_weight', 'sensor.aleksandr_lean_body_mass', 'sensor.aleksandr_body_fat', 'sensor.aleksandr_protein', 'sensor.aleksandr_water', 'sensor.aleksandr_bone_mass', 'sensor.aleksandr_muscle_mass', 'sensor.aleksandr_metabolic_age', 'sensor.aleksandr_body_score', 'sensor.irina_bmi', 'sensor.irina_basal_metabolism', 'sensor.irina_visceral_fat', 'sensor.irina_weight', 'sensor.irina_lean_body_mass', 'sensor.irina_body_fat', 'sensor.irina_protein', 'sensor.irina_water', 'sensor.irina_bone_mass', 'sensor.irina_muscle_mass', 'sensor.irina_metabolic_age', 'sensor.irina_body_score', 'sensor.egor_bmi', 'sensor.egor_basal_metabolism', 'sensor.egor_visceral_fat', 'sensor.egor_weight', 'sensor.kirill_bmi', 'sensor.kirill_basal_metabolism', 'sensor.kirill_visceral_fat', 'sensor.kirill_weight', 'sensor.watchman_missing_entities', 'sensor.watchman_missing_services', 'sensor.ups_battery_charge', 'sensor.ups_battery_voltage', 'sensor.openweathermap_stupino_nivki_2_dew_point', 'sensor.openweathermap_stupino_nivki_2_temperature', 'sensor.openweathermap_stupino_nivki_2_feels_like_temperature', 'sensor.openweathermap_stupino_nivki_2_wind_speed', 'sensor.openweathermap_stupino_nivki_2_wind_bearing', 'sensor.openweathermap_stupino_nivki_2_humidity', 'sensor.openweathermap_stupino_nivki_2_pressure', 'sensor.openweathermap_stupino_nivki_2_cloud_coverage', 'sensor.openweathermap_stupino_nivki_2_rain', 'sensor.openweathermap_stupino_nivki_2_snow', 'sensor.openweathermap_stupino_nivki_2_uv_index', 'sensor.openweathermap_stupino_nivki_2_visibility', 'sensor.openweathermap_moskva_danilovskii_dew_point', 'sensor.openweathermap_moskva_danilovskii_temperature', 'sensor.openweathermap_moskva_danilovskii_feels_like_temperature', 'sensor.openweathermap_moskva_danilovskii_wind_speed', 'sensor.openweathermap_moskva_danilovskii_wind_bearing', 'sensor.openweathermap_moskva_danilovskii_humidity', 'sensor.openweathermap_moskva_danilovskii_pressure', 'sensor.openweathermap_moskva_danilovskii_cloud_coverage', 'sensor.openweathermap_moskva_danilovskii_rain', 'sensor.openweathermap_moskva_danilovskii_snow', 'sensor.openweathermap_moskva_danilovskii_uv_index', 'sensor.openweathermap_moskva_danilovskii_visibility', 'sensor.galaxy_tab_a_8_0_2019_battery', 'sensor.galaxy_tab_a_8_0_2019_internal_storage_free_space', 'sensor.galaxy_tab_a_8_0_2019_internal_storage_total_space', 'sensor.galaxy_tab_a_8_0_2019_free_memory', 'sensor.galaxy_tab_a_8_0_2019_total_memory', 'sensor.kb2003_uroven_zariada_akkumuliatora', 'sensor.kb2003_datchik_osveshchionnosti', 'sensor.kb2003_skorost_soedineniia_wifi', 'sensor.kb2003_chastota_wifi', 'sensor.kb2003_moshchnost_signala_wifi', 'sensor.kb2003_battery_temperature', 'sensor.kb2003_battery_power', 'sensor.sm_t295_hallway_battery_power', 'sensor.gosund_sp111_01_ampere', 'sensor.gosund_sp111_01_watt', 'sensor.gosund_sp111_05_ampere', 'sensor.gosund_sp111_05_watt', 'sensor.gosund_sp111_02_ampere', 'sensor.gosund_sp111_02_watt', 'sensor.gosund_sp111_06_ampere', 'sensor.gosund_sp111_06_watt', 'sensor.gosund_sp111_03_ampere', 'sensor.gosund_sp111_03_watt', 'sensor.gosund_sp111_08_ampere', 'sensor.gosund_sp111_08_watt', 'sensor.gosund_sp111_07_ampere', 'sensor.gosund_sp111_07_watt', 'sensor.gosund_sp111_04_ampere', 'sensor.gosund_sp111_04_watt', 'sensor.0x00158d000413b210_gas_density', 'sensor.tplink_smartplug_02_current_consumption', 'sensor.tplink_smartplug_02_voltage', 'sensor.tplink_smartplug_02_current', 'sensor.tplink_smartplug_01_current_consumption', 'sensor.tplink_smartplug_01_voltage', 'sensor.tplink_smartplug_01_current', 'sensor.gosund_sp111_09_ampere', 'sensor.gosund_sp111_09_watt', 'sensor.gosund_sp111_10_ampere', 'sensor.gosund_sp111_10_watt', 'sensor.esp32_miscale2_01_current_weight', 'sensor.esp32_miscale2_01_current_impedance', 'sensor.air_monitor_lite_cb3b_temperature', 'sensor.air_monitor_lite_cb3b_humidity', 'sensor.air_monitor_lite_cb3b_pm25', 'sensor.air_monitor_lite_cb3b_pm10', 'sensor.air_monitor_lite_cb3b_carbon_dioxide', 'sensor.air_monitor_lite_afb3_temperature', 'sensor.air_monitor_lite_afb3_humidity', 'sensor.air_monitor_lite_afb3_pm25', 'sensor.air_monitor_lite_afb3_pm10', 'sensor.air_monitor_lite_afb3_carbon_dioxide', 'sensor.air_monitor_lite_f6a7_temperature', 'sensor.air_monitor_lite_f6a7_humidity', 'sensor.air_monitor_lite_f6a7_pm25', 'sensor.air_monitor_lite_f6a7_pm10', 'sensor.air_monitor_lite_f6a7_carbon_dioxide', 'sensor.atc_03b4_temperature', 'sensor.atc_03b4_humidity', 'sensor.atc_03b4_battery', 'sensor.atc_3fc4_voltage', 'sensor.atc_4e9a_temperature', 'sensor.atc_4e9a_humidity', 'sensor.atc_4e9a_battery', 'sensor.atc_3d13_voltage', 'sensor.atc_bdae_temperature', 'sensor.atc_bdae_humidity', 'sensor.atc_bdae_battery', 'sensor.th_kukhnia_kholodilnik_niz_voltage', 'sensor.atc_84c8_voltage', 'sensor.th_kukhnia_za_oknom_temperature', 'sensor.th_kukhnia_za_oknom_humidity', 'sensor.th_kukhnia_za_oknom_battery', 'sensor.temperature_humidity_sensor_ac21_temperature', 'sensor.temperature_humidity_sensor_ac21_humidity', 'sensor.fda50693_a4e2_4fb1_afcf_c6eb07647825_10011_2_79ae_estimated_distance', 'sensor.fda50693_a4e2_4fb1_afcf_c6eb07647825_10011_1_2340_estimated_distance', 'sensor.ed5e33eb_0ca3_4263_a681_a68b1045a5e6_100_1_estimated_distance', 'sensor.0x158d00054859d5_battery', 'sensor.0x158d000802df91_temperature', 'sensor.0x158d000802df91_humidity', 'sensor.0x158d000802df91_battery', 'sensor.0x158d000802df91_pressure', 'sensor.0x158d00040e019e_temperature', 'sensor.0x158d00040e019e_humidity', 'sensor.0x158d00040e019e_battery', 'sensor.a4c1380b3a85_temperature', 'sensor.a4c1380b3a85_humidity', 'sensor.a4c1380b3a85_battery', 'sensor.a4c138c7ded2_temperature', 'sensor.a4c138c7ded2_humidity', 'sensor.a4c138c7ded2_battery', 'sensor.lumi_lumi_sensor_cube_power', 'sensor.lumi_lumi_sensor_cube_aqgl01_d92a2905_device_temperature', 'sensor.lumi_lumi_sen_ill_mgl01_power', 'sensor.lumi_lumi_sen_ill_mgl01_illuminance', 'sensor.ikea_of_sweden_tradfri_on_off_switch_46a690fe_power', 'sensor.ikea_of_sweden_tradfri_on_off_switch_06e49efe_power', 'sensor.adurolight_vms_adurolight_f604cd01_power', 'sensor.0x158d00039e2ecb_power', 'sensor.0x158d00039e2ecb_temperature', 'sensor.0x158d00039e2ecb_humidity', 'sensor.0x158d000309920a_battery', 'sensor.0x158d000309920a_illuminance', 'sensor.lumi_lumi_sensor_motion_aq2_0a920903_device_temperature', 'sensor.lumi_lumi_sensor_switch_b1115a04_power', 'sensor.lumi_lumi_sensor_switch_53115a04_power', 'sensor.lumi_lumi_sensor_swit_power', 'sensor.lumi_lumi_sensor_swit_8e46ab04_device_temperature', 'sensor.lumi_lumi_sensor_switch_31f65f03_power', 'sensor.lumi_lumi_sensor_motion_aq2_power', 'sensor.0x158d0003fac0ec_illuminance', 'sensor.lumi_lumi_sensor_motion_aq2_ecc0fa03_device_temperature', 'sensor.lumi_lumi_sens_power', 'sensor.0x158d0003931a55_temperature', 'sensor.0x158d0003931a55_humidity', 'sensor.lumi_lumi_sensor_switch_c59b5a03_power', 'sensor.0x158d0003230618_battery', 'sensor.0x158d0003230618_pressure', 'sensor.0x158d0003230618_temperature', 'sensor.0x158d0003230618_humidity', 'sensor.0x158d0003931b0e_battery', 'sensor.0x158d0003931b0e_temperature', 'sensor.0x158d0003931b0e_humidity', 'sensor.0x158d0003931aec_battery', 'sensor.0x158d0003931aec_temperature', 'sensor.0x158d0003931aec_humidity', 'sensor.lumi_lumi_sensor_switch_9efd3e03_power', 'sensor.lumi_lumi_sensor_motion_aq2_8eea4c04_power', 'sensor.0x158d00044cea8e_illuminance', 'sensor.lumi_lumi_sensor_motion_aq2_8eea4c04_device_temperature', 'sensor.lumi_lumi_sensor_magnet_power', 'sensor.lumi_lumi_sensor_magnet_673b0704_power', 'sensor.lumi_lumi_sensor_magnet_2547d503_power', 'sensor.lumi_lumi_sensor_magnet_74f99c03_power', 'sensor.lumi_th_kitchen_stove_power', 'sensor.lumi_th_kitchen_stove_temperature', 'sensor.lumi_th_kitchen_stove_humidity', 'sensor.lumi_lumi_sensor_magnet_50659603_power', 'sensor.blitzwolf_shp13_02_3ad702fe_electrical_measurement', 'sensor.blitzwolf_shp13_02_3ad702fe_electrical_measurement_rms_current', 'sensor.blitzwolf_shp13_02_3ad702fe_electrical_measurement_rms_voltage', 'sensor.tz3000_g5xawfcq_ts0121_3ad702fe_electrical_measurement_power_factor', 'sensor.lumi_lumi_sensor_switch_005dd103_power', 'sensor.lumi_lumi_sensor_motion_aq2_7b4e5f07_power', 'sensor.lumi_lumi_sensor_motion_aq2_7b4e5f07_illuminance', 'sensor.lumi_lumi_sensor_motion_aq2_7b4e5f07_device_temperature', 'sensor.lumi_lumi_sensor_magnet_724f4f04_power', 'sensor.lumi_lumi_sensor_switch_power', 'sensor.lumi_lumi_sensor_magnet_9bef9603_power', 'sensor.lumi_lumi_sensor_magnet_cd829803_power', 'sensor.lumi_lumi_sen_ill_mgl01_0d117d3c_power', 'sensor.0x4cf8cdf3c7d110d_illuminance', 'sensor.lumi_lumi_sensor_wleak_aq1_power', 'sensor.lumi_lumi_sensor_wleak_aq1_7cadd306_device_temperature', 'sensor.ikea_1_power', 'sensor.ikea_4_power', 'sensor.ikea_5_power', 'sensor.lumi_lumi_weather_power', 'sensor.lumi_lumi_weather_pressure', 'sensor.lumi_lumi_weather_temperature', 'sensor.lumi_lumi_weather_humidity', 'sensor.lumi_lumi_weather_4dad5507_power', 'sensor.lumi_lumi_weather_4dad5507_pressure', 'sensor.lumi_lumi_weather_4dad5507_temperature', 'sensor.lumi_lumi_weather_4dad5507_humidity', 'sensor.lumi_lumi_weather_bf387507_power', 'sensor.lumi_lumi_weather_bf387507_pressure', 'sensor.lumi_lumi_weather_bf387507_temperature', 'sensor.lumi_lumi_weather_bf387507_humidity', 'sensor.lumi_lumi_weather_824e9807_power', 'sensor.lumi_lumi_weather_824e9807_pressure', 'sensor.lumi_lumi_weather_824e9807_temperature', 'sensor.lumi_lumi_weather_824e9807_humidity', 'sensor.lumi_lumi_sensor_wleak_aq1_840d0304_power', 'sensor.lumi_lumi_sensor_wleak_aq1_840d0304_device_temperature', 'sensor.lumi_lumi_sensor_wleak_aq1_7de70004_power', 'sensor.lumi_lumi_sensor_wleak_aq1_7de70004_device_temperature', 'sensor.xiaomi_lumi_sen_ill_mgl01_battery', 'sensor.xiaomi_lumi_sen_ill_mgl01_illuminance', 'sensor.xiaomi_lumi_sen_ill_mgl01_battery_2', 'sensor.xiaomi_lumi_sen_ill_mgl01_illuminance_2', 'sensor.trust_battery', 'sensor.tz3000_g5xawfcq_ts0121_electricalmeasurement', 'sensor.tz3000_g5xawfcq_ts0121_electricalmeasurementrmscurrent', 'sensor.tz3000_g5xawfcq_ts0121_electricalmeasurementrmsvoltage', 'sensor.tz3000_g5xawfcq_ts0121_electricalmeasurementpowerfactor', 'sensor.blitzwolf_shp15_01_electricalmeasurement', 'sensor.blitzwolf_shp15_01_electricalmeasurementrmscurrent', 'sensor.blitzwolf_shp15_01_electricalmeasurementrmsvoltage', 'sensor.blitzwolf_shp15_01_electricalmeasurementpowerfactor', 'sensor.lumi_lumi_sensor_magnet_battery', 'sensor.lumi_lumi_sensor_magnet_devicetemperature', 'sensor.lumi_lumi_relay_c2acn01_electricalmeasurement', 'sensor.lumi_lumi_relay_c2acn01_electricalmeasurementrmsvoltage', 'sensor.lumi_lumi_relay_c2acn01_electricalmeasurementpowerfactor', 'sensor.lumi_lumi_relay_c2acn01_devicetemperature', 'sensor.tz3000_zloso4jk_ts011f_active_power', 'sensor.tz3000_zloso4jk_ts011f_rms_current', 'sensor.tz3000_zloso4jk_ts011f_rms_voltage', 'sensor.tz3000_zloso4jk_ts011f_power_factor', 'sensor.ikea_of_sweden_tradfri_on_off_switch_battery', 'sensor.atc_3fc4_temperature', 'sensor.atc_3fc4_humidity', 'sensor.atc_3fc4_battery', 'sensor.temperature_humidity_sensor_ac21_battery', 'sensor.temperature_humidity_sensor_ac21_voltage', 'sensor.a4c138d358e9_humidity', 'sensor.a4c138d358e9_temperature', 'sensor.a4c138d358e9_battery', 'sensor.a4c1384e2b64_humidity', 'sensor.a4c1384e2b64_temperature', 'sensor.a4c1384e2b64_battery', 'sensor.aleksandr_body_type', 'sensor.irina_body_type', 'sensor.atc_03b4_voltage', 'sensor.atc_4e9a_voltage', 'sensor.atc_3d13_temperature', 'sensor.atc_3d13_humidity', 'sensor.atc_3d13_battery', 'sensor.atc_bdae_voltage', 'sensor.atc_8716_temperature', 'sensor.atc_8716_humidity', 'sensor.atc_8716_battery', 'sensor.atc_84c8_temperature', 'sensor.atc_84c8_humidity', 'sensor.atc_84c8_battery', 'sensor.atc_7f83_voltage', 'sensor.e2c56db5_dffb_48d2_b060_d0f5a71096e0_0_0_estimated_distance', 'sensor.74278bda_b644_4520_8f0c_720eaf059935_0_124_377c_estimated_distance', 'sensor.400225dd_3d15_4a4b_9db3_93c4b2d01eda_0_0_08ff_estimated_distance', 'sensor.389fbc46_bfb4_4d29_a089_bb5b343d069c_100_1_f15f_estimated_distance', 'sensor.74278bda_b644_4520_8f0c_720eaf059935_0_30053_6896_estimated_distance', 'sensor.ikea_3_battery_2') GROUP BY states.entity_id) AS anon_1, states LEFT OUTER JOIN state_attributes ON states.attributes_id = state_attributes.attributes_id WHERE states.state_id = anon_1.max_state_id

Something unexpected is going on as that query is taking 315 rows in set (0.230 sec)

I'm trying to see why its slow for you.

bdraco commented 1 year ago
+------+-------------+------------------+--------+---------------------------------------------------------------+-------------------------------------+---------+---------------------------------+--------+--------------------------+
| id   | select_type | table            | type   | possible_keys                                                 | key                                 | key_len | ref                             | rows   | Extra                    |
+------+-------------+------------------+--------+---------------------------------------------------------------+-------------------------------------+---------+---------------------------------+--------+--------------------------+
|    1 | PRIMARY     | <derived2>       | ALL    | NULL                                                          | NULL                                | NULL    | NULL                            | 638778 | Using where              |
|    1 | PRIMARY     | states           | eq_ref | PRIMARY                                                       | PRIMARY                             | 4       | anon_1.max_state_id             | 1      |                          |
|    1 | PRIMARY     | state_attributes | eq_ref | PRIMARY                                                       | PRIMARY                             | 4       | issue87851.states.attributes_id | 1      | Using where              |
|    2 | DERIVED     | states           | range  | ix_states_entity_id_last_updated_ts,ix_states_last_updated_ts | ix_states_entity_id_last_updated_ts | 1032    | NULL                            | 638778 | Using where; Using index |
+------+-------------+------------------+--------+---------------------------------------------------------------+-------------------------------------+---------+---------------------------------+--------+--------------------------+
bdraco commented 1 year ago

The inner query really does have to look at 638778 rows

+------+-------------+--------+-------+---------------------------------------------------------------+-------------------------------------+---------+------+--------+--------------------------+
| id   | select_type | table  | type  | possible_keys                                                 | key                                 | key_len | ref  | rows   | Extra                    |
+------+-------------+--------+-------+---------------------------------------------------------------+-------------------------------------+---------+------+--------+--------------------------+
|    1 | SIMPLE      | states | range | ix_states_entity_id_last_updated_ts,ix_states_last_updated_ts | ix_states_entity_id_last_updated_ts | 1032    | NULL | 638778 | Using where; Using index |
+------+-------------+--------+-------+---------------------------------------------------------------+-------------------------------------+---------+------+--------+--------------------------+
bdraco commented 1 year ago

The time window looks like it might have been manually selected though

MariaDB [issue87851]> select FROM_UNIXTIME('1676198403.071357e0');
+--------------------------------------+
| FROM_UNIXTIME('1676198403.071357e0') |
+--------------------------------------+
| 2023-02-12 04:40:03.071357           |
+--------------------------------------+
1 row in set (0.000 sec)

MariaDB [issue87851]> select FROM_UNIXTIME('1676296199.999999e0');
+--------------------------------------+
| FROM_UNIXTIME('1676296199.999999e0') |
+--------------------------------------+
| 2023-02-13 07:49:59.999999           |
+--------------------------------------+
1 row in set (0.000 sec)

Do you have some type of frontend card that is querying all of those entities ?

avbor commented 1 year ago

Email or post it here (nothing sensitive in it, just function call timings)

profiler.zip

folder "good" - 60 sec without peak, "bad" - with cpu peak

bdraco commented 1 year ago

The biggest expense in the profile is decoding protobuf messages from esphome devices. That's currently done in pure python. There doesn't appear to be any significant difference between the good and bad one.

bdraco commented 1 year ago

Nothing in the profiles looks like a problem though

avbor commented 1 year ago

Do you have some type of frontend card that is querying all of those entities ?

Which entities are we talking about exactly? I can't figure it out right away, if you're talking about entities in this select (states.entity_id, states.state, states.last_changed_ts, states.last_updated_ts, states.attributes, state_attributes.shared_attrs FROM (SELECT max(states.state_id)), then no, I don't have maps that query all of those entities.

bdraco commented 1 year ago

Which entities are we talking about exactly? I can't figure it out right away, if you're talking about entities in this select (states.entity_id, states.state, states.last_changed_ts, states.last_updated_ts, states.attributes, state_attributes.shared_attrs FROM (SELECT max(states.state_id)), then no, I don't have maps that query all of those entities.

Yup thats the one I'm talking about. Its a pretty standard history query but the time window being > 24 hours looks like it was manually queried from the UI as the stats backend only looks at 5 minute windows which should be very fast. Maybe there is a bug in the frontend where something is selecting more entities than expected.

avbor commented 1 year ago

Among these entities, there are definitely some that I have absolutely no interest in, and I would never put their story on the dashboard. =)

Besides, I haven't changed the interface for a long time, and the problem with CPU spikes like that appeared after one of the updates, but I don't remember which one.

If it's possible frontend bug, is there any chance to find it?

avbor commented 1 year ago

I am very confused by the fact that the problem appears only after several days without rebooting HA. If I reload my instance right now, the problem will disappear for a couple of days...

bdraco commented 1 year ago

Among these entities, there are definitely some that I have absolutely no interest in, and I would never put their story on the dashboard. =)

Besides, I haven't changed the interface for a long time, and the problem with CPU spikes like that appeared after one of the updates, but I don't remember which one.

If it's possible frontend bug, is there any chance to find it?

The main history panel saves the last query. If you go to it now, are there any entities selected?

bdraco commented 1 year ago

I am very confused by the fact that the problem appears only after several days without rebooting HA. If I reload my instance right now, the problem will disappear for a couple of days...

Can you take a py-spy the next time it appears again?

avbor commented 1 year ago

The main history panel saves the last query. If you go to it now, are there any entities selected?

Yes, now there are roughly all my entities selected (all the rooms), but the time period is 3 hours (by default). But I made this request a day or two ago, and in general I use history very rarely.

avbor commented 1 year ago

Can you take a py-spy the next time it appears again?

I can try it right now if I remember how to use it =)

bdraco commented 1 year ago

https://community.home-assistant.io/t/instructions-to-install-py-spy-on-haos/480473

Note that this guide uses 0.3.12. Use 0.3.14 instead as it has some fixes

avbor commented 1 year ago

https://community.home-assistant.io/t/instructions-to-install-py-spy-on-haos/480473

Note that this guide uses 0.3.12. Use 0.3.14 instead as it has some fixes

Thx! The result is at the same link as the database dump.

image

bdraco commented 1 year ago

The only thing I can see in the spy is that its compiling stats in that window, but it doesn't look that expensive. I can try to optimize compiling stats a bit later this week.

avbor commented 1 year ago

Would it be helpful to gather some information after the HA reboot? Before those weird load peaks appear.

avbor commented 1 year ago

For example, i just rebooted HA: image The screenshot shows only peaks every 30 seconds - sql sensors update. And completely missing peaks every 5 minutes...

avbor commented 1 year ago

Just for history, I removed the automatic update of sql sensors every 30 seconds (now I update them with automation once an hour), and the regular cpu load looks like this: image

We'll see if the five minute bursts show up in a couple of days.

avbor commented 1 year ago

Early this morning the load peaks again every 5 minutes, but this time they disappeared on their own after a couple of hours: image

avbor commented 1 year ago

It still comes up from time to time:

SELECT states.entity_id, states.state, states.last_changed_ts, states.last_updated_ts, states.attributes, state_attributes.shared_attrs FROM (SELECT max(states.state_id) AS max_state_id FROM states WHERE states.last_updated_ts >= 1676356826.256737e0 AND states.last_updated_ts < 1676441399.999999e0 AND states.entity_id IN ('sensor.average_carbon_dioxide_in_flat', 'sensor.average_pm25_in_flat', 'sensor.average_pm10_in_flat', 'sensor.average_temperature_in_flat', 'sensor.average_humidity_in_flat', 'sensor.average_voltage_in_flat', 'sensor.average_voltage_in_country_house', 'sensor.country_house_avg_temp_kids_rooms', 'sensor.country_house_avg_humidity_kids_rooms', 'sensor.kitchen_stove_temperature_min_max_bt', 'sensor.kitchen_stove_temperature_min_max_mean', 'sensor.kitchen_stove_temperature_median_min_max_mean', 'sensor.kitchen_stove_temperature_median_zb', 'sensor.kitchen_stove_temperature_median_bt', 'sensor.processor_use', 'sensor.memory_use_percent', 'sensor.memory_use', 'sensor.memory_free', 'sensor.energy_flat_main_power', 'sensor.country_house_living_room_dewpoint', 'sensor.country_house_kids_room_dewpoint', 'sensor.ups_battery_charge', 'sensor.ups_battery_voltage', 'sensor.galaxy_tab_a_8_0_2019_battery', 'sensor.galaxy_tab_a_8_0_2019_internal_storage_free_space', 'sensor.galaxy_tab_a_8_0_2019_internal_storage_total_space', 'sensor.galaxy_tab_a_8_0_2019_free_memory', 'sensor.galaxy_tab_a_8_0_2019_total_memory', 'sensor.openweathermap_stupino_nivki_2_dew_point', 'sensor.openweathermap_stupino_nivki_2_temperature', 'sensor.openweathermap_stupino_nivki_2_feels_like_temperature', 'sensor.openweathermap_stupino_nivki_2_wind_speed', 'sensor.openweathermap_stupino_nivki_2_wind_bearing', 'sensor.openweathermap_stupino_nivki_2_humidity', 'sensor.openweathermap_stupino_nivki_2_pressure', 'sensor.openweathermap_stupino_nivki_2_cloud_coverage', 'sensor.openweathermap_stupino_nivki_2_rain', 'sensor.openweathermap_stupino_nivki_2_snow', 'sensor.openweathermap_stupino_nivki_2_uv_index', 'sensor.openweathermap_stupino_nivki_2_visibility', 'sensor.openweathermap_moskva_danilovskii_dew_point', 'sensor.openweathermap_moskva_danilovskii_temperature', 'sensor.openweathermap_moskva_danilovskii_feels_like_temperature', 'sensor.openweathermap_moskva_danilovskii_wind_speed', 'sensor.openweathermap_moskva_danilovskii_wind_bearing', 'sensor.openweathermap_moskva_danilovskii_humidity', 'sensor.openweathermap_moskva_danilovskii_pressure', 'sensor.openweathermap_moskva_danilovskii_cloud_coverage', 'sensor.openweathermap_moskva_danilovskii_rain', 'sensor.openweathermap_moskva_danilovskii_snow', 'sensor.openweathermap_moskva_danilovskii_uv_index', 'sensor.openweathermap_moskva_danilovskii_visibility', 'sensor.watchman_missing_entities', 'sensor.watchman_missing_services', 'sensor.aleksandr_bmi', 'sensor.aleksandr_basal_metabolism', 'sensor.aleksandr_visceral_fat', 'sensor.aleksandr_weight', 'sensor.aleksandr_lean_body_mass', 'sensor.aleksandr_body_fat', 'sensor.aleksandr_protein', 'sensor.aleksandr_water', 'sensor.aleksandr_bone_mass', 'sensor.aleksandr_muscle_mass', 'sensor.aleksandr_metabolic_age', 'sensor.aleksandr_body_score', 'sensor.irina_bmi', 'sensor.irina_basal_metabolism', 'sensor.irina_visceral_fat', 'sensor.irina_weight', 'sensor.irina_lean_body_mass', 'sensor.irina_body_fat', 'sensor.irina_protein', 'sensor.irina_water', 'sensor.irina_bone_mass', 'sensor.irina_muscle_mass', 'sensor.irina_metabolic_age', 'sensor.irina_body_score', 'sensor.egor_bmi', 'sensor.egor_basal_metabolism', 'sensor.egor_visceral_fat', 'sensor.egor_weight', 'sensor.kirill_bmi', 'sensor.kirill_basal_metabolism', 'sensor.kirill_visceral_fat', 'sensor.kirill_weight', 'sensor.kb2003_uroven_zariada_akkumuliatora', 'sensor.kb2003_datchik_osveshchionnosti', 'sensor.kb2003_skorost_soedineniia_wifi', 'sensor.kb2003_chastota_wifi', 'sensor.kb2003_moshchnost_signala_wifi', 'sensor.kb2003_vnutrenniaia_pamiat', 'sensor.kb2003_battery_temperature', 'sensor.kb2003_battery_power', 'sensor.2109119dg_battery_level', 'sensor.2109119dg_battery_temperature', 'sensor.2109119dg_light_sensor', 'sensor.2109119dg_battery_power', 'sensor.sm_t295_hallway_battery_level', 'sensor.sm_t295_hallway_battery_temperature', 'sensor.sm_t295_hallway_battery_power', 'sensor.gosund_sp111_05_ampere', 'sensor.gosund_sp111_05_watt', 'sensor.gosund_sp111_06_ampere', 'sensor.gosund_sp111_06_watt', 'sensor.gosund_sp111_02_ampere', 'sensor.gosund_sp111_02_watt', 'sensor.gosund_sp111_01_ampere', 'sensor.gosund_sp111_01_watt', 'sensor.gosund_sp111_04_ampere', 'sensor.gosund_sp111_04_watt', 'sensor.gosund_sp111_08_ampere', 'sensor.gosund_sp111_08_watt', 'sensor.gosund_sp111_03_ampere', 'sensor.gosund_sp111_03_watt', 'sensor.gosund_sp111_07_ampere', 'sensor.gosund_sp111_07_watt', 'sensor.gosund_sp111_09_ampere', 'sensor.gosund_sp111_09_watt', 'sensor.gosund_sp111_10_ampere', 'sensor.gosund_sp111_10_watt', 'sensor.esp32_miscale2_01_current_weight', 'sensor.esp32_miscale2_01_current_impedance', 'sensor.0x00158d000413b210_gas_density', 'sensor.temperature_humidity_sensor_ac21_humidity', 'sensor.atc_03b4_temperature', 'sensor.atc_03b4_humidity', 'sensor.atc_03b4_battery', 'sensor.atc_3fc4_temperature', 'sensor.atc_3fc4_humidity', 'sensor.atc_3fc4_battery', 'sensor.atc_4e9a_temperature', 'sensor.atc_4e9a_humidity', 'sensor.atc_4e9a_battery', 'sensor.atc_3d13_temperature', 'sensor.atc_3d13_humidity', 'sensor.atc_3d13_battery', 'sensor.atc_bdae_temperature', 'sensor.atc_bdae_humidity', 'sensor.atc_bdae_battery', 'sensor.atc_84c8_voltage', 'sensor.th_kukhnia_za_oknom_temperature', 'sensor.th_kukhnia_za_oknom_humidity', 'sensor.th_kukhnia_za_oknom_battery', 'sensor.air_monitor_lite_cb3b_temperature', 'sensor.air_monitor_lite_cb3b_humidity', 'sensor.air_monitor_lite_cb3b_pm25', 'sensor.air_monitor_lite_cb3b_pm10', 'sensor.air_monitor_lite_cb3b_carbon_dioxide', 'sensor.air_monitor_lite_afb3_temperature', 'sensor.air_monitor_lite_afb3_humidity', 'sensor.air_monitor_lite_afb3_pm25', 'sensor.air_monitor_lite_afb3_pm10', 'sensor.air_monitor_lite_afb3_carbon_dioxide', 'sensor.air_monitor_lite_f6a7_temperature', 'sensor.air_monitor_lite_f6a7_humidity', 'sensor.air_monitor_lite_f6a7_pm25', 'sensor.air_monitor_lite_f6a7_pm10', 'sensor.air_monitor_lite_f6a7_carbon_dioxide', 'sensor.0x158d00054859d5_battery', 'sensor.0x158d000802df91_temperature', 'sensor.0x158d000802df91_humidity', 'sensor.0x158d000802df91_battery', 'sensor.0x158d000802df91_pressure', 'sensor.0x158d00040e019e_temperature', 'sensor.0x158d00040e019e_humidity', 'sensor.0x158d00040e019e_battery', 'sensor.ed5e33eb_0ca3_4263_a681_a68b1045a5e6_100_1_estimated_distance', 'sensor.fda50693_a4e2_4fb1_afcf_c6eb07647825_10011_1_2340_estimated_distance', 'sensor.tplink_smartplug_01_current_consumption', 'sensor.tplink_smartplug_01_voltage', 'sensor.tplink_smartplug_01_current', 'sensor.tplink_smartplug_02_current_consumption', 'sensor.tplink_smartplug_02_voltage', 'sensor.tplink_smartplug_02_current', 'sensor.a4c1380b3a85_temperature', 'sensor.a4c1380b3a85_humidity', 'sensor.a4c1380b3a85_battery', 'sensor.a4c138c7ded2_temperature', 'sensor.a4c138c7ded2_humidity', 'sensor.a4c138c7ded2_battery', 'sensor.atc_3fc4_voltage', 'sensor.temperature_humidity_sensor_ac21_battery', 'sensor.temperature_humidity_sensor_ac21_voltage', 'sensor.lumi_lumi_sensor_cube_power', 'sensor.lumi_lumi_sensor_cube_aqgl01_d92a2905_device_temperature', 'sensor.lumi_lumi_sen_ill_mgl01_power', 'sensor.lumi_lumi_sen_ill_mgl01_illuminance', 'sensor.ikea_of_sweden_tradfri_on_off_switch_46a690fe_power', 'sensor.ikea_of_sweden_tradfri_on_off_switch_06e49efe_power', 'sensor.adurolight_vms_adurolight_f604cd01_power', 'sensor.0x158d00039e2ecb_power', 'sensor.0x158d00039e2ecb_temperature', 'sensor.0x158d00039e2ecb_humidity', 'sensor.0x158d000309920a_battery', 'sensor.0x158d000309920a_illuminance', 'sensor.lumi_lumi_sensor_motion_aq2_0a920903_device_temperature', 'sensor.lumi_lumi_sensor_switch_b1115a04_power', 'sensor.lumi_lumi_sensor_switch_53115a04_power', 'sensor.lumi_lumi_sensor_swit_power', 'sensor.lumi_lumi_sensor_swit_8e46ab04_device_temperature', 'sensor.lumi_lumi_sensor_switch_31f65f03_power', 'sensor.lumi_lumi_sensor_motion_aq2_power', 'sensor.0x158d0003fac0ec_illuminance', 'sensor.lumi_lumi_sensor_motion_aq2_ecc0fa03_device_temperature', 'sensor.lumi_lumi_sens_power', 'sensor.0x158d0003931a55_temperature', 'sensor.0x158d0003931a55_humidity', 'sensor.lumi_lumi_sensor_switch_c59b5a03_power', 'sensor.0x158d0003230618_battery', 'sensor.0x158d0003230618_pressure', 'sensor.0x158d0003230618_temperature', 'sensor.0x158d0003230618_humidity', 'sensor.0x158d0003931b0e_battery', 'sensor.0x158d0003931b0e_temperature', 'sensor.0x158d0003931b0e_humidity', 'sensor.0x158d0003931aec_battery', 'sensor.0x158d0003931aec_temperature', 'sensor.0x158d0003931aec_humidity', 'sensor.lumi_lumi_sensor_switch_9efd3e03_power', 'sensor.lumi_lumi_sensor_motion_aq2_8eea4c04_power', 'sensor.0x158d00044cea8e_illuminance', 'sensor.lumi_lumi_sensor_motion_aq2_8eea4c04_device_temperature', 'sensor.lumi_lumi_sensor_magnet_power', 'sensor.lumi_lumi_sensor_magnet_673b0704_power', 'sensor.lumi_lumi_sensor_magnet_2547d503_power', 'sensor.lumi_lumi_sensor_magnet_74f99c03_power', 'sensor.lumi_th_kitchen_stove_power', 'sensor.lumi_th_kitchen_stove_temperature', 'sensor.lumi_th_kitchen_stove_humidity', 'sensor.lumi_lumi_sensor_magnet_50659603_power', 'sensor.blitzwolf_shp13_02_3ad702fe_electrical_measurement', 'sensor.blitzwolf_shp13_02_3ad702fe_electrical_measurement_rms_current', 'sensor.blitzwolf_shp13_02_3ad702fe_electrical_measurement_rms_voltage', 'sensor.tz3000_g5xawfcq_ts0121_3ad702fe_electrical_measurement_power_factor', 'sensor.lumi_lumi_sensor_switch_005dd103_power', 'sensor.lumi_lumi_sensor_motion_aq2_7b4e5f07_power', 'sensor.lumi_lumi_sensor_motion_aq2_7b4e5f07_illuminance', 'sensor.lumi_lumi_sensor_motion_aq2_7b4e5f07_device_temperature', 'sensor.lumi_lumi_sensor_magnet_724f4f04_power', 'sensor.lumi_lumi_sensor_switch_power', 'sensor.lumi_lumi_sensor_magnet_9bef9603_power', 'sensor.lumi_lumi_sensor_magnet_cd829803_power', 'sensor.lumi_lumi_sen_ill_mgl01_0d117d3c_power', 'sensor.0x4cf8cdf3c7d110d_illuminance', 'sensor.lumi_lumi_sensor_wleak_aq1_power', 'sensor.lumi_lumi_sensor_wleak_aq1_7cadd306_device_temperature', 'sensor.ikea_1_power', 'sensor.ikea_4_power', 'sensor.ikea_5_power', 'sensor.lumi_lumi_weather_power', 'sensor.lumi_lumi_weather_pressure', 'sensor.lumi_lumi_weather_temperature', 'sensor.lumi_lumi_weather_humidity', 'sensor.lumi_lumi_weather_4dad5507_power', 'sensor.lumi_lumi_weather_4dad5507_pressure', 'sensor.lumi_lumi_weather_4dad5507_temperature', 'sensor.lumi_lumi_weather_4dad5507_humidity', 'sensor.lumi_lumi_weather_bf387507_power', 'sensor.lumi_lumi_weather_bf387507_pressure', 'sensor.lumi_lumi_weather_bf387507_temperature', 'sensor.lumi_lumi_weather_bf387507_humidity', 'sensor.lumi_lumi_weather_824e9807_power', 'sensor.lumi_lumi_weather_824e9807_pressure', 'sensor.lumi_lumi_weather_824e9807_temperature', 'sensor.lumi_lumi_weather_824e9807_humidity', 'sensor.lumi_lumi_sensor_wleak_aq1_840d0304_power', 'sensor.lumi_lumi_sensor_wleak_aq1_840d0304_device_temperature', 'sensor.lumi_lumi_sensor_wleak_aq1_7de70004_power', 'sensor.lumi_lumi_sensor_wleak_aq1_7de70004_device_temperature', 'sensor.xiaomi_lumi_sen_ill_mgl01_battery', 'sensor.xiaomi_lumi_sen_ill_mgl01_illuminance', 'sensor.xiaomi_lumi_sen_ill_mgl01_battery_2', 'sensor.xiaomi_lumi_sen_ill_mgl01_illuminance_2', 'sensor.trust_battery', 'sensor.tz3000_g5xawfcq_ts0121_electricalmeasurement', 'sensor.tz3000_g5xawfcq_ts0121_electricalmeasurementrmscurrent', 'sensor.tz3000_g5xawfcq_ts0121_electricalmeasurementrmsvoltage', 'sensor.tz3000_g5xawfcq_ts0121_electricalmeasurementpowerfactor', 'sensor.blitzwolf_shp15_01_electricalmeasurement', 'sensor.blitzwolf_shp15_01_electricalmeasurementrmscurrent', 'sensor.blitzwolf_shp15_01_electricalmeasurementrmsvoltage', 'sensor.blitzwolf_shp15_01_electricalmeasurementpowerfactor', 'sensor.lumi_lumi_sensor_magnet_battery', 'sensor.lumi_lumi_sensor_magnet_devicetemperature', 'sensor.lumi_lumi_relay_c2acn01_electricalmeasurement', 'sensor.lumi_lumi_relay_c2acn01_electricalmeasurementrmsvoltage', 'sensor.lumi_lumi_relay_c2acn01_electricalmeasurementpowerfactor', 'sensor.lumi_lumi_relay_c2acn01_devicetemperature', 'sensor.tz3000_zloso4jk_ts011f_active_power', 'sensor.tz3000_zloso4jk_ts011f_rms_current', 'sensor.tz3000_zloso4jk_ts011f_rms_voltage', 'sensor.tz3000_zloso4jk_ts011f_power_factor', 'sensor.ikea_of_sweden_tradfri_on_off_switch_battery', 'sensor.ikea_3_battery_2', 'sensor.th_kukhnia_kholodilnik_niz_voltage', 'sensor.temperature_humidity_sensor_ac21_temperature', 'sensor.a4c138d358e9_humidity', 'sensor.a4c138d358e9_temperature', 'sensor.a4c138d358e9_battery', 'sensor.a4c1384e2b64_humidity', 'sensor.a4c1384e2b64_temperature', 'sensor.a4c1384e2b64_battery', 'sensor.aleksandr_body_type', 'sensor.irina_body_type', 'sensor.atc_03b4_voltage', 'sensor.atc_4e9a_voltage', 'sensor.atc_3d13_voltage', 'sensor.atc_bdae_voltage', 'sensor.atc_8716_temperature', 'sensor.atc_8716_humidity', 'sensor.atc_8716_battery', 'sensor.atc_84c8_temperature', 'sensor.atc_84c8_humidity', 'sensor.atc_84c8_battery', 'sensor.atc_7f83_voltage', 'sensor.e2c56db5_dffb_48d2_b060_d0f5a71096e0_0_0_estimated_distance', 'sensor.74278bda_b644_4520_8f0c_720eaf059935_0_124_377c_estimated_distance', 'sensor.fda50693_a4e2_4fb1_afcf_c6eb07647825_10011_2_79ae_estimated_distance', 'sensor.400225dd_3d15_4a4b_9db3_93c4b2d01eda_0_0_08ff_estimated_distance', 'sensor.389fbc46_bfb4_4d29_a089_bb5b343d069c_100_1_f15f_estimated_distance', 'sensor.74278bda_b644_4520_8f0c_720eaf059935_0_30053_6896_estimated_distance', 'sensor.74278bda_b644_4520_8f0c_720eaf059935_0_39103_20f7_estimated_distance') GROUP BY states.entity_id) AS anon_1, states LEFT OUTER JOIN state_attributes ON states.attributes_id = state_attributes.attributes_id WHERE states.state_id = anon_1.max_state_id

image

If it's a history request, how do you figure out where it comes from? I definitely don't look at the history, and my history tab is closed...

avbor commented 1 year ago

Yes, it started again - every 5 minutes rush, in mysql processes the same query:

SELECT states.entity_id, states.state, states.last_changed_ts, states.last_updated_ts, states.attributes, state_attributes.shared_attrs FROM (SELECT max(states.state_id) AS max_state_id FROM states WHERE states.last_updated_ts >= 1676356826.256737e0 AND states.last_updated_ts < 1676444999.999999e0 AND states.entity_id IN ('sensor.average_carbon_dioxide_in_flat', 'sensor.average_pm25_in_flat', 'sensor.average_pm10_in_flat', 'sensor.average_temperature_in_flat', 'sensor.average_humidity_in_flat', 'sensor.average_voltage_in_flat', 'sensor.average_voltage_in_country_house', 'sensor.country_house_avg_temp_kids_rooms', 'sensor.country_house_avg_humidity_kids_rooms', 'sensor.kitchen_stove_temperature_min_max_bt', 'sensor.kitchen_stove_temperature_min_max_mean', 'sensor.kitchen_stove_temperature_median_min_max_mean', 'sensor.kitchen_stove_temperature_median_zb', 'sensor.kitchen_stove_temperature_median_bt', 'sensor.processor_use', 'sensor.memory_use_percent', 'sensor.memory_use', 'sensor.memory_free', 'sensor.energy_flat_main_power', 'sensor.country_house_living_room_dewpoint', 'sensor.country_house_kids_room_dewpoint', 'sensor.ups_battery_charge', 'sensor.ups_battery_voltage', 'sensor.galaxy_tab_a_8_0_2019_battery', 'sensor.galaxy_tab_a_8_0_2019_internal_storage_free_space', 'sensor.galaxy_tab_a_8_0_2019_internal_storage_total_space', 'sensor.galaxy_tab_a_8_0_2019_free_memory', 'sensor.galaxy_tab_a_8_0_2019_total_memory', 'sensor.openweathermap_stupino_nivki_2_dew_point', 'sensor.openweathermap_stupino_nivki_2_temperature', 'sensor.openweathermap_stupino_nivki_2_feels_like_temperature', 'sensor.openweathermap_stupino_nivki_2_wind_speed', 'sensor.openweathermap_stupino_nivki_2_wind_bearing', 'sensor.openweathermap_stupino_nivki_2_humidity', 'sensor.openweathermap_stupino_nivki_2_pressure', 'sensor.openweathermap_stupino_nivki_2_cloud_coverage', 'sensor.openweathermap_stupino_nivki_2_rain', 'sensor.openweathermap_stupino_nivki_2_snow', 'sensor.openweathermap_stupino_nivki_2_uv_index', 'sensor.openweathermap_stupino_nivki_2_visibility', 'sensor.openweathermap_moskva_danilovskii_dew_point', 'sensor.openweathermap_moskva_danilovskii_temperature', 'sensor.openweathermap_moskva_danilovskii_feels_like_temperature', 'sensor.openweathermap_moskva_danilovskii_wind_speed', 'sensor.openweathermap_moskva_danilovskii_wind_bearing', 'sensor.openweathermap_moskva_danilovskii_humidity', 'sensor.openweathermap_moskva_danilovskii_pressure', 'sensor.openweathermap_moskva_danilovskii_cloud_coverage', 'sensor.openweathermap_moskva_danilovskii_rain', 'sensor.openweathermap_moskva_danilovskii_snow', 'sensor.openweathermap_moskva_danilovskii_uv_index', 'sensor.openweathermap_moskva_danilovskii_visibility', 'sensor.watchman_missing_entities', 'sensor.watchman_missing_services', 'sensor.aleksandr_bmi', 'sensor.aleksandr_basal_metabolism', 'sensor.aleksandr_visceral_fat', 'sensor.aleksandr_weight', 'sensor.aleksandr_lean_body_mass', 'sensor.aleksandr_body_fat', 'sensor.aleksandr_protein', 'sensor.aleksandr_water', 'sensor.aleksandr_bone_mass', 'sensor.aleksandr_muscle_mass', 'sensor.aleksandr_metabolic_age', 'sensor.aleksandr_body_score', 'sensor.irina_bmi', 'sensor.irina_basal_metabolism', 'sensor.irina_visceral_fat', 'sensor.irina_weight', 'sensor.irina_lean_body_mass', 'sensor.irina_body_fat', 'sensor.irina_protein', 'sensor.irina_water', 'sensor.irina_bone_mass', 'sensor.irina_muscle_mass', 'sensor.irina_metabolic_age', 'sensor.irina_body_score', 'sensor.egor_bmi', 'sensor.egor_basal_metabolism', 'sensor.egor_visceral_fat', 'sensor.egor_weight', 'sensor.kirill_bmi', 'sensor.kirill_basal_metabolism', 'sensor.kirill_visceral_fat', 'sensor.kirill_weight', 'sensor.kb2003_uroven_zariada_akkumuliatora', 'sensor.kb2003_datchik_osveshchionnosti', 'sensor.kb2003_skorost_soedineniia_wifi', 'sensor.kb2003_chastota_wifi', 'sensor.kb2003_moshchnost_signala_wifi', 'sensor.kb2003_battery_temperature', 'sensor.kb2003_battery_power', 'sensor.2109119dg_battery_level', 'sensor.2109119dg_battery_temperature', 'sensor.2109119dg_light_sensor', 'sensor.2109119dg_battery_power', 'sensor.sm_t295_hallway_battery_level', 'sensor.sm_t295_hallway_battery_temperature', 'sensor.sm_t295_hallway_battery_power', 'sensor.gosund_sp111_05_ampere', 'sensor.gosund_sp111_05_watt', 'sensor.gosund_sp111_06_ampere', 'sensor.gosund_sp111_06_watt', 'sensor.gosund_sp111_02_ampere', 'sensor.gosund_sp111_02_watt', 'sensor.gosund_sp111_01_ampere', 'sensor.gosund_sp111_01_watt', 'sensor.gosund_sp111_04_ampere', 'sensor.gosund_sp111_04_watt', 'sensor.gosund_sp111_08_ampere', 'sensor.gosund_sp111_08_watt', 'sensor.gosund_sp111_03_ampere', 'sensor.gosund_sp111_03_watt', 'sensor.gosund_sp111_07_ampere', 'sensor.gosund_sp111_07_watt', 'sensor.gosund_sp111_09_ampere', 'sensor.gosund_sp111_09_watt', 'sensor.gosund_sp111_10_ampere', 'sensor.gosund_sp111_10_watt', 'sensor.esp32_miscale2_01_current_weight', 'sensor.esp32_miscale2_01_current_impedance', 'sensor.0x00158d000413b210_gas_density', 'sensor.temperature_humidity_sensor_ac21_humidity', 'sensor.atc_03b4_temperature', 'sensor.atc_03b4_humidity', 'sensor.atc_03b4_battery', 'sensor.atc_3fc4_temperature', 'sensor.atc_3fc4_humidity', 'sensor.atc_3fc4_battery', 'sensor.atc_4e9a_temperature', 'sensor.atc_4e9a_humidity', 'sensor.atc_4e9a_battery', 'sensor.atc_3d13_temperature', 'sensor.atc_3d13_humidity', 'sensor.atc_3d13_battery', 'sensor.atc_bdae_temperature', 'sensor.atc_bdae_humidity', 'sensor.atc_bdae_battery', 'sensor.atc_84c8_voltage', 'sensor.th_kukhnia_za_oknom_temperature', 'sensor.th_kukhnia_za_oknom_humidity', 'sensor.th_kukhnia_za_oknom_battery', 'sensor.air_monitor_lite_cb3b_temperature', 'sensor.air_monitor_lite_cb3b_humidity', 'sensor.air_monitor_lite_cb3b_pm25', 'sensor.air_monitor_lite_cb3b_pm10', 'sensor.air_monitor_lite_cb3b_carbon_dioxide', 'sensor.air_monitor_lite_afb3_temperature', 'sensor.air_monitor_lite_afb3_humidity', 'sensor.air_monitor_lite_afb3_pm25', 'sensor.air_monitor_lite_afb3_pm10', 'sensor.air_monitor_lite_afb3_carbon_dioxide', 'sensor.air_monitor_lite_f6a7_temperature', 'sensor.air_monitor_lite_f6a7_humidity', 'sensor.air_monitor_lite_f6a7_pm25', 'sensor.air_monitor_lite_f6a7_pm10', 'sensor.air_monitor_lite_f6a7_carbon_dioxide', 'sensor.0x158d00054859d5_battery', 'sensor.0x158d000802df91_temperature', 'sensor.0x158d000802df91_humidity', 'sensor.0x158d000802df91_battery', 'sensor.0x158d000802df91_pressure', 'sensor.0x158d00040e019e_temperature', 'sensor.0x158d00040e019e_humidity', 'sensor.0x158d00040e019e_battery', 'sensor.ed5e33eb_0ca3_4263_a681_a68b1045a5e6_100_1_estimated_distance', 'sensor.fda50693_a4e2_4fb1_afcf_c6eb07647825_10011_1_2340_estimated_distance', 'sensor.tplink_smartplug_01_current_consumption', 'sensor.tplink_smartplug_01_voltage', 'sensor.tplink_smartplug_01_current', 'sensor.tplink_smartplug_02_current_consumption', 'sensor.tplink_smartplug_02_voltage', 'sensor.tplink_smartplug_02_current', 'sensor.a4c1380b3a85_temperature', 'sensor.a4c1380b3a85_humidity', 'sensor.a4c1380b3a85_battery', 'sensor.a4c138c7ded2_temperature', 'sensor.a4c138c7ded2_humidity', 'sensor.a4c138c7ded2_battery', 'sensor.atc_3fc4_voltage', 'sensor.temperature_humidity_sensor_ac21_battery', 'sensor.temperature_humidity_sensor_ac21_voltage', 'sensor.lumi_lumi_sensor_cube_power', 'sensor.lumi_lumi_sensor_cube_aqgl01_d92a2905_device_temperature', 'sensor.lumi_lumi_sen_ill_mgl01_power', 'sensor.lumi_lumi_sen_ill_mgl01_illuminance', 'sensor.ikea_of_sweden_tradfri_on_off_switch_46a690fe_power', 'sensor.ikea_of_sweden_tradfri_on_off_switch_06e49efe_power', 'sensor.adurolight_vms_adurolight_f604cd01_power', 'sensor.0x158d00039e2ecb_power', 'sensor.0x158d00039e2ecb_temperature', 'sensor.0x158d00039e2ecb_humidity', 'sensor.0x158d000309920a_battery', 'sensor.0x158d000309920a_illuminance', 'sensor.lumi_lumi_sensor_motion_aq2_0a920903_device_temperature', 'sensor.lumi_lumi_sensor_switch_b1115a04_power', 'sensor.lumi_lumi_sensor_switch_53115a04_power', 'sensor.lumi_lumi_sensor_swit_power', 'sensor.lumi_lumi_sensor_swit_8e46ab04_device_temperature', 'sensor.lumi_lumi_sensor_switch_31f65f03_power', 'sensor.lumi_lumi_sensor_motion_aq2_power', 'sensor.0x158d0003fac0ec_illuminance', 'sensor.lumi_lumi_sensor_motion_aq2_ecc0fa03_device_temperature', 'sensor.lumi_lumi_sens_power', 'sensor.0x158d0003931a55_temperature', 'sensor.0x158d0003931a55_humidity', 'sensor.lumi_lumi_sensor_switch_c59b5a03_power', 'sensor.0x158d0003230618_battery', 'sensor.0x158d0003230618_pressure', 'sensor.0x158d0003230618_temperature', 'sensor.0x158d0003230618_humidity', 'sensor.0x158d0003931b0e_battery', 'sensor.0x158d0003931b0e_temperature', 'sensor.0x158d0003931b0e_humidity', 'sensor.0x158d0003931aec_battery', 'sensor.0x158d0003931aec_temperature', 'sensor.0x158d0003931aec_humidity', 'sensor.lumi_lumi_sensor_switch_9efd3e03_power', 'sensor.lumi_lumi_sensor_motion_aq2_8eea4c04_power', 'sensor.0x158d00044cea8e_illuminance', 'sensor.lumi_lumi_sensor_motion_aq2_8eea4c04_device_temperature', 'sensor.lumi_lumi_sensor_magnet_power', 'sensor.lumi_lumi_sensor_magnet_673b0704_power', 'sensor.lumi_lumi_sensor_magnet_2547d503_power', 'sensor.lumi_lumi_sensor_magnet_74f99c03_power', 'sensor.lumi_th_kitchen_stove_power', 'sensor.lumi_th_kitchen_stove_temperature', 'sensor.lumi_th_kitchen_stove_humidity', 'sensor.lumi_lumi_sensor_magnet_50659603_power', 'sensor.blitzwolf_shp13_02_3ad702fe_electrical_measurement', 'sensor.blitzwolf_shp13_02_3ad702fe_electrical_measurement_rms_current', 'sensor.blitzwolf_shp13_02_3ad702fe_electrical_measurement_rms_voltage', 'sensor.tz3000_g5xawfcq_ts0121_3ad702fe_electrical_measurement_power_factor', 'sensor.lumi_lumi_sensor_switch_005dd103_power', 'sensor.lumi_lumi_sensor_motion_aq2_7b4e5f07_power', 'sensor.lumi_lumi_sensor_motion_aq2_7b4e5f07_illuminance', 'sensor.lumi_lumi_sensor_motion_aq2_7b4e5f07_device_temperature', 'sensor.lumi_lumi_sensor_magnet_724f4f04_power', 'sensor.lumi_lumi_sensor_switch_power', 'sensor.lumi_lumi_sensor_magnet_9bef9603_power', 'sensor.lumi_lumi_sensor_magnet_cd829803_power', 'sensor.lumi_lumi_sen_ill_mgl01_0d117d3c_power', 'sensor.0x4cf8cdf3c7d110d_illuminance', 'sensor.lumi_lumi_sensor_wleak_aq1_power', 'sensor.lumi_lumi_sensor_wleak_aq1_7cadd306_device_temperature', 'sensor.ikea_1_power', 'sensor.ikea_4_power', 'sensor.ikea_5_power', 'sensor.lumi_lumi_weather_power', 'sensor.lumi_lumi_weather_pressure', 'sensor.lumi_lumi_weather_temperature', 'sensor.lumi_lumi_weather_humidity', 'sensor.lumi_lumi_weather_4dad5507_power', 'sensor.lumi_lumi_weather_4dad5507_pressure', 'sensor.lumi_lumi_weather_4dad5507_temperature', 'sensor.lumi_lumi_weather_4dad5507_humidity', 'sensor.lumi_lumi_weather_bf387507_power', 'sensor.lumi_lumi_weather_bf387507_pressure', 'sensor.lumi_lumi_weather_bf387507_temperature', 'sensor.lumi_lumi_weather_bf387507_humidity', 'sensor.lumi_lumi_weather_824e9807_power', 'sensor.lumi_lumi_weather_824e9807_pressure', 'sensor.lumi_lumi_weather_824e9807_temperature', 'sensor.lumi_lumi_weather_824e9807_humidity', 'sensor.lumi_lumi_sensor_wleak_aq1_840d0304_power', 'sensor.lumi_lumi_sensor_wleak_aq1_840d0304_device_temperature', 'sensor.lumi_lumi_sensor_wleak_aq1_7de70004_power', 'sensor.lumi_lumi_sensor_wleak_aq1_7de70004_device_temperature', 'sensor.xiaomi_lumi_sen_ill_mgl01_battery', 'sensor.xiaomi_lumi_sen_ill_mgl01_illuminance', 'sensor.xiaomi_lumi_sen_ill_mgl01_battery_2', 'sensor.xiaomi_lumi_sen_ill_mgl01_illuminance_2', 'sensor.trust_battery', 'sensor.tz3000_g5xawfcq_ts0121_electricalmeasurement', 'sensor.tz3000_g5xawfcq_ts0121_electricalmeasurementrmscurrent', 'sensor.tz3000_g5xawfcq_ts0121_electricalmeasurementrmsvoltage', 'sensor.tz3000_g5xawfcq_ts0121_electricalmeasurementpowerfactor', 'sensor.blitzwolf_shp15_01_electricalmeasurement', 'sensor.blitzwolf_shp15_01_electricalmeasurementrmscurrent', 'sensor.blitzwolf_shp15_01_electricalmeasurementrmsvoltage', 'sensor.blitzwolf_shp15_01_electricalmeasurementpowerfactor', 'sensor.lumi_lumi_sensor_magnet_battery', 'sensor.lumi_lumi_sensor_magnet_devicetemperature', 'sensor.lumi_lumi_relay_c2acn01_electricalmeasurement', 'sensor.lumi_lumi_relay_c2acn01_electricalmeasurementrmsvoltage', 'sensor.lumi_lumi_relay_c2acn01_electricalmeasurementpowerfactor', 'sensor.lumi_lumi_relay_c2acn01_devicetemperature', 'sensor.tz3000_zloso4jk_ts011f_active_power', 'sensor.tz3000_zloso4jk_ts011f_rms_current', 'sensor.tz3000_zloso4jk_ts011f_rms_voltage', 'sensor.tz3000_zloso4jk_ts011f_power_factor', 'sensor.ikea_of_sweden_tradfri_on_off_switch_battery', 'sensor.ikea_3_battery_2', 'sensor.th_kukhnia_kholodilnik_niz_voltage', 'sensor.temperature_humidity_sensor_ac21_temperature', 'sensor.a4c138d358e9_humidity', 'sensor.a4c138d358e9_temperature', 'sensor.a4c138d358e9_battery', 'sensor.a4c1384e2b64_humidity', 'sensor.a4c1384e2b64_temperature', 'sensor.a4c1384e2b64_battery', 'sensor.aleksandr_body_type', 'sensor.irina_body_type', 'sensor.atc_03b4_voltage', 'sensor.atc_4e9a_voltage', 'sensor.atc_3d13_voltage', 'sensor.atc_bdae_voltage', 'sensor.atc_8716_temperature', 'sensor.atc_8716_humidity', 'sensor.atc_8716_battery', 'sensor.atc_84c8_temperature', 'sensor.atc_84c8_humidity', 'sensor.atc_84c8_battery', 'sensor.atc_7f83_voltage', 'sensor.e2c56db5_dffb_48d2_b060_d0f5a71096e0_0_0_estimated_distance', 'sensor.74278bda_b644_4520_8f0c_720eaf059935_0_124_377c_estimated_distance', 'sensor.fda50693_a4e2_4fb1_afcf_c6eb07647825_10011_2_79ae_estimated_distance', 'sensor.400225dd_3d15_4a4b_9db3_93c4b2d01eda_0_0_08ff_estimated_distance', 'sensor.389fbc46_bfb4_4d29_a089_bb5b343d069c_100_1_f15f_estimated_distance', 'sensor.74278bda_b644_4520_8f0c_720eaf059935_0_30053_6896_estimated_distance', 'sensor.74278bda_b644_4520_8f0c_720eaf059935_0_39103_20f7_estimated_distance') GROUP BY states.entity_id) AS anon_1, states LEFT OUTER JOIN state_attributes ON states.attributes_id = state_attributes.attributes_id WHERE states.state_id = anon_1.max_state_id

image image

@bdraco Do you have any idea what could be causing this behavior?

bdraco commented 1 year ago

Tue Feb 14 2023 06:40:26 GMT+0000 - Wed Feb 15 2023 07:09:59 GMT+0000 is the time window. There isn't anything in HA that I can think of that would select data like that to compile stats.

avbor commented 1 year ago

Tue Feb 14 2023 06:40:26 GMT+0000 - Wed Feb 15 2023 07:09:59 GMT+0000 is the time window. There isn't anything in HA that I can think of that would select data like that to compile stats.

It is strange, in addition, the time and date in this query changes:

Sunday, 12 February 2023 г., 10:40:03.071 - Monday, 13 February 2023 г., 13:49:59.999 https://github.com/home-assistant/core/issues/87851#issuecomment-1427986325 and Tuesday, 14 February 2023 г., 6:40:26.256 - Wednesday, 15 February 2023 г., 7:09:59.999 https://github.com/home-assistant/core/issues/87851#issuecomment-1430813029

But the period is always the same. And yes, the period is strange, too.

bdraco commented 1 year ago

I had a chance to run though this a bit more and opened a few PRs to optimize things a bit that you can see mentioned above.

I think the key is going to be finding the source of the multi-day history query.

I'd probably logout every device out and add them back one by one in case its something hitting on the frontend.

avbor commented 1 year ago

I think the key is going to be finding the source of the multi-day history query.

Yes, only I have absolutely no idea how to find this request.

I'd probably logout every device out and add them back one by one in case its something hitting on the frontend.

Logout from web interface and HA apps? I will try.

avbor commented 1 year ago

I re-logged on all devices and browsers, deleted the cache, but it did not help: image

SELECT states.entity_id, states.state, states.last_changed_ts, states.last_updated_ts, states.attributes, state_attributes.shared_attrs FROM (SELECT max(states.state_id) AS max_state_id FROM states WHERE states.last_updated_ts >= 1676622590.438751e0 AND states.last_updated_ts < 1676804099.999999e0 AND states.entity_id IN ('sensor.average_carbon_dioxide_in_flat', 'sensor.average_pm25_in_flat', 'sensor.average_pm10_in_flat', 'sensor.average_temperature_in_flat', 'sensor.average_humidity_in_flat', 'sensor.average_voltage_in_flat', 'sensor.average_voltage_in_country_house', 'sensor.country_house_avg_temp_kids_rooms', 'sensor.country_house_avg_humidity_kids_rooms', 'sensor.energy_flat_main_power', 'sensor.kitchen_stove_temperature_min_max_bt', 'sensor.kitchen_stove_temperature_min_max_mean', 'sensor.kitchen_stove_temperature_median_min_max_mean', 'sensor.kitchen_stove_temperature_median_zb', 'sensor.kitchen_stove_temperature_median_bt', 'sensor.processor_use', 'sensor.memory_use_percent', 'sensor.memory_use', 'sensor.memory_free', 'sensor.country_house_living_room_dewpoint', 'sensor.country_house_kids_room_dewpoint', 'sensor.openweathermap_moskva_danilovskii_dew_point', 'sensor.openweathermap_moskva_danilovskii_temperature', 'sensor.openweathermap_moskva_danilovskii_feels_like_temperature', 'sensor.openweathermap_moskva_danilovskii_wind_speed', 'sensor.openweathermap_moskva_danilovskii_wind_bearing', 'sensor.openweathermap_moskva_danilovskii_humidity', 'sensor.openweathermap_moskva_danilovskii_pressure', 'sensor.openweathermap_moskva_danilovskii_cloud_coverage', 'sensor.openweathermap_moskva_danilovskii_rain', 'sensor.openweathermap_moskva_danilovskii_snow', 'sensor.openweathermap_moskva_danilovskii_uv_index', 'sensor.openweathermap_moskva_danilovskii_visibility', 'sensor.openweathermap_stupino_nivki_2_dew_point', 'sensor.openweathermap_stupino_nivki_2_temperature', 'sensor.openweathermap_stupino_nivki_2_feels_like_temperature', 'sensor.openweathermap_stupino_nivki_2_wind_speed', 'sensor.openweathermap_stupino_nivki_2_wind_bearing', 'sensor.openweathermap_stupino_nivki_2_humidity', 'sensor.openweathermap_stupino_nivki_2_pressure', 'sensor.openweathermap_stupino_nivki_2_cloud_coverage', 'sensor.openweathermap_stupino_nivki_2_rain', 'sensor.openweathermap_stupino_nivki_2_snow', 'sensor.openweathermap_stupino_nivki_2_uv_index', 'sensor.openweathermap_stupino_nivki_2_visibility', 'sensor.watchman_missing_entities', 'sensor.watchman_missing_services', 'sensor.aleksandr_bmi', 'sensor.aleksandr_basal_metabolism', 'sensor.aleksandr_visceral_fat', 'sensor.aleksandr_weight', 'sensor.aleksandr_lean_body_mass', 'sensor.aleksandr_body_fat', 'sensor.aleksandr_protein', 'sensor.aleksandr_water', 'sensor.aleksandr_bone_mass', 'sensor.aleksandr_muscle_mass', 'sensor.aleksandr_metabolic_age', 'sensor.aleksandr_body_score', 'sensor.irina_bmi', 'sensor.irina_basal_metabolism', 'sensor.irina_visceral_fat', 'sensor.irina_weight', 'sensor.irina_lean_body_mass', 'sensor.irina_body_fat', 'sensor.irina_protein', 'sensor.irina_water', 'sensor.irina_bone_mass', 'sensor.irina_muscle_mass', 'sensor.irina_metabolic_age', 'sensor.irina_body_score', 'sensor.egor_bmi', 'sensor.egor_basal_metabolism', 'sensor.egor_visceral_fat', 'sensor.egor_weight', 'sensor.kirill_bmi', 'sensor.kirill_basal_metabolism', 'sensor.kirill_visceral_fat', 'sensor.kirill_weight', 'sensor.ups_battery_charge', 'sensor.ups_battery_voltage', 'sensor.galaxy_tab_a_8_0_2019_battery', 'sensor.galaxy_tab_a_8_0_2019_internal_storage_free_space', 'sensor.galaxy_tab_a_8_0_2019_internal_storage_total_space', 'sensor.galaxy_tab_a_8_0_2019_free_memory', 'sensor.galaxy_tab_a_8_0_2019_total_memory', 'sensor.tplink_smartplug_02_current_consumption', 'sensor.tplink_smartplug_02_voltage', 'sensor.tplink_smartplug_02_current', 'sensor.tplink_smartplug_01_current_consumption', 'sensor.tplink_smartplug_01_voltage', 'sensor.tplink_smartplug_01_current', 'sensor.2109119dg_battery_temperature', 'sensor.2109119dg_light_sensor', 'sensor.2109119dg_battery_power', 'sensor.sm_t295_hallway_battery_level', 'sensor.sm_t295_hallway_battery_power', 'sensor.sm_t295_hallway_battery_temperature', 'sensor.kb2003_battery_level', 'sensor.kb2003_battery_temperature', 'sensor.kb2003_battery_power', 'sensor.kb2003_light_sensor', 'sensor.kb2003_wifi_link_speed', 'sensor.kb2003_wifi_frequency', 'sensor.kb2003_wifi_signal_strength', 'sensor.gosund_sp111_01_ampere', 'sensor.gosund_sp111_01_watt', 'sensor.gosund_sp111_02_ampere', 'sensor.gosund_sp111_02_watt', 'sensor.gosund_sp111_06_ampere', 'sensor.gosund_sp111_06_watt', 'sensor.gosund_sp111_05_ampere', 'sensor.gosund_sp111_05_watt', 'sensor.gosund_sp111_04_ampere', 'sensor.gosund_sp111_04_watt', 'sensor.gosund_sp111_07_ampere', 'sensor.gosund_sp111_07_watt', 'sensor.gosund_sp111_03_ampere', 'sensor.gosund_sp111_03_watt', 'sensor.gosund_sp111_08_ampere', 'sensor.gosund_sp111_08_watt', 'sensor.gosund_sp111_09_ampere', 'sensor.gosund_sp111_09_watt', 'sensor.esp32_miscale2_01_current_weight', 'sensor.esp32_miscale2_01_current_impedance', 'sensor.gosund_sp111_10_ampere', 'sensor.gosund_sp111_10_watt', 'sensor.temperature_humidity_sensor_ac21_humidity', 'sensor.air_monitor_lite_cb3b_temperature', 'sensor.air_monitor_lite_cb3b_humidity', 'sensor.air_monitor_lite_cb3b_pm25', 'sensor.air_monitor_lite_cb3b_pm10', 'sensor.air_monitor_lite_cb3b_carbon_dioxide', 'sensor.air_monitor_lite_afb3_temperature', 'sensor.air_monitor_lite_afb3_humidity', 'sensor.air_monitor_lite_afb3_pm25', 'sensor.air_monitor_lite_afb3_pm10', 'sensor.air_monitor_lite_afb3_carbon_dioxide', 'sensor.air_monitor_lite_f6a7_temperature', 'sensor.air_monitor_lite_f6a7_humidity', 'sensor.air_monitor_lite_f6a7_pm25', 'sensor.air_monitor_lite_f6a7_pm10', 'sensor.air_monitor_lite_f6a7_carbon_dioxide', 'sensor.atc_03b4_temperature', 'sensor.atc_03b4_humidity', 'sensor.atc_03b4_battery', 'sensor.atc_3fc4_temperature', 'sensor.atc_3fc4_humidity', 'sensor.atc_3fc4_battery', 'sensor.atc_4e9a_temperature', 'sensor.atc_4e9a_humidity', 'sensor.atc_4e9a_battery', 'sensor.atc_3d13_voltage', 'sensor.atc_bdae_temperature', 'sensor.atc_bdae_humidity', 'sensor.atc_bdae_battery', 'sensor.atc_8716_temperature', 'sensor.atc_8716_humidity', 'sensor.atc_8716_battery', 'sensor.atc_84c8_temperature', 'sensor.atc_84c8_humidity', 'sensor.atc_84c8_battery', 'sensor.th_kukhnia_za_oknom_temperature', 'sensor.th_kukhnia_za_oknom_humidity', 'sensor.th_kukhnia_za_oknom_battery', 'sensor.0x00158d000413b210_gas_density', 'sensor.0x158d00054859d5_battery', 'sensor.0x158d000802df91_temperature', 'sensor.0x158d000802df91_humidity', 'sensor.0x158d000802df91_battery', 'sensor.0x158d000802df91_pressure', 'sensor.0x158d00040e019e_temperature', 'sensor.0x158d00040e019e_humidity', 'sensor.0x158d00040e019e_battery', 'sensor.a4c1380b3a85_temperature', 'sensor.a4c1380b3a85_humidity', 'sensor.a4c1380b3a85_battery', 'sensor.a4c138c7ded2_temperature', 'sensor.a4c138c7ded2_humidity', 'sensor.a4c138c7ded2_battery', 'sensor.temperature_humidity_sensor_ac21_temperature', 'sensor.lumi_lumi_sensor_cube_power', 'sensor.lumi_lumi_sensor_cube_aqgl01_d92a2905_device_temperature', 'sensor.lumi_lumi_sen_ill_mgl01_power', 'sensor.lumi_lumi_sen_ill_mgl01_illuminance', 'sensor.ikea_of_sweden_tradfri_on_off_switch_46a690fe_power', 'sensor.ikea_of_sweden_tradfri_on_off_switch_06e49efe_power', 'sensor.adurolight_vms_adurolight_f604cd01_power', 'sensor.0x158d00039e2ecb_power', 'sensor.0x158d00039e2ecb_temperature', 'sensor.0x158d00039e2ecb_humidity', 'sensor.0x158d000309920a_battery', 'sensor.0x158d000309920a_illuminance', 'sensor.lumi_lumi_sensor_motion_aq2_0a920903_device_temperature', 'sensor.lumi_lumi_sensor_switch_b1115a04_power', 'sensor.lumi_lumi_sensor_switch_53115a04_power', 'sensor.lumi_lumi_sensor_swit_power', 'sensor.lumi_lumi_sensor_swit_8e46ab04_device_temperature', 'sensor.lumi_lumi_sensor_switch_31f65f03_power', 'sensor.lumi_lumi_sensor_motion_aq2_power', 'sensor.0x158d0003fac0ec_illuminance', 'sensor.lumi_lumi_sensor_motion_aq2_ecc0fa03_device_temperature', 'sensor.lumi_lumi_sens_power', 'sensor.0x158d0003931a55_temperature', 'sensor.0x158d0003931a55_humidity', 'sensor.lumi_lumi_sensor_switch_c59b5a03_power', 'sensor.0x158d0003230618_battery', 'sensor.0x158d0003230618_pressure', 'sensor.0x158d0003230618_temperature', 'sensor.0x158d0003230618_humidity', 'sensor.0x158d0003931b0e_battery', 'sensor.0x158d0003931b0e_temperature', 'sensor.0x158d0003931b0e_humidity', 'sensor.0x158d0003931aec_battery', 'sensor.0x158d0003931aec_temperature', 'sensor.0x158d0003931aec_humidity', 'sensor.lumi_lumi_sensor_switch_9efd3e03_power', 'sensor.lumi_lumi_sensor_motion_aq2_8eea4c04_power', 'sensor.0x158d00044cea8e_illuminance', 'sensor.lumi_lumi_sensor_motion_aq2_8eea4c04_device_temperature', 'sensor.lumi_lumi_sensor_magnet_power', 'sensor.lumi_lumi_sensor_magnet_673b0704_power', 'sensor.lumi_lumi_sensor_magnet_2547d503_power', 'sensor.lumi_lumi_sensor_magnet_74f99c03_power', 'sensor.lumi_th_kitchen_stove_power', 'sensor.lumi_th_kitchen_stove_temperature', 'sensor.lumi_th_kitchen_stove_humidity', 'sensor.lumi_lumi_sensor_magnet_50659603_power', 'sensor.blitzwolf_shp13_02_3ad702fe_electrical_measurement', 'sensor.blitzwolf_shp13_02_3ad702fe_electrical_measurement_rms_current', 'sensor.blitzwolf_shp13_02_3ad702fe_electrical_measurement_rms_voltage', 'sensor.tz3000_g5xawfcq_ts0121_3ad702fe_electrical_measurement_power_factor', 'sensor.lumi_lumi_sensor_switch_005dd103_power', 'sensor.lumi_lumi_sensor_motion_aq2_7b4e5f07_power', 'sensor.lumi_lumi_sensor_motion_aq2_7b4e5f07_illuminance', 'sensor.lumi_lumi_sensor_motion_aq2_7b4e5f07_device_temperature', 'sensor.lumi_lumi_sensor_magnet_724f4f04_power', 'sensor.lumi_lumi_sensor_switch_power', 'sensor.lumi_lumi_sensor_magnet_9bef9603_power', 'sensor.lumi_lumi_sensor_magnet_cd829803_power', 'sensor.lumi_lumi_sen_ill_mgl01_0d117d3c_power', 'sensor.0x4cf8cdf3c7d110d_illuminance', 'sensor.lumi_lumi_sensor_wleak_aq1_power', 'sensor.lumi_lumi_sensor_wleak_aq1_7cadd306_device_temperature', 'sensor.ikea_1_power', 'sensor.ikea_4_power', 'sensor.ikea_5_power', 'sensor.lumi_lumi_weather_power', 'sensor.lumi_lumi_weather_pressure', 'sensor.lumi_lumi_weather_temperature', 'sensor.lumi_lumi_weather_humidity', 'sensor.lumi_lumi_weather_4dad5507_power', 'sensor.lumi_lumi_weather_4dad5507_pressure', 'sensor.lumi_lumi_weather_4dad5507_temperature', 'sensor.lumi_lumi_weather_4dad5507_humidity', 'sensor.lumi_lumi_weather_bf387507_power', 'sensor.lumi_lumi_weather_bf387507_pressure', 'sensor.lumi_lumi_weather_bf387507_temperature', 'sensor.lumi_lumi_weather_bf387507_humidity', 'sensor.lumi_lumi_weather_824e9807_power', 'sensor.lumi_lumi_weather_824e9807_pressure', 'sensor.lumi_lumi_weather_824e9807_temperature', 'sensor.lumi_lumi_weather_824e9807_humidity', 'sensor.lumi_lumi_sensor_wleak_aq1_840d0304_power', 'sensor.lumi_lumi_sensor_wleak_aq1_840d0304_device_temperature', 'sensor.lumi_lumi_sensor_wleak_aq1_7de70004_power', 'sensor.lumi_lumi_sensor_wleak_aq1_7de70004_device_temperature', 'sensor.xiaomi_lumi_sen_ill_mgl01_battery', 'sensor.xiaomi_lumi_sen_ill_mgl01_illuminance', 'sensor.xiaomi_lumi_sen_ill_mgl01_battery_2', 'sensor.xiaomi_lumi_sen_ill_mgl01_illuminance_2', 'sensor.trust_battery', 'sensor.tz3000_g5xawfcq_ts0121_electricalmeasurement', 'sensor.tz3000_g5xawfcq_ts0121_electricalmeasurementrmscurrent', 'sensor.tz3000_g5xawfcq_ts0121_electricalmeasurementrmsvoltage', 'sensor.tz3000_g5xawfcq_ts0121_electricalmeasurementpowerfactor', 'sensor.blitzwolf_shp15_01_electricalmeasurement', 'sensor.blitzwolf_shp15_01_electricalmeasurementrmscurrent', 'sensor.blitzwolf_shp15_01_electricalmeasurementrmsvoltage', 'sensor.blitzwolf_shp15_01_electricalmeasurementpowerfactor', 'sensor.lumi_lumi_sensor_magnet_battery', 'sensor.lumi_lumi_sensor_magnet_devicetemperature', 'sensor.lumi_lumi_relay_c2acn01_electricalmeasurement', 'sensor.lumi_lumi_relay_c2acn01_electricalmeasurementrmsvoltage', 'sensor.lumi_lumi_relay_c2acn01_electricalmeasurementpowerfactor', 'sensor.lumi_lumi_relay_c2acn01_devicetemperature', 'sensor.tz3000_zloso4jk_ts011f_active_power', 'sensor.tz3000_zloso4jk_ts011f_rms_current', 'sensor.tz3000_zloso4jk_ts011f_rms_voltage', 'sensor.tz3000_zloso4jk_ts011f_power_factor', 'sensor.ikea_of_sweden_tradfri_on_off_switch_battery', 'sensor.ikea_3_battery_2', 'sensor.temperature_humidity_sensor_ac21_battery', 'sensor.temperature_humidity_sensor_ac21_voltage', 'sensor.a4c138d358e9_humidity', 'sensor.a4c138d358e9_temperature', 'sensor.a4c138d358e9_battery', 'sensor.a4c1384e2b64_humidity', 'sensor.a4c1384e2b64_temperature', 'sensor.a4c1384e2b64_battery', 'sensor.aleksandr_body_type', 'sensor.irina_body_type', 'sensor.atc_03b4_voltage', 'sensor.atc_3fc4_voltage', 'sensor.atc_4e9a_voltage', 'sensor.atc_3d13_temperature', 'sensor.atc_3d13_humidity', 'sensor.atc_3d13_battery', 'sensor.atc_bdae_voltage', 'sensor.th_kukhnia_kholodilnik_niz_voltage', 'sensor.atc_84c8_voltage', 'sensor.atc_7f83_voltage') GROUP BY states.entity_id) AS anon_1, states LEFT OUTER JOIN state_attributes ON states.attributes_id = state_attributes.attributes_id WHERE states.state_id = anon_1.max_state_id

Query period: from Friday, 17 February 2023 г., 8:29:50.438 to Sunday, 19 February 2023 г., 10:54:59.999 Again some random, more than two days...

HA uptime for now ~2 days.

avbor commented 1 year ago

After some time query period changed: from Friday, 17 February 2023 г., 8:29:50.438 to Sunday, 19 February 2023 г., 11:09:59.999

avbor commented 1 year ago

I also noticed that the first date in the query is very close to the time of the last HA boot: image

query from Friday, 17 February 2023 г., 8:29:50.438 startup time 2023-02-17T08:29:57+00:00

avbor commented 1 year ago

Some more time later, query: from Friday, 17 February 2023 г., 8:29:50.438 to Sunday, 19 February 2023 г., 11:44:59.999

As far as I can see, something in HA runs a query every 5 minutes, selecting a range of entities, with the sampling period constantly expanding. That is, an hour after HA starts, the query only selects data for an hour (and it happens quickly and without any visible load), and a two days after HA starts it selects data for the whole two days, which is already becoming noticeable. This can explain the fact that a noticeable load appears only after a few days. But I still can't figure out how to find what creates these queries... @bdraco I really hope for your help =)