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
74.04k stars 31.07k forks source link

MQTT sensor cause crash with Client exceeded max pending messages #42150

Closed shajek closed 3 years ago

shajek commented 4 years ago

The problem

When i add MQTT sensors (with discovery), which add arround 30sensors, HA just give up and throw error (above), after restart HA, it try load all sensors, but it end again with "Client exceeded max pending messages". When i turn off that sensor, restart HA, it works again, but when i turn on sensor, it crash ....

Environment

Problem-relevant configuration.yaml

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

frontend:
  themes: !include_dir_merge_named themes

discovery:

yeelight:
  devices:
    192.168.88.12:
      name: Zachod
      model: ceiling4
    192.168.88.10:
      name: Obyvacka
      model: ceiling4
    192.168.88.11:
      name: Spalna
      model: ceiling4
    192.168.88.14:
      name: Izba ulica
      model: ceiling4
    192.168.88.13:
      name: Izba terasa
      model: ceiling4

switch:
  - platform: mqtt
    name: "S55 Switch"
    state_topic: "stat/tasmota_BF9D3A/RESULT"  
    value_template: "{{ value_json.POWER }}"
    command_topic: "cmnd/tasmota_BF9D3A/POWER"
    payload_on: "ON"
    payload_off: "OFF"
    availability_topic: "tele/tasmota_BF9D3A/LWT"
    payload_available: "Online"
    payload_not_available: "Offline"
    qos: 1
    retain: false
  - platform: mqtt
    name: "Zvonek cez computer"
    command_topic: "cmnd/RF_Bridge/rfcode"
    payload_on: "#434BD1"
    payload_off: "#434BD1"

sensor szabinka work:
  - platform: mqtt
    name: "Teplota vzduchu Szabinka work"
    state_topic: "tele/D1miniSzabinkaWork/SENSOR"
    unit_of_measurement: '°C'
    value_template: "{{ value_json.BME280.Temperature }}"
  - platform: mqtt
    name: "Vlhkost vzduchu Szabinka work"
    state_topic: "tele/D1miniSzabinkaWork/SENSOR"
    unit_of_measurement: '%'
    value_template: "{{ value_json.BME280.Humidity }}"
  - platform: mqtt
    name: "Tlak vzduchu Szabinka work"
    state_topic: "tele/D1miniSzabinkaWork/SENSOR"
    unit_of_measurement: 'hPa'
    value_template: "{{ value_json.BME280.SeaPressure }}"
  - platform: mqtt
    name: "Rosny bod Szabinka work"
    state_topic: "tele/D1miniSzabinkaWork/SENSOR"
    unit_of_measurement: '°C'
    value_template: "{{ value_json.BME280.DewPoint }}"
  - platform: mqtt
    name: "CO2 Szabinka work"
    state_topic: "tele/D1miniSzabinkaWork/SENSOR"
    unit_of_measurement: 'ppm'
    value_template: "{{ value_json.MHZ19B.CarbonDioxide }}" 

sensor PMsensor:
  - platform: mqtt
    name: "PM2.5 sensor"
    state_topic: "tele/D1miniPMsensor/SENSOR"
    value_template: "{{ value_json['SDS0X1']['PM2.5'] }}"
    unit_of_measurement: "µg/m³"
  - platform: mqtt
    name: "PM10 sensor"
    state_topic: "tele/D1miniPMsensor/SENSOR"
    value_template: "{{ value_json.SDS0X1.PM10 }}"
    unit_of_measurement: "µg/m³"

mysensors:
  gateways:
    - device: mqtt
      persistence_file: 'mysensors_miloslavov.json'
      topic_in_prefix: 'miloslavov-nrfgateway-out'
      topic_out_prefix: 'miloslavov-nrfgateway-in'
  optimistic: false
  persistence: true
  retain: true
  version: '2.3'

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

Traceback/Error logs

2020-10-20 23:00:24 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140530573380768] Client exceeded max pending messages [2]: 2048
2020-10-20 23:00:24 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140530573380768] Client exceeded max pending messages [2]: 2048
2020-10-20 23:00:24 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140530573380768] Client exceeded max pending messages [2]: 2048
2020-10-20 23:00:24 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140530573380768] Client exceeded max pending messages [2]: 2048
2020-10-20 23:00:24 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140530573380768] Client exceeded max pending messages [2]: 2048
2020-10-20 23:00:24 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140530573380768] Client exceeded max pending messages [2]: 2048
2020-10-20 23:00:24 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140530573380768] Client exceeded max pending messages [2]: 2048
2020-10-20 23:00:24 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140530573380768] Client exceeded max pending messages [2]: 2048 

