Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZeroDivisionError: float division by zero #2386

Open
MaRmARk0 opened this issue Feb 24, 2025 · 0 comments
Open

ZeroDivisionError: float division by zero #2386

MaRmARk0 opened this issue Feb 24, 2025 · 0 comments

Comments

@MaRmARk0
Copy link

Device model / 设备型号

n/a

Component version / 插件版本

1.0.12

HA core version / HA版本

2024.12.4

Integrated mode / 集成方式

Automatic (自动模式)

The problem / 问题详情

After last update one of my purifiers just stopped working. Others are OK, just the first is shown as Unavailable.

2025-02-21 13:35:50.250 ERROR (MainThread) [custom_components.xiaomi_miot.core.device.zhimi.airpurifier.mc1] Unexpected error fetching 04:cf:8c:f1:9e:b1-9da16b14b0cff6dd592fcc3c885d7ec6-chunk_2 data
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 631, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2733, in _render_with_context
    return template.render(**kwargs)
           ~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/jinja2/environment.py", line 1304, in render
    self.environment.handle_exception()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/jinja2/environment.py", line 939, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
ZeroDivisionError: float division by zero

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 379, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 280, in _async_update_data
    return await self.update_method()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/xiaomi_miot/core/device.py", line 530, in _update
    result = await self.update_miot_status(mapping)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/xiaomi_miot/core/device.py", line 852, in update_miot_status
    results = await self.miio2miot.async_get_miot_props(self.local, mapping)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/xiaomi_miot/core/miio2miot.py", line 112, in async_get_miot_props
    return await self.hass.async_add_executor_job(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        partial(self.get_miot_props, *args, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/xiaomi_miot/core/miio2miot.py", line 135, in get_miot_props
    val = tpl.render({
        'value': val,
    ...<5 lines>...
        'description': prop.list_description(val) if prop.value_list else None,
    })
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 599, in render
    ).result()
      ~~~~~~^^
  File "/usr/local/lib/python3.13/concurrent/futures/_base.py", line 456, in result
    return self.__get_result()
           ~~~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/src/homeassistant/homeassistant/util/async_.py", line 68, in run_callback
    future.set_result(callback(*args))
                      ~~~~~~~~^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 633, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: ZeroDivisionError: float division by zero

Entity attributes / 实体属性

icon: mdi:information
device_class: update
friendly_name: Mi Air Purifier 2S Info
info: Mi Air Purifier 2S
model: zhimi.airpurifier.mc1
did: "259104528"
mac: 04:CF:8C:F1:9E:B1
lan_ip: 192.168.0.141
app_link: mihome://device?uid=1676842482&did=259104528
miot_type: urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-mc1:1
available: true
home_room: Lounge House Kids room
updater: local
updated_at: "2025-02-24 14:35:18.123056+01:00"
aqi: 8
bright: 79
motor1_speed: 351
indicator_light.on: false
air_purifier.on: true
air_purifier.fan_level: 0
air_purifier.mode: 0
converters:
  - button.info
  - light.indicator_light.on
  - fan.air_purifier.on
  - air_purifier.on
  - air_purifier.fan_level
  - air_purifier.mode
  - switch.alarm
  - switch.physical_controls_locked
  - sensor.filter.filter_life_level
  - sensor.filter.filter_left_time
  - sensor.environment.temperature
  - sensor.environment.relative_humidity
  - sensor.environment.pm2_5_density
  - switch.air_purifier.on
customizes:
  switch_properties: air_purifier.on,alarm.alarm,anion,uv
  sensor_properties: illumination,motor_speed
  chunk_coordinators:
    - interval: 10
      props: on,mode,fan_level
    - interval: 300
      props: filter_life_level,filter_left_time,filter_used_time
  speed_property: favorite_level,favorite_fan_level
  number_properties: favorite_level,favorite_fan_level
  exclude_miot_services: button,filter_time,rfid,others
  exclude_miot_properties: >-
    average_aqi_cnt,aqi_zone,sensor_state,aqi_goodh,aqi_runstate,aqi_state,motor_strong,motor_high,motor_med,motor_med_l,motor_low,motor_silent,motor_favorite,motor_set_speed

Home Assistant Logs / 系统日志

2025-02-21 13:35:50.250 ERROR (MainThread) [custom_components.xiaomi_miot.core.device.zhimi.airpurifier.mc1] Unexpected error fetching 04:cf:8c:f1:9e:b1-9da16b14b0cff6dd592fcc3c885d7ec6-chunk_2 data
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 631, in async_render
render_result = _render_with_context(self.template, compiled, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2733, in _render_with_context
return template.render(**kwargs)
~~~~~~~~~~~~~~~^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/jinja2/environment.py", line 1304, in render
self.environment.handle_exception()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.13/site-packages/jinja2/environment.py", line 939, in handle_exception
raise rewrite_traceback_stack(source=source)
File "", line 1, in top-level template code
ZeroDivisionError: float division by zero

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 379, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 280, in _async_update_data
return await self.update_method()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/xiaomi_miot/core/device.py", line 530, in _update
result = await self.update_miot_status(mapping)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/xiaomi_miot/core/device.py", line 852, in update_miot_status
results = await self.miio2miot.async_get_miot_props(self.local, mapping)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/xiaomi_miot/core/miio2miot.py", line 112, in async_get_miot_props
return await self.hass.async_add_executor_job(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
partial(self.get_miot_props, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/xiaomi_miot/core/miio2miot.py", line 135, in get_miot_props
val = tpl.render({
'value': val,
...<5 lines>...
'description': prop.list_description(val) if prop.value_list else None,
})
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 599, in render
).result()
~~~~~~^^
File "/usr/local/lib/python3.13/concurrent/futures/_base.py", line 456, in result
return self.__get_result()
~~~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.13/concurrent/futures/_base.py", line 401, in __get_result
raise self.exception
File "/usr/src/homeassistant/homeassistant/util/async
.py", line 68, in run_callback
future.set_result(callback(*args))
~~~~~~~~^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 633, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: ZeroDivisionError: float division by zero

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants