Skip to content
New issue

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

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

Already on GitHub? # to your account

冷氣耗電量呈現不可用 #108

Closed
Dmans opened this issue May 17, 2024 · 2 comments
Closed

冷氣耗電量呈現不可用 #108

Dmans opened this issue May 17, 2024 · 2 comments

Comments

@Dmans
Copy link

Dmans commented May 17, 2024

我dump debug log如下
2024-05-17 14:23:53.479 DEBUG (MainThread) [custom_components.panasonic_smart_app] Finished fetching Panasonic Smart Application data in 10.019 seconds (success: True)
2024-05-17 14:23:53.480 DEBUG (MainThread) [custom_components.panasonic_smart_app] [客廳冷氣機 本月耗電量] state: 18.3
2024-05-17 14:23:53.480 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 258, in _handle_refresh_interval
await self._async_refresh(log_failures=True, scheduled=True)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 414, in _async_refresh
self.async_update_listeners()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 168, in async_update_listeners
update_callback()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 492, in _handle_coordinator_update
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1009, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1132, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1069, in __async_calculate_state
if state_attributes := self.state_attributes:
^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 446, in state_attributes
raise ValueError(
ValueError: Entity sensor.ke_ting_leng_qi_ji_ben_yue_hao_dian_liang (<class 'custom_components.panasonic_smart_app.sensor.PanasonicEnergySensor'>) with state_class total_increasing has set last_reset. Setting last_reset for entities with state_class other than 'total' is not supported. Please update your configuration if state_class is manually configured.

查了HA官方文件
https://developers.home-assistant.io/docs/core/entity/sensor
有以下描述
How to choose state_class and last_reset
It's recommended to use state class total without last_reset whenever possible, state class total_increasing or total with last_reset should only be used when state class total without last_reset does not work for the sensor.

看目前設置 PanasonicEnergySensor內的state_class會被指定成 total_increasing
last_reset看起來是為了每月重設 但不懂為什麼會拋個錯誤?

@Dmans
Copy link
Author

Dmans commented May 17, 2024

剛剛有先comment掉last_reset看起來值可以正常顯示 但是不確定是否會造成接下來就是一直往上加?

@Dmans
Copy link
Author

Dmans commented May 17, 2024

剛剛認真看其他人的問題跟解決方案看樣子是同一個問題
#101 (comment)
我先關單

@Dmans Dmans closed this as completed May 17, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant