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

How its can integrate in hass.io ? #1

Closed
xrays72 opened this issue Oct 10, 2020 · 9 comments
Closed

How its can integrate in hass.io ? #1

xrays72 opened this issue Oct 10, 2020 · 9 comments

Comments

@xrays72
Copy link

xrays72 commented Oct 10, 2020

@swim2sun
Hello, thank you for your work.
Please write how its can integrate in hass.io ?

@swim2sun
Copy link
Owner

Hi @xrays72, this repo is my home assistant configuration, it's not a hass.io component.

Do you want integrate xiaomi_fan? If yes, the steps are like this:

You need do this on the machine where you installed your home assistant.

  1. Clone this repo (star this repo is better 😄)
  2. Uninstall the python-miio which installed by HA.
pip uninstall python-miio
  1. Install the python-miio provided by this repo
pip install libs/python_miio-0.5.3-py3-none-any.whl
  1. Copy the custom_components/xiaomi_miio_fan to your custom_components.
cp custom_components/xiaomi_miio_fan path/to/your/custom_components
  1. Add xiaomi_fan configuration to your configuration.yaml
fan:
  - platform: xiaomi_miio_fan
    name: xiaomi_fan
    host: 192.168.xx.xx
    token: xxxxxxxxxxxxxxx

Good luck!

@iquix
Copy link

iquix commented Oct 11, 2020

Thank you very much for your HA custom_component and pull request into python-miio for miot fan.

Is it possible to add support for dmaker-p11 fan?
http://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:fan:0000A005:dmaker-p11:1

@swim2sun
Copy link
Owner

@iquix Looks like the spec is similar to p9/p10, I can have a try when I have time

@iquix
Copy link

iquix commented Oct 12, 2020

@swim2sun Thank you so much!

@swim2sun
Copy link
Owner

Hi, @iquix , I updated libs/python_miio-0.5.3-py3-none-any.whl and custom_components/xiaomi_miio_fan for supporting p11, could you help to test it?

@iquix
Copy link

iquix commented Oct 17, 2020

@swim2sun
Thank you so much for your effort.

I tried to install this but I failed.

I'm using homeassistant with docker image homeassistant/raspberrypi3-homeassistant:stable, which is HA version 0.116.4
But when I try to install the miio whl with pip in the docker container, it gives me dependency error for 'cryptography'.

In homeassistant/raspberrypi3-homeassistant:stable docker image, python cryptography 2.9.2 is installed, but in the whl file, it requires python cryptography version >3.0.
So pip automatically tries to install cryptography 3.x version, but there's no gcc installed in the docker image, so it fails to install using pip.

I need to install gcc in the docker container to install cryptography 3.x, but its such a hard work, because HA docker image is a lightweight image, and it contains merely nothing.

I'll give it a try later, when I find out how to install python cryptography version >3.0 in docker container.

Anyway, thank you so much for your effort.

@iquix
Copy link

iquix commented Oct 17, 2020

I just changed dependency settings in the whl file to allow python cryptography 2.9.2, and installation was successful.

However, I cannot set the fan speed "level" , nor speed "level" is always fixed to "Level 1" . The reason is as follow.
This model does not have 0~100 level in the miot spec, so in the python-miio library fan_miot.py, it is defined as
speed=PropertyAdapter("fan", "fan-level"), which is in the range 1 to 4

But in the custom_component, line 579 in the fan.py
if speed in FAN_SPEED_VALUES:
speed = FAN_SPEED_VALUES[speed]

This part makes speed always "Level 1", because 'speed' is always in the range 1 to 4, and FAN_SPEED_VALUES is defined as
FAN_SPEED_VALUES = {
SPEED_OFF: 0,
FAN_SPEED_LEVEL1: 1,
FAN_SPEED_LEVEL2: 35,
FAN_SPEED_LEVEL3: 74,
FAN_SPEED_LEVEL4: 100,
}

Therefor, codes that uses FAN_SPEED_VALUES, as well as codes with FAN_SPEED_LIST needs to be fixed in the custom_compoent, since speed=PropertyAdapter("fan", "fan-level").

Again, thank you so much.

@iquix
Copy link

iquix commented Oct 17, 2020

Finally I successfully can control my P11 fan.

I found out that urn:miot-spec-v2:property:status:00000007:dmaker-p11:1, which is "siid":2,"piid":6 is speed 0~100.

So I modified fan_miot.py line 92 to
speed=PropertyAdapter("fan", "status")

and after that, without modifying the custom_component, everything works fine.

Thank you so much.

@swim2sun
Copy link
Owner

@iquix sry for the late reply. I'm glad that the component can work.

I'll fix the bug of setting speed, thx for your feedback.

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

3 participants