syssi / xiaomi_airpurifier

Xiaomi Mi Air Purifier and Xiaomi Mi Air Humidifier integration for Home Assistant
Apache License 2.0
451 stars 111 forks source link

Add support for deerma.humidifier.mjjsq #40

Closed tehnoinstyle closed 4 years ago

tehnoinstyle commented 4 years ago

Hello. Please, add support for deerma.humidifier.mjjsq

I have such a humidifier (deerma.humidifier.mjjsq). https://ru.aliexpress.com/item/4000056420604.html?spm=a2g0s.9042311.0.0.71e033ed6TUs5o

But I could not add it to the hass.io.

I get the following error:

2019-11-28 22:19:43 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for xiaomi_miio which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant. 2019-11-28 22:19:43 ERROR (MainThread) [custom_components.fan.fan] Unsupported device found! Please create an issue at https://github.com/syssi/xiaomi_airpurifier/issues and provide the following data: **deerma.humidifier.mjjsq**

How do I add it to hass.io? Thanks.

tehnoinstyle commented 4 years ago

Now:

C:\Users\albina>miiocli device --ip 192.168.1.204 --token 1759ffeef59e788e2794e6d3632a554d raw_command get_prop "['Humidifier_Gear','Humidity_Value','HumiSet_Value','Led_State','OnOff_State','TemperatureValue','TipSound_State','waterstatus','watertankstatus']"

Running command raw_command [4]

C:\Users\albina>miiocli airhumidifiermjjsq --ip 192.168.1.204 --token 1759ffeef59e788e2794e6d3632a554d status

Traceback (most recent call last):

File "C:\Users\albina\AppData\Local\Programs\Python\Python38-32\Scripts\miiocli-script.py", line 11, in <module> load_entry_point('python-miio==0.4.7', 'console_scripts', 'miiocli')()

File "c:\users\albina\appdata\local\programs\python\python38-32\lib\site-packages\miio\cli.py", line 44, in create_cli return cli(auto_envvar_prefix="MIIO")

File "c:\users\albina\appdata\local\programs\python\python38-32\lib\site-packages\miio\click_common.py", line 59, in __call__ return self.main(*args, **kwargs)

File "c:\users\albina\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 717, in main rv = self.invoke(ctx)

File "c:\users\albina\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx))

File "c:\users\albina\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx))

File "c:\users\albina\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 956, in invoke return ctx.invoke(self.callback, **ctx.params)

File "c:\users\albina\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 555, in invoke return callback(*args, **kwargs)

File "c:\users\albina\appdata\local\programs\python\python38-32\lib\site-packages\miio\click_common.py", line 285, in wrap result_msg = result_msg_fmt.format(**kwargs)

AttributeError: 'AirHumidifierMjjsqStatus' object has no attribute 'led_brightness'

C:\Users\albina>miiocli airhumidifiermjjsq --ip 192.168.1.204 --token 1759ffeef59e788e2794e6d3632a554d info

Model: deerma.humidifier.mjjsq Hardware version: ESP8266 Firmware version: 1.4.0 Network: {'localIp': '192.168.1.204', 'mask': '255.255.255.0', 'gw': '192.168.1.1'} AP: {'rssi': -49, 'ssid': 'Temponary', 'bssid': 'B8:69:F4:C7:12:CD'}

syssi commented 4 years ago

Okay. The status call doesn't work. What about the other methods?

tehnoinstyle commented 4 years ago

C:\Users\albina>miiocli airhumidifiermjjsq --ip 192.168.1.204 --token 1759ffeef59e788e2794e6d3632a554d on

Powering on ['ok']

C:\Users\albina>miiocli airhumidifiermjjsq --ip 192.168.1.204 --token 1759ffeef59e788e2794e6d3632a554d off

Powering off ['ok']

tehnoinstyle commented 4 years ago

C:\Users\albina>miiocli airhumidifiermjjsq --ip 192.168.1.204 --token 1759ffeef59e788e2794e6d3632a554d set_buzzer 0

Turning off buzzer ['ok']

C:\Users\albina>miiocli airhumidifiermjjsq --ip 192.168.1.204 --token 1759ffeef59e788e2794e6d3632a554d set_buzzer 1

Turning on buzzer ['ok']

C:\Users\albina>miiocli airhumidifiermjjsq --ip 192.168.1.204 --token 1759ffeef59e788e2794e6d3632a554d set_led 0

Turning off LED ['ok']

C:\Users\albina>miiocli airhumidifiermjjsq --ip 192.168.1.204 --token 1759ffeef59e788e2794e6d3632a554d set_led 1

Turning on LED ['ok']

These commands work correctly.

syssi commented 4 years ago

Could you provide the (debug) output of:

miiocli -d airhumidifiermjjsq --ip 192.168.1.204 --token 1759ffeef59e788e2794e6d3632a554d status
syssi commented 4 years ago

I've fixed an issue. Please update and try the status call again:

pip3 install https://github.com/syssi/python-miio/archive/feature/deerma-humidifier-mjjsq-support.zip -U
miiocli -d airhumidifiermjjsq --ip 192.168.1.204 --token 1759ffeef59e788e2794e6d3632a554d status
tehnoinstyle commented 4 years ago

Yes!

C:\Users\albina>miiocli -d airhumidifiermjjsq --ip 192.168.1.204 --token 1759ffeef59e788e2794e6d3632a554d status

INFO:miio.cli:Debug mode active DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b'' DEBUG:miio.device:Got a response: Container: data = Container: data = b'' (total 0) value = b'' (total 0) offset1 = 32 offset2 = 32 length = 0 header = Container: data = b'!1\x00 \x00\x00\x00\x00\x10Xrd\x00\r\xe0U' (total 16) value = Container: length = 32 unknown = 0 device_id = b'\x10Xrd' (total 4) ts = 1970-01-11 12:36:37 offset1 = 0 offset2 = 16 length = 16 checksum = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' (total 16) DEBUG:miio.device:Discovered 10587264 with ts: 1970-01-11 12:36:37, token: b'00000000000000000000000000000000' DEBUG:miio.device:192.168.1.204:54321 >>: {'id': 1, 'method': 'get_prop', 'params': ['OnOff_State']} DEBUG:miio.device:192.168.1.204:54321 (ts: 1970-01-11 12:36:38, id: 1) << {'result': [0], 'id': 1} DEBUG:miio.device:192.168.1.204:54321 >>: {'id': 2, 'method': 'get_prop', 'params': ['TemperatureValue']} DEBUG:miio.device:192.168.1.204:54321 (ts: 1970-01-11 12:36:38, id: 2) << {'result': [20], 'id': 2} DEBUG:miio.device:192.168.1.204:54321 >>: {'id': 3, 'method': 'get_prop', 'params': ['Humidity_Value']} DEBUG:miio.device:192.168.1.204:54321 (ts: 1970-01-11 12:36:38, id: 3) << {'result': [50], 'id': 3} DEBUG:miio.device:192.168.1.204:54321 >>: {'id': 4, 'method': 'get_prop', 'params': ['HumiSet_Value']} DEBUG:miio.device:192.168.1.204:54321 (ts: 1970-01-11 12:36:38, id: 4) << {'result': [54], 'id': 4} DEBUG:miio.device:192.168.1.204:54321 >>: {'id': 5, 'method': 'get_prop', 'params': ['Humidifier_Gear']} DEBUG:miio.device:192.168.1.204:54321 (ts: 1970-01-11 12:36:38, id: 5) << {'result': [4], 'id': 5} DEBUG:miio.device:192.168.1.204:54321 >>: {'id': 6, 'method': 'get_prop', 'params': ['Led_State']} DEBUG:miio.device:192.168.1.204:54321 (ts: 1970-01-11 12:36:38, id: 6) << {'result': [1], 'id': 6} DEBUG:miio.device:192.168.1.204:54321 >>: {'id': 7, 'method': 'get_prop', 'params': ['TipSound_State']} DEBUG:miio.device:192.168.1.204:54321 (ts: 1970-01-11 12:36:38, id: 7) << {'result': [1], 'id': 7} DEBUG:miio.device.device:192.168.1.204:54321 >>: {'id': 8, 'method': 'get_prop', 'params': ['waterstatus']} DEBUG:miio.device:192.168.1.204:54321 (ts: 1970-01-11 12:36:39, id: 8) << {'result': [1], 'id': 8} DEBUG:miio.device:192.168.1.204:54321 >>: {'id': 9, 'method': 'get_prop', 'params': ['watertankstatus']} DEBUG:miio.device:192.168.1.204:54321 (ts: 1970-01-11 12:36:39, id: 9) << {'result': [1], 'id': 9} Power: off Mode: OperationModeMjjsq.Humidity Temperature: 20 °C Humidity: 50 % LED: True Buzzer: True Target humidity: 54 % No water: False Water tank detached: False

syssi commented 4 years ago

Perfect! Could you acknowledge every command is doing the right thing? For example: If you enable the buzzer does your device beep on very key press afterwards?

