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

Countdown timer for fan zhimi.fan.za4 should be in minutes #1786

Closed
alex3305 opened this issue Jun 20, 2023 · 3 comments · Fixed by #1787
Closed

Countdown timer for fan zhimi.fan.za4 should be in minutes #1786

alex3305 opened this issue Jun 20, 2023 · 3 comments · Fixed by #1787
Assignees
Labels

Comments

@alex3305
Copy link
Contributor

Describe the bug
As mentioned in home-assistant/core#91824 the countdown timer for zhimi.fan.za4 is currently in seconds, but this should be in minutes.

Version information (please complete the following information):

  • OS: Docker (python:3 image)
  • python-miio: 0.5.12

Device information:
If the issue is specific to a device [Use miiocli device --ip <ip address> --token <token> info]:

  • Model: zhimi.fan.za4
  • Hardware version: esp32
  • Firmware version: 2.0.3

To Reproduce
Steps to reproduce the behavior:

  1. Set the countdown timer
  2. See that the countdown timer should be in minutes, but is in seconds

Expected behavior
The countdown timer should be set in minutes and retrieved in minutes

Maybe an exception should be made here?:

@property
def delay_off_countdown(self) -> int:
"""Countdown until turning off in seconds."""
return self.data["poweroff_time"]

@alex3305 alex3305 changed the title Countdown timer for fan zhimi.fan.za4 should be in seconds Countdown timer for fan zhimi.fan.za4 should be in minutes Jun 20, 2023
@rytilahti
Copy link
Owner

Feel free to create a PR to fix it!

I was hoping it would fix itself when genericmiot support gets done, but it looks like this information is not accessible over miot. If you want to verify that, you can use miiocli genericmiot --ip <addr> --token <token> status after following the readme on how to install and obtain the tokens.

@rytilahti rytilahti added the bug label Jun 22, 2023
@alex3305
Copy link
Contributor Author

Thanks for the quick response!

Feel free to create a PR to fix it!

If you are open for PR's, I'm glad to contribute where I can 😄.

[...] If you want to verify that, you can use miiocli genericmiot --ip <addr> --token <token> status after following the readme on how to install and obtain the tokens.

I tried that (after installing the latest development branch from GitHub as described in the README), but that doesn't seem to work 😐:

miiocli genericmiot --ip 192.168.10.8 --token REDACTED status
Running command status
ERROR:miio.miioprotocol:Got error when receiving: {'code': -9999, 'message': 'user ack timeout'}
ERROR:miio.click_common:Exception: Unable to recover failed command
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/miio/miioprotocol.py", line 215, in send
    self._handle_error(payload["error"])
  File "/usr/local/lib/python3.11/site-packages/miio/miioprotocol.py", line 275, in _handle_error
    raise RecoverableError(error)
miio.exceptions.RecoverableError: {'code': -9999, 'message': 'user ack timeout'}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/miio/miioprotocol.py", line 215, in send
    self._handle_error(payload["error"])
  File "/usr/local/lib/python3.11/site-packages/miio/miioprotocol.py", line 275, in _handle_error
    raise RecoverableError(error)
miio.exceptions.RecoverableError: {'code': -9999, 'message': 'user ack timeout'}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/miio/miioprotocol.py", line 215, in send
    self._handle_error(payload["error"])
  File "/usr/local/lib/python3.11/site-packages/miio/miioprotocol.py", line 275, in _handle_error
    raise RecoverableError(error)
miio.exceptions.RecoverableError: {'code': -9999, 'message': 'user ack timeout'}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/miio/miioprotocol.py", line 215, in send
    self._handle_error(payload["error"])
  File "/usr/local/lib/python3.11/site-packages/miio/miioprotocol.py", line 275, in _handle_error
    raise RecoverableError(error)
miio.exceptions.RecoverableError: {'code': -9999, 'message': 'user ack timeout'}

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/miio/click_common.py", line 54, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/miio/click_common.py", line 305, in wrap
    result = kwargs["result"] = func(*args, **kwargs)
                                ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/miio/click_common.py", line 270, in command_callback
    return miio_command.call(miio_device, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/miio/click_common.py", line 218, in call
    return method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/miio/click_common.py", line 185, in _wrap
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/miio/integrations/genericmiot/genericmiot.py", line 83, in status
    response = self.get_properties(
               ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/miio/device.py", line 308, in get_properties
    values.extend(self.send(property_getter, _props[:max_properties]))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/miio/device.py", line 122, in send
    return self._protocol.send(
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/miio/miioprotocol.py", line 249, in send
    return self.send(
           ^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/miio/miioprotocol.py", line 249, in send
    return self.send(
           ^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/miio/miioprotocol.py", line 249, in send
    return self.send(
           ^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/miio/miioprotocol.py", line 257, in send
    raise DeviceException("Unable to recover failed command") from ex
miio.exceptions.DeviceException: Unable to recover failed command

I also tried it on my other fan dmaker.fan.1c and that yields the same result.

@rytilahti
Copy link
Owner

Ohh, za4 is indeed using the zhimi fan instead of fanmiot for controls, so that's expected. dmaker.fan.1c should work though given its a miot device is a bit odd:

FAN1C_MAPPINGS = {
MODEL_FAN_1C: {
# https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:fan:0000A005:dmaker-1c:1
"power": {"siid": 2, "piid": 1},
"fan_level": {"siid": 2, "piid": 2},
"child_lock": {"siid": 3, "piid": 1},
"swing_mode": {"siid": 2, "piid": 3},
"power_off_time": {"siid": 2, "piid": 10},
"buzzer": {"siid": 2, "piid": 11},
"light": {"siid": 2, "piid": 12},
"mode": {"siid": 2, "piid": 7},
}
}

PRs are always welcome! Alas, the library has been undergoing a major rewrite to make it easier to integrate the devices to homeassistant, but I haven't been able to find free time to push this effort onwards.

If you don't mind, feel free to try adding decorators defining metadata about the sensors & settings for the zhimi fan to see if there are some improvements needed to the interfaces. The descriptors marked with these decorators will be used in the future to expose the information to homeassistant (and other downstreams) using a common interface, one example of adding such for viomi vacuum (and how the result looks like in a development fork) can be seen in #1559.

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

Successfully merging a pull request may close this issue.

3 participants