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

Support device model dmaker.fan.p5 #30

Closed
1043717432 opened this issue May 23, 2019 · 74 comments
Closed

Support device model dmaker.fan.p5 #30

1043717432 opened this issue May 23, 2019 · 74 comments

Comments

@1043717432
Copy link

Support device model dmaker.fan.p5

Hi, today I received my "xiaomi SmartmiFan 1x"
Sadly it is not yet recognised by your component. Could you please integrate it?

I try to give the same information which you required in similar requests, let me know if you need more information:
Mi Home App doesn't seem to display battery stats

Support device model dmaker.fan.p5

bash-4.4# mirobo --ip 192.168.120.157 --token df0xx25caxxcedxx7656368xx79aaxx9 raw-command get_prop "['$PROP']"
Sending cmd get_prop with params ['']
[True, 'nature', 35, True, 140, 0, True, False, False, 2]

@StanislavBolshakov
Copy link

Came across the same issue. Component returns an error on load:

Unsupported device found! Please create an issue at https://github.com/syssi/xiaomi_fan/issues and provide the following data: dmaker.fan.p5

@vandijks
Copy link

I can help testing if required, received the same device today (2019, 1X, 140deg instead of 120, wired).

@syssi
Copy link
Owner

syssi commented Jun 2, 2019

Could somebody provide the output of:

for PROP in ac_power angle angle_enable bat_charge bat_state battery button_pressed buzzer child_lock humidity led led_b natural_level power poweroff_time speed speed_level temp_dec use_time
do
  mirobo --ip IP --token TOKEN raw-command get_prop "['$PROP']"
done

and

for PROP in power mode speed roll_enable roll_angle time_off light beep_sound child_lock
do
  mirobo --ip IP --token TOKEN raw-command get_prop "['$PROP']"
done

I will implement the device support as soon as the output is known.

@1043717432
Copy link
Author

稍等,我现在立马测试!

@syssi
Copy link
Owner

syssi commented Jun 2, 2019

Cool! Thanks.

@StanislavBolshakov
Copy link

StanislavBolshakov commented Jun 2, 2019

Sending cmd get_prop with params ['ac_power']
[True]
Sending cmd get_prop with params ['angle']
[True, 'normal', 35, False, 140, 0, True, False, False, 2]
Sending cmd get_prop with params ['angle_enable']
[True, 'normal', 35, False, 140, 0, True, False, False, 2]
Sending cmd get_prop with params ['bat_charge']
[True, 'normal', 35, False, 140, 0, True, False, False, 2]
Sending cmd get_prop with params ['bat_state']
[True, 'normal', 35, False, 140, 0, True, False, False, 2]
Sending cmd get_prop with params ['battery']
[True, 'normal', 35, False, 140, 0, True, False, False, 2]
Sending cmd get_prop with params ['button_pressed']
[True, 'normal', 35, False, 140, 0, True, False, False, 2]
Sending cmd get_prop with params ['buzzer']
[True, 'normal', 35, False, 140, 0, True, False, False, 2]
Sending cmd get_prop with params ['child_lock']
[False]
Sending cmd get_prop with params ['humidity']
[True, 'normal', 35, False, 140, 0, True, False, False, 2]
Sending cmd get_prop with params ['led']
[True, 'normal', 35, False, 140, 0, True, False, False, 2]
Sending cmd get_prop with params ['led_b']
[True, 'normal', 35, False, 140, 0, True, False, False, 2]
Sending cmd get_prop with params ['natural_level']
[True, 'normal', 35, False, 140, 0, True, False, False, 2]
Sending cmd get_prop with params ['power']
[True]
Sending cmd get_prop with params ['poweroff_time']
[True]
Sending cmd get_prop with params ['speed']
[35]
Sending cmd get_prop with params ['speed_level']
[35]
Sending cmd get_prop with params ['temp_dec']
[True, 'normal', 35, False, 140, 0, True, False, False, 2]
Sending cmd get_prop with params ['use_time']
[True, 'normal', 35, False, 140, 0, True, False, False, 2]
Sending cmd get_prop with params ['power']
[True]
Sending cmd get_prop with params ['mode']
['normal']
Sending cmd get_prop with params ['speed']
[35]
Sending cmd get_prop with params ['roll_enable']
[False]
Sending cmd get_prop with params ['roll_angle']
[140]
Sending cmd get_prop with params ['time_off']
[0]
Sending cmd get_prop with params ['light']
[True]
Sending cmd get_prop with params ['beep_sound']
[False]
Sending cmd get_prop with params ['child_lock']
[False]

