QNAP integration error on network

Recently I discovered, that trying to get bandwidth data from my qnap devices is not working anymore. I’m not sure, if it is a problem cuased by qnap or the integration, as I updated both recently.

Reading

  • status
  • cpu_usage
  • cpu_temp
  • memory_percent_used
  • volume_percentage_used
  • system_temp
  • drive_smart_status

seems to work without error, however trying to get

  • network_tx
  • network_rx
    result in an error.

The HA log shows:

Failed to fetch QNAP stats from the NAS
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/qnap/sensor.py", line 197, in update
    self.data["bandwidth"] = self._api.get_bandwidth()
  File "/usr/local/lib/python3.8/site-packages/qnapstats/qnap_stats.py", line 290, in get_bandwidth
    default = resp["bandwidth_info"]["df_gateway"]
KeyError: 'bandwidth_info'

and

- Error adding entities for domain sensor with platform qnap
- Error while setting up qnap platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 383, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 588, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 615, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 368, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 402, in _async_write_ha_state
    state = self._stringify_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 374, in _stringify_state
    state = self.state
  File "/usr/src/homeassistant/homeassistant/components/qnap/sensor.py", line 288, in state
    data = self._api.data["bandwidth"][self.monitor_device]
KeyError: 'bandwidth'

My config is:

- platform: qnap
  host: !secret qnap_host
  port: 443
  ssl: true
  verify_ssl: false
  username: !secret qnap_user
  password: !secret qnap_passwd
  nics: eth4
  monitored_conditions:
    - status
    - cpu_usage
    - cpu_temp
    - memory_percent_used
    - network_tx
    - network_rx
    - volume_percentage_used
    - system_temp
    - drive_smart_status

Even if I omit “nics: eth4” I do not get any network card listed.

1 Like

Same story, but qnapstats did not work even without: network_tx, network_rx
QNAP: TS-453Be. firmware 4.5.4.1715
Config:

sensor:
  - platform: qnap
    host: 192.168.xx.xx
    ssl: true
    verify_ssl: false
    port: 443
    username: !secret qnap_acc
    password: !secret qnap_pass
    monitored_conditions:
      - status
      - cpu_usage
      - cpu_temp
      - memory_percent_used
      - volume_percentage_used
      - drive_smart_status
      - drive_temp

looks like this issue:

I had the same issue. Removing the not working network section (nics: eth4 and network_tx and network_rx) and doing a reboot solved the issue for me. I still get all stats, like temperature, volume percentage used, etc. Only the network bandwidth shows an error.

Maybe logging on to the qnap with the homeassistant account on the qnap web-interface and accepting all the popup information helps.