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 dmaker.airfresh.a1 support #48

Open DmitryUdaltsov opened 4 years ago

DmitryUdaltsov commented 4 years ago

Unsupported device found! Please create an issue at https://github.com/syssi/xiaomi_airpurifier/issues and provide the following data: dmaker.airfresh.a1

Device: MJXFJ-150-A1 Web link: https://item.mi.com/product/11044.html

DmitryUdaltsov commented 4 years ago
DmitryUdaltsov commented 4 years ago
Traceback (most recent call last):
  File "/usr/local/bin/miiocli", line 11, in <module>
    load_entry_point('python-miio==0.4.5', 'console_scripts', 'miiocli')()
  File "/usr/local/lib/python3.6/dist-packages/miio/cli.py", line 43, in create_cli
    return cli(auto_envvar_prefix="MIIO")
  File "/usr/local/lib/python3.6/dist-packages/miio/click_common.py", line 54, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/miio/click_common.py", line 267, in wrap
    result_msg = result_msg_fmt.format(**kwargs)
  File "/usr/local/lib/python3.6/dist-packages/miio/airpurifier.py", line 142, in mode
    return OperationMode(self.data["mode"])
  File "/usr/lib/python3.6/enum.py", line 293, in __call__
    return cls.__new__(cls, value)
  File "/usr/lib/python3.6/enum.py", line 535, in __new__
    return cls._missing_(value)
  File "/usr/lib/python3.6/enum.py", line 548, in _missing_
    raise ValueError("%r is not a valid %s" % (value, cls.__name__))
ValueError: 79 is not a valid OperationMode
ilshatms commented 4 years ago

@syssi, hello! I also have dmaker.airfresh.a1. How can I help add a device? I see fresh activity with details here

syssi commented 3 years ago
Retrieve all properties: get_prop ["all"]

Could somebody provide the output of:

miiocli device --ip IP --token TOKEN info
miiocli device --ip IP --token TOKEN raw_command get_prop '["all"]'
ilshatms commented 3 years ago

@syssi , hello

admin@admin ~ % miiocli device --ip 192.168.0.100 --token ************************ info
Model: dmaker.airfresh.a1
Hardware version: esp8266
Firmware version: 2.1.0
Network: {'localIp': '192.168.0.100', 'mask': '255.255.255.0', 'gw': '192.168.0.1'}
AP: {'ssid': '********', 'bssid': '**:11:DC:49:**:**', 'rssi': -66, 'primary': 6}
admin@admin ~ % miiocli device --ip 192.168.0.100 --token ************************ raw_command get_prop '["all"]'
Running command raw_command
[2, 543, 10, 150, 45, 81, 60, True, 'auto', False, False, False, False, False]
syssi commented 3 years ago

@ilshatms Next step: Could you provide the output of:

# try to retrieve all properties again for comparison
miiocli device --ip IP --token TOKEN raw_command get_prop '["all"]'
# try to retrieve all property by name at once
miiocli device --ip IP --token TOKEN raw_command get_prop '["power", "pm25", "co2", "temperature_outside", "favourite_speed", "filter_rate", "filter_day", "control_speed", "ptc_on", "ptc_status", "child_lock", "sound", "display", "mode"]'

# try to retrieve 4 properties per request
miiocli device --ip IP --token TOKEN raw_command get_prop '["power", "pm25", "co2", "temperature_outside"]'
miiocli device --ip IP --token TOKEN raw_command get_prop '["favourite_speed", "filter_rate", "filter_day", "control_speed"]
miiocli device --ip IP --token TOKEN raw_command get_prop '["ptc_on", "ptc_status", "child_lock", "sound"]'
miiocli device --ip IP --token TOKEN raw_command get_prop '["display", "mode"]'

# please try to get an idea how much properties can be retrieved at once.

It looks like the dmaker.airfresh.a1 is very similar to the dmaker.airfresh.t2017.

ilshatms commented 3 years ago

@syssi done!

miiocli device --ip IP --token TOKEN raw_command get_prop '["all"]'

Running command raw_command
[2, 553, 13, 150, 45, 81, 60, True, 'auto', False, False, False, False, False]

miiocli device --ip IP --token TOKEN raw_command get_prop '["power", "pm25", "co2", "temperature_outside", "favourite_speed", "filter_rate", "filter_day", "control_speed", "ptc_on", "ptc_status", "child_lock", "sound", "display", "mode"]'

Running command raw_command
[True, 2, 554, 12, 150, 45, 81, 60, False, False, False, False, False, 'auto']

miiocli device --ip IP --token TOKEN raw_command get_prop '["power", "pm25", "co2", "temperature_outside"]'

Running command raw_command
[True, 2, 551, 12]

miiocli device --ip IP --token TOKEN raw_command get_prop '["favourite_speed", "filter_rate", "filter_day", "control_speed"]'

Running command raw_command
[120, 45, 81, 60]

miiocli device --ip IP --token TOKEN raw_command get_prop '["ptc_on", "ptc_status", "child_lock", "sound"]'

Running command raw_command
[False, False, False, False]

miiocli device --ip IP --token TOKEN raw_command get_prop '["display", "mode"]'

Running command raw_command
[False, 'auto']

miiocli device --ip IP --token TOKEN raw_command get_prop '["favourite_speed"]'

Running command raw_command
[120]

miiocli device --ip IP --token TOKEN raw_command get_prop '["filter_rate"]

Running command raw_command
[45]
syssi commented 3 years ago

Good job!

syssi commented 3 years ago
# Supported or not?
miiocli device --ip IP --token TOKEN raw_command get_prop '["screen_direction"]'
miiocli device --ip IP --token TOKEN raw_command get_prop '["ptc_level"]'
miiocli device --ip IP --token TOKEN raw_command set_ptc_level '["low"]'
miiocli device --ip IP --token TOKEN raw_command set_screen_direction '["right"]'
ilshatms commented 3 years ago

Аpparently not

miiocli device --ip IP --token TOKEN raw_command get_prop '["screen_direction"]'

Running command raw_command
[1, 530, 12, 120, 45, 81, 60, True, 'auto', False, False, False, False, False]

miiocli device --ip IP --token TOKEN raw_command get_prop '["ptc_level"]'

Running command raw_command
[1, 530, 11, 120, 45, 81, 60, True, 'auto', False, False, False, False, False]

miiocli device --ip IP --token TOKEN raw_command set_ptc_level '["low"]'

Error: Invalid value for '[PARAMETERS]': set_ptc_level is not a valid literal

miiocli device --ip IP --token TOKEN raw_command set_screen_direction '["right"]'

Error: Invalid value for '[PARAMETERS]': set_screen_direction is not a valid literal