panasonic_smart_app icon indicating copy to clipboard operation
panasonic_smart_app copied to clipboard

除濕機的實體顯示不可用!

Open Timyeh0211 opened this issue 1 year ago • 1 comments

除濕機的實體顯示不可用! 有照之前版友提供的做法將291至293註記掉,但是變成我的洗衣機不可用.... 請問該如何解決呢 謝謝

image image image image image

Logger: homeassistant.components.sensor Source: helpers/entity_platform.py:368 Integration: 感測器 (documentation, issues) First occurred: 2024年6月5日 下午10:10:45 (2 occurrences) Last logged: 上午11:00:42

Error while setting up panasonic_smart_app platform for sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 368, in _async_setup_platform await asyncio.gather(*pending) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1282, in add_to_platform_finish self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 945, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1066, in _async_write_ha_state state, attr, capabilities, shadowed_attr = self.__async_calculate_state() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1003, in __async_calculate_state state = self._stringify_state(available) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 951, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/config/custom_components/panasonic_smart_app/sensor.py", line 361, in state _current_status = list( ^^^^^ IndexError: list index out of range

Timyeh0211 avatar Jun 20 '24 03:06 Timyeh0211

方便提供機型跟 debug log 嗎?

osk2 avatar Jul 12 '24 08:07 osk2

v2.8.2 修正了一些除濕機的問題,再試試能不能正常運作

osk2 avatar Jul 24 '24 09:07 osk2

有遇到類似問題,不過我這邊是warning不影響使用,不確定是不是 async_setup 的問題

WARNING (MainThread) [homeassistant.helpers.frame] Detected code that calls async_forward_entry_setup for integration panasonic_smart_app with title: ****** and entry_id: 01J2S****************C143, during setup without awaiting async_forward_entry_setup, which can cause the setup lock to be released before the setup is done. This will stop working in Home Assistant 2025.1. Please report this issue.

JyunWei-Su avatar Jul 29 '24 13:07 JyunWei-Su

@Timyeh0211 請問您的帳號下有洗衣機嗎,因為 sensor 的 log 是報錯在洗衣機,除濕機的實體可能要看一下humidifier.py的log。

一樣不能用耶 Logger: homeassistant.components.sensor Source: helpers/entity_platform.py:507 Integration: 感測器 (documentation, issues) First occurred: 上午10:53:38 (2 occurrences) Last logged: 下午12:42:36

Error adding entities for domain sensor with platform panasonic_smart_app Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1282, in add_to_platform_finish self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 945, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1066, in _async_write_ha_state state, attr, capabilities, shadowed_attr = self.__async_calculate_state() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1003, in __async_calculate_state state = self._stringify_state(available) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 951, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/config/custom_components/panasonic_smart_app/sensor.py", line 368, in state _current_status = list( ^^^^^ IndexError: list index out of range

JyunWei-Su avatar Jul 31 '24 07:07 JyunWei-Su

不確定是不是 sensor.py 報錯導致除濕機實體沒辦法正常顯示,可以試試看修改 sensor.py 增加兩行,重啟後看問題能不能解決: 在PanasonicWashingStatusSensor 底下的 def state 增加兩行

        if not raw_mode_list:
            return STATE_UNAVAILABLE

修改後如下:

    @property
    def state(self) -> int:
        status = self.coordinator.data[self.index]["status"]
        washing_status = status.get("0x50")

        if not washing_status:
            return STATE_UNAVAILABLE

        raw_mode_list = list(
            filter(lambda c: c["CommandType"] == "0x50", self.commands)
        )[0]["Parameters"]

        ###增加在這裡###
        if not raw_mode_list:
            return STATE_UNAVAILABLE
        
        _current_status = list(
            filter(lambda m: m[1] == int(washing_status), raw_mode_list)
        )[0][0]
        
        _LOGGER.debug(f"[{self.label}] state: {_current_status}")
        return _current_status

JyunWei-Su avatar Aug 07 '24 04:08 JyunWei-Su

感謝!!!可以了耶~~~~ 但是PM2.5仍然無法顯示 這個要提供log檔嗎還是先更新到 v2.83?

PM2.5 的問題在 2.8.3 解決了,可以更新試試看

JyunWei-Su avatar Aug 07 '24 06:08 JyunWei-Su