Here you go.

@1043717432
Copy link
Author

1043717432 commented Jun 2, 2019

@syssi

/config # mirobo --ip 192.168.120.129 --token df02225caf5cedxxxx563687e79aadd9 raw-command get_prop "['$PROP']" Sending cmd get_prop with params [''] [True, 'nature', 100, False, 140, 0, True, False, False, 4]
/config # mirobo --ip 192.168.120.129 --token df02225caf5cedxxxx563687e79aadd9 raw-command get_prop "['$PROP']" Sending cmd get_prop with params [''] [False, 'nature', 100, False, 140, 0, True, False, False, 4] 
/config # mirobo --ip 192.168.120.129 --token df02225caf5cedxxxx563687e79aadd9 raw-command get_prop "['$PROP']" Sending cmd get_prop with params [''] [False, 'nature', 100, False, 140, 0, True, False, False, 4] 
/config # mirobo --ip 192.168.120.129 --token df02225caf5cedxxxx563687e79aadd9 raw-command get_prop "['$PROP']" Sending cmd get_prop with params [''] [True, 'nature', 100, False, 140, 0, True, False, False, 4] 
/config # mirobo --ip 192.168.120.129 --token df02225caf5cedxxxx563687e79aadd9 raw-command get_prop "['$PROP']" Sending cmd get_prop with params [''] [True, 'nature', 1, False, 140, 0, True, False, False, 1] 
/config # mirobo --ip 192.168.120.129 --token df02225caf5cedxxxx563687e79aadd9 raw-command get_prop "['$PROP']" Sending cmd get_prop with params [''] [True, 'nature', 35, False, 140, 0, True, False, False, 2] 
/config # mirobo --ip 192.168.120.129 --token df02225caf5cedxxxx563687e79aadd9 raw-command get_prop "['$PROP']" Sending cmd get_prop with params [''] [True, 'nature', 70, False, 140, 0, True, False, False, 3] 

@syssi
Copy link
Owner

syssi commented Jun 2, 2019

@StanislavBolshakov If you request a list of properties do you retrieve a proper response:

mirobo --ip IP --token TOKEN raw-command get_prop "['power','mode','speed','roll_enable','roll_angle','time_off','light','beep_sound','child_lock']"

@1043717432
Copy link
Author

/config # mirobo --ip 192.168.120.129 --token df02225caf5cedxxxx563687e79aadd9 raw-command get_prop "['power','mode','speed','roll_enable','roll_angle','time_off','light','beep_sound','child_lock']" Sending cmd get_prop with params ['power', 'mode', 'speed', 'roll_enable', 'roll_angle', 'time_off', 'light', 'beep_sound', 'child_lock'] [True, 'nature', 70, False, 140, 0, True, False, False]

@1043717432
Copy link
Author

我按一次风速和转动方向 ,都只是这样的反馈!

@1043717432
Copy link
Author

抱歉不会编辑回复,可能你看得有点乱!

@StanislavBolshakov
Copy link

StanislavBolshakov commented Jun 2, 2019

@syssi yup.

Sending cmd get_prop with params ['power', 'mode', 'speed', 'roll_enable', 'roll_angle', 'time_off', 'light', 'beep_sound', 'child_lock']
[False, 'normal', 35, False, 140, 0, True, False, False]

But I believe there should be something else as well. Sending command without params returns "2" in array.

Sending cmd get_prop with params ['']
[False, 'normal', 35, False, 140, 0, True, False, False, 2]

On a side note, it reports "2" no matter what, so probably doesn't matter.

@syssi
Copy link
Owner

syssi commented Jun 2, 2019

I want to request a list of properties because of future firmware updates. If the response of the empty request changes the values are mapped incorrect.

@syssi
Copy link
Owner

syssi commented Jun 2, 2019

Could somebody provide a list of the different available "mode"s?

@1043717432
Copy link
Author

How to provide a list of different modes?

@StanislavBolshakov
Copy link

Could somebody provide a list of the different available "mode"s?

It's either normal or nature.

@syssi
Copy link
Owner

syssi commented Jun 2, 2019

The maximum speed is 100%?

@StanislavBolshakov
Copy link

The maximum speed is 100%?

Yes

@syssi
Copy link
Owner

syssi commented Jun 2, 2019

This is the first step (extending python-miio): rytilahti/python-miio#513

@StanislavBolshakov Do you like to install and test the feature branch?

$ pip3 install https://github.com/syssi/python-miio/archive/feature/dmaker-fan-p5-support.zip
[...]
$ miiocli fanp5
Usage: miiocli fanp5 [OPTIONS] COMMAND [ARGS]...

Options:
  --ip TEXT     [required]
  --token TEXT  [required]
  --help        Show this message and exit.

Commands:
  delay_off       Set delay off seconds.
  info            Get miIO protocol information from the device.
  off             Power off.
  on              Power on.
  raw_command     Send a raw command to the device.
  set_angle       Set the oscillation angle.
  set_buzzer      Set buzzer on/off.
  set_child_lock  Set child lock on/off.
  set_led         Turn led on/off.
  set_mode        Set mode.
  set_oscillate   Set oscillate on/off.
  set_speed       Set speed.
  status          Retrieve properties

@StanislavBolshakov
Copy link

Getting an error:

bash-4.4#  miiocli fanp5
Usage: miiocli [OPTIONS] COMMAND [ARGS]...
Try "miiocli --help" for help.

Error: No such command "fanp5".

@syssi
Copy link
Owner

syssi commented Jun 2, 2019

In this case you have python-miio installed two times now. This should work:

~/.local/bin/miiocli fanp5

@StanislavBolshakov
Copy link

StanislavBolshakov commented Jun 2, 2019

Missed the --upgrade key, sorry.

Works fine:

  • Info provides accurate info about device, firmware and WLAN.
  • On/off toggles the device.
  • Buzzer
  • Child mode
  • LED
  • On/off oscillating
  • Speed
  • Setting mode normal & nature
  • Status

There is space for improvement:

  • Delay_off expects minutes, not seconds. Overwise works.
  • Set_angle should receive [30,60,90,120,140], other values won't work. Will it make sense to call set_oscillate prior set_angle if oscillating currently disabled?
  • Mi Home App has controls to rotate the fan gradually without enabling oscillating mode. Is it worth to implement?

@syssi
Copy link
Owner

syssi commented Jun 2, 2019

  1. Fixed.
  2. What happens if you turn off oscillation, set_angle 90 and retrieve the status afterwards. Does the property change and is the oscillation still disabled? I will restrict the accepted values.
  3. Could you test m_roll as raw_command?
miiocli fanp5 --ip IP --token TOKEN raw_command m_roll "['left']"
...multiple times...
miiocli fanp5 --ip IP --token TOKEN raw_command m_roll "['right']"
...multiple times...

I'm unsure about "left" and "right". The proper payload is unknown up to now.

@StanislavBolshakov
Copy link

  1. Value sets to 90. Oscillation still being disabled.
  2. Works fine.

@syssi
Copy link
Owner

syssi commented Jun 2, 2019

Cool. In this case the implementation should be feature complete now:

rytilahti/python-miio@0f76c50

Could you test the new command?

$ pip3 install https://github.com/syssi/python-miio/archive/feature/dmaker-fan-p5-support.zip -U
[...]
miiocli fanp5 --ip IP --token TOKEN set_rotate left
miiocli fanp5 --ip IP --token TOKEN set_rotate right

@StanislavBolshakov
Copy link

It works!

@syssi
Copy link
Owner

syssi commented Jun 10, 2019

A release of python-miio is needed first. Afterwards I will extend the HA component.

@yeyeyaya
Copy link

how to fix it?
2019-06-12 22:54:25 INFO (MainThread) [homeassistant.components.fan] Setting up fan.xiaomi_miio
2019-06-12 22:54:25 INFO (MainThread) [homeassistant.components.switch] Setting up switch.broadlink
2019-06-12 22:54:26 INFO (MainThread) [homeassistant.components.xiaomi_miio.fan] Initializing with host 192.168.3.10 (token 09d62...)
2019-06-12 22:54:26 INFO (MainThread) [homeassistant.components.xiaomi_miio.fan] dmaker.fan.p5 1.3.6 ESP8266 detected
2019-06-12 22:54:26 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Unsupported device found! Please create an issue at https://github.com/syssi/xiaomi_fan/issues and provide the following data: dmaker.fan.p5

@syssi
Copy link
Owner

syssi commented Jun 12, 2019

You have to wait. I will extend the component soon.

@yeyeyaya
Copy link

You have to wait. I will extend the component soon.

thanks for reply!

@surpasstop
Copy link

What is the error below?

ERROR (MainThread) [custom_components.xiaomi_miio_fan.fan] Got exception while fetching the state: {'code': -9999, 'message': 'user ack timeout'}

@syssi
Copy link
Owner

syssi commented Oct 11, 2019

@sjtuross Please update the custom component again. We need a few iterations may be. I've improved the implementation. If the component doesn't crash anymore we should check all features are working fine.

@syssi
Copy link
Owner

syssi commented Oct 11, 2019

@surpasstop Please update the custom component, too.

@surpasstop
Copy link

surpasstop commented Oct 11, 2019

@syssi I've updated component and restart ha, another error occured
I use RPi3 b+ Raspbian and docker based HA

Error while setting up platform xiaomi_miio_fan Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT) File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for return fut.result() File "/config/custom_components/xiaomi_miio_fan/fan.py", line 231, in async_setup_platform from miio import FanP5 ImportError: cannot import name 'FanP5' from 'miio' (/usr/local/lib/python3.7/site-packages/miio/__init__.py)

@syssi
Copy link
Owner

syssi commented Oct 11, 2019

In this case you don't have python-miio 0.4.6 installed. Please use the development version of HA.

@surpasstop
Copy link

I've updated development version
and another error occured

xiaomi_miio_fan: Error on device update! Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 292, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 448, in async_device_update await self.async_update() File "/config/custom_components/xiaomi_miio_fan/fan.py", line 447, in async_update self._natural_mode = (state.natural_speed != 0) AttributeError: 'FanStatusP5' object has no attribute 'natural_speed'

@syssi
Copy link
Owner

syssi commented Oct 11, 2019

Could you provide the xiaomi_miio_fan section of your configuration.yaml? This part shouldn't be used if you've the most recent version of the custom component. Relevent lines for the P5 are L572-L678.

@surpasstop
Copy link

surpasstop commented Oct 11, 2019

Thank you syssi
I use two v3 and two p5 fan
V3 works fine well even after updating components

model: 'dmaker.fan.p5' or
model: dmaker.fan.p5 or
skipping model: ~ don't works..

  • platform: xiaomi_miio_fan
    name: ecroom fan
    host: 192.168.0.117
    token: 1a84028de6a8aa0c474fc5362140b440
    model: 'dmaker.fan.p5'
  • platform: xiaomi_miio_fan
    name: ejroom fan
    host: 192.168.0.118
    token: 13915911513b46931b1ca035cf3edafe
    model: 'dmaker.fan.p5'

@syssi
Copy link
Owner

syssi commented Oct 11, 2019

Could you remove the V3 temporary from your configuration? Just use:

fan:
  - platform: xiaomi_miio_fan
    name: ejroom fan
    host: 192.168.0.118
    token: 13915911513b46931b1ca035cf3edafe

# And enable the debug out / change the configuration of your "logger:" by

logger:
  default: warn
  logs:
    custom_components.fan.xiaomi_miio_fan: debug
    miio: debug

Restart HA and provide the error of the log. :-)

@surpasstop
Copy link

surpasstop commented Oct 11, 2019

Here you are

2019-10-12 00:05:16 DEBUG (MainThread) [miio.device] 192.168.0.118:54321 >>: {'id': 1, 'method': 'miIO.info', 'params': []}

2019-10-12 00:05:16 DEBUG (MainThread) [miio.device] 192.168.0.118:54321 (ts: 1970-02-06 05:30:57, id: 1) << {'id': 1, 'result': {'life': 3130257, 'uid': 1678397415, 'model': 'dmaker.fan.p5', 'token': '13915911513b46931b1ca035cf3edafe', 'fw_ver': '2.0.4', 'mcu_fw_ver': '0008', 'miio_ver': '0.0.6', 'hw_ver': 'esp8266', 'mmfree': 25056, 'mac': '40:31:3C:DC:74:2C', 'wifi_fw_ver': '2709610', 'ap': {'ssid': 'IoT_Home', 'bssid': '8A:36:6C:5A:12:47', 'rssi': -65, 'primary': 3}, 'netif': {'localIp': '192.168.0.118', 'mask': '255.255.255.0', 'gw': '192.168.0.1'}}}

2019-10-12 00:05:18 DEBUG (SyncWorker_6) [miio.device] 192.168.0.118:54321 >>: {'id': 1, 'method': 'get_prop', 'params': ['power', 'mode', 'speed', 'roll_enable', 'roll_angle', 'time_off', 'light', 'beep_sound', 'child_lock']}

2019-10-12 00:05:18 DEBUG (SyncWorker_6) [miio.device] 192.168.0.118:54321 (ts: 1970-02-06 05:30:59, id: 1) << {'id': 1, 'result': [False, 'normal', 1, True, 140, 0, True, False, False]}

2019-10-12 00:05:19 ERROR (MainThread) [homeassistant.components.fan] xiaomi_miio_fan: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 292, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 448, in async_device_update
await self.async_update()
File "/config/custom_components/xiaomi_miio_fan/fan.py", line 445, in async_update
self._natural_mode = (state.natural_speed != 0)
AttributeError: 'FanStatusP5' object has no attribute 'natural_speed'

@syssi
Copy link
Owner

syssi commented Oct 11, 2019

My fault! Line 234 must be XiaomiFanP5 instead XiaomiFan. I will fix it ASAP.

@surpasstop
Copy link

I've change that you mentioned, and restore my setting, reboot
Then.. Error occured

xiaomi_miio_fan: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 292, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 448, in async_device_update
await self.async_update()
File "/config/custom_components/xiaomi_miio_fan/fan.py", line 616, in async_update
if state.direct_speed in range:
AttributeError: 'FanStatusP5' object has no attribute 'direct_speed'

@syssi
Copy link
Owner

syssi commented Oct 11, 2019

Fixed. Thanks for your time! :-)

@surpasstop
Copy link

All is working well. Thanks syssi!!

@syssi
Copy link
Owner

syssi commented Oct 11, 2019

Could provide some more testing/infos.

  1. I want to know the different speed values (min/max) of the P5. If you use the mi home app, how much different speed values can you choose from?

@syssi
Copy link
Owner

syssi commented Oct 11, 2019

You can add the second fan to the configuration again. Make sure to set the correct model or leave out the model parameter.

@surpasstop
Copy link

surpasstop commented Oct 11, 2019

min/max speed value is 1~100
Second fan was added and P5 fans all works fine now.

But V3 fans do not show speed level (level 1~4),
Is it correct [ATTR_SPEED] at the line 421, 459 ?
[ATTR_SPEED_LEVEL] shows speed level..

@syssi
Copy link
Owner

syssi commented Oct 11, 2019

The V3 has speed levels between 1 and 4. Should the P5 have the same speed levels? I will take a look at the speed levels of the V3.

@surpasstop
Copy link

surpasstop commented Oct 11, 2019

P5 level is 1 ~ 4 too, but
Level 1 : P5-1 V3-1
Level 2 : P5-35 V3-35
Level 3 : P5-70 V3-74
Level 4 : P5-100 V3-100

@syssi
Copy link
Owner

syssi commented Oct 11, 2019

I've added your values: 6901cce

And I've tried to fix the other fan level issues. Please give it a try!

@syssi
Copy link
Owner

syssi commented Oct 12, 2019

Side note: I will remove the sped levels (1-4) in future because HA supports "off", "low", "medium" and "high" only to be Google Home / Alexa comaptible. As soon as we use other values for the speed level the devices cannot be controlled via Alexa.

https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/fan/__init__.py#L40-L43
home-assistant/architecture#27

@syssi
Copy link
Owner

syssi commented Oct 12, 2019

Could you check both fans with the latest version of the component to make sure everything works fine now? Thanks in advance!

@surpasstop
Copy link

I'm sorry for late response
I applied your last code, all functions work fine,
except that I can't find attribute direct_speed at P5.
So I added ATTR_RAW_SPEED: "speed" below AVAILABLE_ATTRIBUTES_FAN_P5 = {
It works, thank you

@biscuitee
Copy link

hi, can the expert help to how to add newer xiaomi fan model into miio_fan? I have new model dmaker.fan.p9 and would like to control it via miio_fan . thanks in advanced

@syssi
Copy link
Owner

syssi commented Jul 19, 2020

Device support was added some time ago.

@syssi syssi closed this as completed Jul 19, 2020
@biscuitee
Copy link

Hi, I couldn't load the dmaker.fan.p9 using the latest xiaomi_miio_fan custom component. My HA reported the following error:

 Invalid config for [fan.xiaomi_miio_fan]: value is not allowed for dictionary value @ data['model']. Got 'dmaker.fan.p9'. (See ?, line ?). 

@syssi
Copy link
Owner

syssi commented Jul 19, 2020

This issue is about the dmaker.fan.p5 (a miio device). You are asking about a dmaker.fan.p9 (a miot device) which isn't supported right now.

@fineemb
Copy link

fineemb commented Sep 6, 2020

Can your speed values ( raw speed, direct speed, natural speed )be obtained normally?

01

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