syssi commented 4 years ago

Does the status LED turn on/off correctly?

tehnoinstyle commented 4 years ago

Yes, every command is doing the right thing!

tehnoinstyle commented 4 years ago

Hello, Sebastian.

Is there any news?

syssi commented 4 years ago

No. It will take some time to implement everything.

tehnoinstyle commented 4 years ago

Oh. How long can the implementation take?

I will really wait! Thanks.

syssi commented 4 years ago

I've updated the custom component. Please give it a try!

tehnoinstyle commented 4 years ago

Perfect!

I can try after 16:00 (now I'm not at home). It is very interesting.

My question is (I am new in HA): how to install a custom component correctly?

  1. Should I copy the directory /xiaomi_miio/ (and 3 files contained in this directory) to the /custom_component/ directory?

  2. Or just copy 3 files from directory /xiaomi_miio/ to the /custom_component/ directory? (I did it the last time I tried it, a week ago).

And then I add in configuration.yaml:

fan:
  - platform: xiaomi_miio
    name:
    host:
    token:
    model:

How right?

Thanks.

syssi commented 4 years ago

Option 1. The directory structure is important. Your configuration example is fine.

tehnoinstyle commented 4 years ago

OK. I will write you when I am ready to try!

tehnoinstyle commented 4 years ago

I decided to try now, remotely, from the office.

I added a directory /xiaomi_miio/ (and 3 files contained in this directory) to the /custom_component/ directory in my server. Correctly?

And add in configuration.yaml:

fan:
   - platform: xiaomi_miio
     name: Xiaomi Air Humidifier
     host: 192.168.1.204
     token: 1759ffeef59e788e2794e6d3632a554d
     model: deerma.humidifier.mjjsq

Correctly? Now I have to restart the server and the device should appear. Correctly?

tehnoinstyle commented 4 years ago

Got the following:

Platform error fan.xiaomi_miio - No module named 'custom_components.fan'
14:44 components/hassio/__init__.py (ERROR)

You are using a custom integration for xiaomi_miio which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.

14:44 loader.py (WARNING)
Error handling request
1:03 /usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py (ERROR) - первое сообщение получено 1:03 и повторялось 2 раз

Exception occurred:
6 декабря 2019 г., 17:51 /usr/local/lib/python3.7/site-packages/zeroconf.py (WARNING)
syssi commented 4 years ago

Did you copy the xiaomi_miio directory? The structure must be:

configuration.yaml
custom_components/
custom_components/xiaomi_miio
custom_components/xiaomi_miio/__init__.py
custom_components/xiaomi_miio/fan.py
custom_components/xiaomi_miio/manifest.json
tehnoinstyle commented 4 years ago

yes, I copy the xiaomi_miio directory to custom_component/ directory.

but in configuration.yaml I add only:

fan:
   - platform: xiaomi_miio
     name: Xiaomi Air Humidifier
     host: 192.168.1.204
     token: 1759ffeef59e788e2794e6d3632a554d
     model: deerma.humidifier.mjjsq

I am not add this:

custom_components/
custom_components/xiaomi_miio
custom_components/xiaomi_miio/__init__.py
custom_components/xiaomi_miio/fan.py
custom_components/xiaomi_miio/manifest.json

Does this also need to be added to the configuration.yaml ?

syssi commented 4 years ago

I've posted a directory structure. Please provide a directory listing of your "custom_components" folder. Does a xiaomi_miio folder exist there?

tehnoinstyle commented 4 years ago

yes, only one xiaomi_miio (with 3 files inside) folder in my custom_components folder.

tehnoinstyle commented 4 years ago

Now got the following:

Invalid config for [fan.xiaomi_miio]: value is not allowed for dictionary value @ data['model']. Got 'deerma.humidifier.mjjsq'. (See /config/configuration.yaml, line 20). Please check the docs at https://home-assistant.io/integrations/xiaomi_miio/

tehnoinstyle commented 4 years ago

If I comment out the model

fan:
   - platform: xiaomi_miio
     name: Xiaomi Air Humidifier
     host: 192.168.1.204
     token: 1759ffeef59e788e2794e6d3632a554d
     #model: deerma.humidifier.mjjsq

got the following:

Unsupported device found! Please create an issue at https://github.com/syssi/xiaomi_airpurifier/issues and provide the following data: deerma.humidifier.mjjsq

syssi commented 4 years ago

This happens if the custom component cannot be found and the official one is used. There is still something wrong with your directory structure.

tehnoinstyle commented 4 years ago

On Synology:

/volume1/hass/hass.io/homeassistant/custom_components/xiaomi_miio/

tehnoinstyle commented 4 years ago

Hass.io package for Synology from: https://community.home-assistant.io/t/hass-io-on-synology-dsm-native-package/125559

tehnoinstyle commented 4 years ago

And there was another message:

2019-12-07 13:29:31 ERROR (SyncWorker_0) [homeassistant.loader] Error parsing manifest.json file at /config/custom_components/xiaomi_miio/manifest.json: Expecting value: line 8 column 5 (char 338)

syssi commented 4 years ago

Alright. This is a bug.

syssi commented 4 years ago

A official release of python-miio is required first. This will take a few days.

tehnoinstyle commented 4 years ago

Ok, I will be very looking forward release of python-miio. Thanks.

anhnvme commented 4 years ago

bump up, i just bough deerma.humidifier.mjjsq device, still waiting

thanks

tehnoinstyle commented 4 years ago

Hello, Sebastian.

Not ready yet? Yesterday a new release HA 0.103.0 was released.

anhnvme commented 4 years ago

Hello, Sebastian.

Not ready yet? Yesterday a new release HA 0.103.0 was released.

take a time, he said wait for next release of python-miio not HA :D i think few month

tehnoinstyle commented 4 years ago

i think few month

Why so long?

syssi commented 4 years ago

Please update the custom component and give it a try.

anhnvme commented 4 years ago

Please update the custom component and give it a try.

it's not working. i got this error

2019-12-13 08:23:15 ERROR (MainThread) [custom_components.xiaomi_miio_airpurifier.fan] Unsupported device found! Please create an issue at https://github.com/syssi/xiaomi_airpurifier/issues and provide the following data: deerma.humidifier.mjjsq

config fan.yml:

- platform: xiaomi_miio_airpurifier
  name: Xiaomi Air Hudimifier
  host: 192.168.10.53
  token: xxxxxxxxxxxxxxxxxxxxxxxxxx
  model: deerma.humidifier.mjjsq
tehnoinstyle commented 4 years ago

it's not working

2019-12-13 08:22:31 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for xiaomi_miio_airpurifier which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-12-13 08:22:46 ERROR (MainThread) [custom_components.xiaomi_miio_airpurifier.fan] Unsupported device found! Please create an issue at https://github.com/syssi/xiaomi_airpurifier/issues and provide the following data: deerma.humidifier.mjjsq
fan:
  - platform: xiaomi_miio_airpurifier
    name: Xiaomi Air Humidifier
    host: 192.168.1.204
    token: 1759ffeef59e788e2794e6d3632a554d
    model: deerma.humidifier.mjjsq
syssi commented 4 years ago

Fixed! Please try again.

tehnoinstyle commented 4 years ago

Yes! Work.

But:

You are using a custom integration for xiaomi_miio_airpurifier which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
tehnoinstyle commented 4 years ago
model deerma.humidifier.mjjsq
temperature 20
humidity 53
mode 3
buzzer true
target humidity 0
trans level -
button pressed -
child lock -
led brightness -
use time -
hardware version -
led true
no water false
water tank detached false
syssi commented 4 years ago

The warning is fine because it's an custom component.

tehnoinstyle commented 4 years ago

I understood.

syssi commented 4 years ago

Please update the component again. I've removed the unavailable attributes:

trans level -
button pressed -
child lock -
led brightness -
use time -
hardware version -
tehnoinstyle commented 4 years ago

now ok:

model deerma.humidifier.mjjsq
temperature 20
humidity 53
mode 3
buzzer true
target humidity 0
led true
no water false
water tank detached false
syssi commented 4 years ago

Fine. Please test the different services to make sure operation mode, buzzer, led and target humidity can be controlled.

tehnoinstyle commented 4 years ago

Ok, I test the different services, but only in the evening. I'm not near the humidifier right now to monitor its condition.

As soon as I am at home, I will test and let you know.

tehnoinstyle commented 4 years ago

Noob question. Please help me with the creation of humidity and temperature sensors from the Air Humidifier. How can I creat these sensors, and to use their data for integration with EmonCMS? I read the docks, but so far I could not understand. Used platform: template? Maybe there are ready examples of sensor configuration from the Air Humidifier?

When I add the Z-Wave gateway Vera Edge in Hassio, the humidity, temperature, light, etc. sensors connected to the gateway are automatically detected in the HA interface as sensors.

Thanks.

syssi commented 4 years ago

I've added an example to the README: https://github.com/syssi/xiaomi_airpurifier#template-sensor-example