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

Xiaomi Humidifier action crash if speed value passed #21209

Closed
StanislavBolshakov opened this issue Feb 19, 2019 · 2 comments · Fixed by #27231
Closed

Xiaomi Humidifier action crash if speed value passed #21209

StanislavBolshakov opened this issue Feb 19, 2019 · 2 comments · Fixed by #27231

Comments

@StanislavBolshakov
Copy link

Home Assistant release with the issue:

0.87.1

Last working Home Assistant release (if known):
Don't know

Operating environment (Hass.io/Docker/Windows/etc.):

Docker
Component/platform:

https://www.home-assistant.io/components/fan/
https://www.home-assistant.io/components/fan.xiaomi_miio/
Description of problem:

Passing speed value to Xiaomi Humidifier 2 ends with an error. Same service called from web interface works fine for some reason.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

fan:
  - platform: xiaomi_miio
    host: 172.16.100.31
    token: !secret humidifier_token

Automation itself:

- alias: 'Humidify on weekdays'
  trigger:
    - platform: numeric_state
      entity_id: sensor.humidity_158d0001b75d90
      below: '55'
  action:
    - service: fan.turn_on
      data:
        entity_id: fan.xiaomi_miio_device
        speed: high

Traceback (if applicable):

2019-02-19 14:38:18 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/fan/xiaomi_miio.py", line 551, in _try_command
    partial(func, *args, **kwargs))
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/miio/airhumidifier.py", line 329, in set_mode
    return self.send("set_mode", [mode.value])
  File "/usr/local/lib/python3.6/site-packages/miio/device.py", line 272, in send
    raise DeviceError(m.data.value["error"])
miio.exceptions.DeviceError: {'code': -6011, 'message': 'device_poweroff'}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/service.py", line 289, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/fan/xiaomi_miio.py", line 566, in async_turn_on
    result = await self.async_set_speed(speed)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/fan/xiaomi_miio.py", line 879, in async_set_speed
    self._device.set_mode, OperationMode[speed.title()])
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/fan/xiaomi_miio.py", line 557, in _try_command
    _LOGGER.error(mask_error, exc)
  File "/usr/local/lib/python3.6/logging/__init__.py", line 1336, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/local/lib/python3.6/logging/__init__.py", line 1443, in _log
    self.handle(record)
  File "/usr/local/lib/python3.6/logging/__init__.py", line 1453, in handle
    self.callHandlers(record)
  File "/usr/local/lib/python3.6/logging/__init__.py", line 1515, in callHandlers
    hdlr.handle(record)
  File "/usr/local/lib/python3.6/logging/__init__.py", line 864, in handle
    self.emit(record)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/system_log/__init__.py", line 130, in emit
    entry = self._create_entry(record, stack)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/system_log/__init__.py", line 113, in _create_entry
    'message': record.getMessage(),
  File "/usr/local/lib/python3.6/logging/__init__.py", line 338, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting

Additional information:

@syssi
Copy link
Member

syssi commented Feb 26, 2019

It looks like the firmware doesn't allow a set_mode call if the device is turned off. Could you try to extend your automation (as workaround): Call the turn_on service without the speed parameter. Call the set_speed service afterwards with speed: high. If this solution works fine I will update the HA component:

https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/xiaomi_miio/fan.py#L556-L564

@StanislavBolshakov
Copy link
Author

Already done this. Works fine for a week. Action part looks like this:

  action:
    - service: fan.turn_on
      data:
        entity_id: fan.xiaomi_miio_device
    - service: fan.set_speed
      data:
        entity_id: fan.xiaomi_miio_device
        speed: high

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

Successfully merging a pull request may close this issue.

4 participants