Additional information

here is example of discovery message:

{"name":"Grid frequency","stat_t":"tele/MGWmiloslavov-6695731/STATUS","avty_t":"tele/MGWmiloslavov-6695731/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"6695731_Grid_frequency","dev":{"ids":["6695731"]},"unit_of_meas":"Hz","frc_upd":true,"val_tpl":"{{value_json['5008']['value']}}"}
{"name":"L2 Power factor","stat_t":"tele/MGWmiloslavov-6695731/STATUS","avty_t":"tele/MGWmiloslavov-6695731/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"6695731_L2_Power_factor","dev":{"ids":["6695731"]},"unit_of_meas":" ","dev_cla":"power_factor","frc_upd":true,"val_tpl":"{{value_json['502e']['value']}}"}

and here is status message from MQTT:

{"sensor":"Modbus GW","4003":{"name":"Modbus ID","value":1,"units":" "},"5002":{"name":"L1 Voltage","value":239.7,"units":"V"},"5004":{"name":"L2 Voltage","value":238.1,"units":"V"},"5006":{"name":"L3 Voltage","value":239.7,"units":"V"},"5008":{"name":"Grid frequency","value":50,"units":"Hz"},"500c":{"name":"L1 Current","value":1.02,"units":"A"},"500e":{"name":"L2 Current","value":2.87,"units":"A"},"5010":{"name":"L3 Current","value":0.42,"units":"A"},"5014":{"name":"L1 Active power","value":0.108,"units":"kW"},"5016":{"name":"L2 Active power","value":0.562,"units":"kW"},"5018":{"name":"L3 Active power","value":0.072,"units":"kW"},"501c":{"name":"L1 Reactive power","value":-0.214,"units":"kvar"},"501e":{"name":"L2 Reactive power","value":-0.311,"units":"kvar"},"5020":{"name":"L3 Reactive power","value":-0.069,"units":"kvar"},"5024":{"name":"L1 Apparent power","value":0.239,"units":"kVA"},"5026":{"name":"L2 Apparent Power","value":0.632,"units":"kVA"},"5028":{"name":"L3 Apparent Power","value":0.1,"units":"kVA"},"502c":{"name":"L1 Power factor","value":0.45,"units":" "},"502e":{"name":"L2 Power factor","value":0.87,"units":" "},"5030":{"name":"L3 Power factor","value":0.72,"units":" "},"6006":{"name":"L1 Total active energy","value":927.94,"units":"kWh"},"6008":{"name":"L2 Total active energy","value":812.96,"units":"kWh"},"600a":{"name":"L3 Total active energy","value":204.57,"units":"kWh"},"602a":{"name":"L1 Total reactive energy","value":56.75,"units":"kvarh"},"602c":{"name":"L2 Total reactive energy","value":12.01,"units":"kvarh"},"602e":{"name":"L3 Total reactive energy","value":0.65,"units":"kvarh"},"6048":{"name":"Tariff","value":1,"units":""},"6049":{"name":"Resetable day counter","value":1944.71,"units":"kWh"}}
probot-home-assistant[bot] commented 4 years ago

Hey there @home-assistant/core, @emontnemery, mind taking a look at this issue as its been labeled with an integration (mqtt) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

shajek commented 4 years ago

I try report period 1min,2min,10min ... nothing helps

emontnemery commented 4 years ago

I can't reproduce your problem, please enable debug logging of core + MQTT, and attach a log starting with HA startup and until you see the Client exceeded max pending messages errors.

logger:
   default: info
   logs:
     homeassistant.core: debug
     homeassistant.components.mqtt: debug
shajek commented 4 years ago

With debug settings i either dont see any error. But HA still doesnt load and stay unresponsive. Here is cut from the log (because of pastebin) https://pastebin.com/LSJeT290

(PS: as i say, i try it on fresh clean install on HassOS, supervisor, or pure core ... the same problem, i delete all custom componets and HACS, no change)

emontnemery commented 4 years ago

If you zip the log, you can drag and drop it when editing a GitHub comment.

emontnemery commented 4 years ago

The log you uploaded to pastebin only spans 7 seconds, and does not include any received state message from the modbus sensor.

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.