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

Fan initialization fails on Hass.io #4

Closed
jacekpaszkowski opened this issue Jun 4, 2018 · 7 comments
Closed

Fan initialization fails on Hass.io #4

jacekpaszkowski opened this issue Jun 4, 2018 · 7 comments

Comments

@jacekpaszkowski
Copy link

Hi,

Suddenly (maybe couple of restarts after updating to Hass.io 0.70.1) i'm getting this error on startup and fan is not showing in UI:

Count (17) of requested properties does not match the count (16) of received values.
21:00 deps/lib/python3.6/site-packages/miio/fan.py (ERROR)

@jacekpaszkowski
Copy link
Author

I'm using latest version of your component. After fixing locally the problem with missing ATTR_SPEED_LEVEL i get this error:

xiaomi_miio_fan: Error on device update!
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 244, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 325, in async_device_update
yield from self.async_update()
File "/config/custom_components/fan/xiaomi_miio_fan.py", line 422, in async_update
key, value in self._available_attributes.items()})
File "/config/custom_components/fan/xiaomi_miio_fan.py", line 422, in
key, value in self._available_attributes.items()})
File "/config/custom_components/fan/xiaomi_miio_fan.py", line 286, in _extract_value_from_attribute
value = getattr(state, attribute)
File "/config/deps/lib/python3.6/site-packages/miio/fan.py", line 178, in button_pressed
if self.data["button_pressed"] is not None:
KeyError: 'button_pressed'

@syssi syssi closed this as completed in 7894355 Jun 4, 2018
@jacekpaszkowski
Copy link
Author

Works good. Thank You!

@syssi
Copy link
Owner

syssi commented Jun 4, 2018

I would be happy if you provide some further testing. Do you like to provide some feedback to these questions:

  • fan.oscillate {"oscillating":true} / {"oscillating":false}
    It's possible the turning on doesn't work because the oscillation angle is unknown. The Mi Home app turns the oscillation on by set_angle(30) f.e. and only uses the method above to disable the oscillation.
  • fan.set_direction {"direction":"left"} / {"direction":"right"}
    Does the fan move left/right? It's required to turn of the oscillation beforehand? Does the service work fine if oscillation is enabled?
  • fan.xiaomi_miio_set_oscillation_angle {"angle": 30} / {"angle": 60} / {"angle": 90} / {"angle": 120}
    What happens if you use other values like: {"angle": 0}, {"angle": 1}, {"angle": 15} and {"angle": 130}? Please provide the homeassistant.log.
  • fan.xiaomi_miio_set_natural_mode_on / fan.xiaomi_miio_set_natural_mode_off
    Does this service work fine? Please check the "natural_speed" attribute. Is the values stable or does it change over time (+/- a few values)
  • fan.xiaomi_miio_set_led_brightness {"brightness": 0} / {"brightness": 1} / {"brightness": 2}
    Are you able to control the led brightness?
  • fan.set_speed {speed: 0} / {speed: 1} / {speed: 10} / {speed: 100} / {speed: 110}
    Next to "Level 1...4" it should also be possible to provide an integer (0...100). What happens if you set the speed to a value of "0"? Does the device turn off? What's the response of the device for values like 0, 1, 10, 100, 110?

@jacekpaszkowski
Copy link
Author

No problem, i'll do some tests in up coming days and give you feedback :)

@jacekpaszkowski
Copy link
Author

Hi,

for points 1,2,5 i've created separate issues.

  • fan.xiaomi_miio_set_oscillation_angle {"angle": 30} / {"angle": 60} / {"angle": 90} / {"angle": 120}
    using numeric value seems to hang whole Hass.io :-/
    passing string values works only for: "30", "60", "90", "120" for other values nothing happens and get this king of error:
    Invalid service data for fan.xiaomi_miio_set_oscillation_angle: value is not allowed for dictionary value @ data['angle']. Got '50'

  • fan.xiaomi_miio_set_natural_mode_on / fan.xiaomi_miio_set_natural_mode_off
    works fine. when on "natural_speed" seems to be constant:
    "Level 1" = 13 ("speed" 200250)
    "Level 2" = 38 ("speed" 300
    380)
    "Level 3" = 63 ("speed" 390500)
    "Level 4" = 88 ("speed" 520
    630)
    when off "natural_speed" = 0

  • fan.set_speed {speed: 0} / {speed: 1} / {speed: 10} / {speed: 100} / {speed: 110}
    works with numeric values, eg:
    1 -> "direct_speed"=13
    10 -> "direct_speed"=13
    20 -> "direct_speed"=20
    50 -> "direct_speed"=38
    100 -> "direct_speed"=88

100

Error executing service <ServiceCall fan.set_speed: entity_id=['fan.xiaomi_smart_fan'], speed=120>
Traceback (most recent call last):
File "/config/custom_components/fan/xiaomi_miio_fan.py", line 298, in _try_command
partial(func, *args, **kwargs))
File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/deps/lib/python3.6/site-packages/miio/fan.py", line 312, in set_direct_speed
raise FanException("Invalid speed: %s" % speed)
miio.fan.FanException: Invalid speed: 120

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/homeassistant/core.py", line 1007, in _event_to_service_call
await service_handler.func(service_call)
File "/usr/lib/python3.6/site-packages/homeassistant/components/fan/init.py", line 219, in async_handle_fan_service
yield from getattr(fan, method['method'])(**params)
File "/config/custom_components/fan/xiaomi_miio_fan.py", line 464, in async_set_speed
self._device.set_direct_speed, speed)
File "/config/custom_components/fan/xiaomi_miio_fan.py", line 304, in _try_command
_LOGGER.error(mask_error, exc)
File "/usr/lib/python3.6/logging/init.py", line 1335, in error
self._log(ERROR, msg, args, **kwargs)
File "/usr/lib/python3.6/logging/init.py", line 1442, in _log
self.handle(record)
File "/usr/lib/python3.6/logging/init.py", line 1452, in handle
self.callHandlers(record)
File "/usr/lib/python3.6/logging/init.py", line 1514, in callHandlers
hdlr.handle(record)
File "/usr/lib/python3.6/logging/init.py", line 863, in handle
self.emit(record)
File "/usr/lib/python3.6/site-packages/homeassistant/components/system_log/init.py", line 131, in emit
entry = self._create_entry(record, stack)
File "/usr/lib/python3.6/site-packages/homeassistant/components/system_log/init.py", line 114, in _create_entry
'message': record.getMessage(),
File "/usr/lib/python3.6/logging/init.py", line 338, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting

@syssi
Copy link
Owner

syssi commented Jun 5, 2018

Thanks for your feedback. A last question: Could you test the fan.set_speed {speed: 0} call? Does the fan turn off?

@jacekpaszkowski
Copy link
Author

No, calling fan.set_speed {speed: 0} doesn't turn off the fan.

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

No branches or pull requests

2 participants