al-one / hass-xiaomi-miot

Automatic integrate all Xiaomi devices to HomeAssistant via miot-spec, support Wi-Fi, BLE, ZigBee devices. 小米米家智能家居设备接入Hass集成
https://miot-spec.com
Apache License 2.0
4.59k stars 650 forks source link

Log Details (ERROR) Xiaomi Miot(dreame.vacuum.mc1808): Got MiioException while fetching the state: Unable to discover the device 192.168.178.XX, mapping: #999

Closed Blendi closed 1 year ago

Blendi commented 1 year ago

Device model / 设备型号

dreame.vacuum.mc1808

Component version / 插件版本

0.7.5

HA core version / HA版本

2023.1.1

Integrated mode / 集成方式

Automatic (自动模式)

The problem / 问题详情

Hello.

I don't know if this issue was already discussed but I tried to read through the old issues and I did not find anything.

My issue is that I see a lot of errors in my HA logs related to the Vacuum cleaner. Normally the Vacuum cleaner does not stay on for all day. I have created automations so when needed the Vacuum Cleaner is turned on by switching on a 220V smart plug, vacuum cleaner is charged up to 80% of battery and then starts cleaning the apartment. It is by design that when I don't need it, vacuum cleaner charges up to 60% battery and then turns off, thus disconnects from WIFI and is not available anymore.

Normally I would not bother but this log used to appear every 30 seconds, depending on my update interval. Now I have changed it to 90 seconds, so now every 90 second the same error log keeps writing in the error log.

Is there any option to switch off this error log? Especially for me I don't need it because I know that the device is offline.

It would be helpful if I can activate it on demand example when I need to debug a connection issue.

I was thinking to modify the code in the custom_components/xiaomi_miot/init.py:1374 but I don't have a coding experience and I don't know if that would work. I could comment the 4 lines of the below code and try but again not sure.

        **except (DeviceException, OSError) as exc:
            log = self.logger.error
            if self.custom_config_bool('auto_cloud'):
                use_cloud = self.xiaomi_cloud
                log = self.logger.warning if self._local_state else self.logger.info
            else:
                self._available = False
                errors = f'{exc}'
            self._local_state = False
            log(
                '%s: Got MiioException while fetching the state: %s, mapping: %s, max_properties: %s/%s',
                self.name_model, exc, mapping, max_properties, len(mapping)
            )**

Entity attributes / 实体属性

fan_speed_list:

Home Assistant Logs / 系统日志

This error originated from a custom integration.

Logger: custom_components.xiaomi_miot.vacuum Source: custom_components/xiaomi_miot/init.py:1374 Integration: Xiaomi Miot Auto (documentation, issues) First occurred: 2:36:52 PM (29 occurrences) Last logged: 3:18:57 PM

Xiaomi Miot(dreame.vacuum.mc1808): Got MiioException while fetching the state: Unable to discover the device 192.168.178.XX, mapping: {'vacuum.fault': {'siid': 3, 'piid': 1}, 'vacuum.status': {'siid': 3, 'piid': 2}, 'audio.volume': {'siid': 24, 'piid': 1}, 'audio.voice_packets': {'siid': 24, 'piid': 3}, 'clean.work_mode': {'siid': 18, 'piid': 1}, 'clean.area': {'siid': 18, 'piid': 4}, 'clean.timer': {'siid': 18, 'piid': 5}, 'clean.mode': {'siid': 18, 'piid': 6}, 'clean.water_box': {'siid': 18, 'piid': 9}, 'clean.total_clean_time': {'siid': 18, 'piid': 13}, 'clean.total_clean_times': {'siid': 18, 'piid': 14}, 'clean.total_clean_area': {'siid': 18, 'piid': 15}, 'clean.clean_log_start_time': {'siid': 18, 'piid': 16}, 'clean.button_led': {'siid': 18, 'piid': 17}, 'clean.task_done': {'siid': 18, 'piid': 18}, 'brush_left_time-28-1': {'siid': 28, 'piid': 1}, 'brush_life_level-28-2': {'siid': 28, 'piid': 2}, 'filter.filter_life_level': {'siid': 27, 'piid': 1}, 'filter.filter_left_time': {'siid': 27, 'piid': 2}, 'brush_cleaner.brush_left_time': {'siid': 26, 'piid': 1}, 'brush_cleaner.brush_life_level': {'siid': 26, 'piid': 2}, 'battery_level': {'siid': 2, 'piid': 1}, 'battery.charging_state': {'siid': 2, 'piid': 2}}, max_properties: 8/23

sezlony commented 1 year ago

it has to be some general error, I experienced the same with security cameras, so I assume it comes from the integration as nothing has changed on my side neither in hardware nor software

al-one commented 1 year ago

Maybe you can try adding a custom option auto_cloud: true.

Blendi commented 1 year ago

@sezlony Yes, the integration works perfectly, error I have is an expected error. It is normal if integration cannot reach the device, it will complain. Everything is working as expected. No issues at all. Vacuum Cleaner works perfect and react to all my commands.

I am just wondering if there is a way I can turn off this particular error log that is thrown in HomeAssistant while the device is off as per my intend. The log is repeating too much and flooding the log file. If there was a way to just turn it of would be great.

al-one commented 1 year ago
service: logger.set_level
data:
  custom_components.xiaomi_miot.vacuum: fatal

Maybe need logger: in your configuration.yaml.

Blendi commented 1 year ago

Maybe you can try adding a custom option auto_cloud: true.

Hello, Thanks for the suggestion. Actually it helps reducing by a lot the error logs, logged in the home assistant 👍 . I now have only warnings and the frequency is low. I can live with that 😄

Blendi commented 1 year ago
service: logger.set_level
data:
  custom_components.xiaomi_miot.vacuum: fatal

Maybe need logger: in your configuration.yaml.

I will try this and update you. I think this would be the perfect solution for me . 😄

In case I have issues I can always comment the lines in configuration.yaml, restart home assistant and read logs to get more details and solve my issue. (Hopefully will never need that 😄

I will give un update, hopefully soon.

Blendi commented 1 year ago

I am closing this issue since the logger mentioned by @al-one did the trick for me and now the log files is looking way better. I have only few warnings from other custom components.

logger:
  default: warn
  logs:
    custom_components.xiaomi_miot.vacuum: fatal