Closed mapledxf closed 3 years ago
Could you provide some details about the device?
It is a Mijia Air Fresher https://www.mi.com/fresh-air-ventilator/
I also have this device. Please let me know if I can help anything @syssi .
I also have this device. @syssi .
php miio-cli.php --ip 192.168.2.230 --info --token xxx {"id":7,"result":{"life":33055,"uid":1070947982,"model":"dmaker.airfresh.t2017","token":"xxx","fw_ver":"2.0.3","mcu_fw_ver":"0014","miio_ver":"0.0.3","hw_ver":"esp32","mmfree":68980,"mac":"7C:49:EB:58:D4:BF","wifi_fw_ver":"v3.1.3-8-gce4d3fe10","ap":{"rssi":-68,"ssid":"xxx","primary":11,"bssid":"D0:17:C2:DF:AE:68"},"netif":{"localIp":"192.168.2.230","mask":"255.255.255.0","gw":"192.168.2.1"},"miio_times":[33055,3,2,33050]}}
php miio-cli.php --ip 192.168.2.230 --token xxx --sendcmd '{"method":"get_prop",,"params":[],"id":1}' {"id":1,"result":[2,550,24,241,100,90,100,180,241,true,"favourite",false,"low",false,false,true,false,"forward"]}
php miio-cli.php --ip 192.168.2.230 --token xxx --sendcmd '{"method":"get_prop",,"params":["pm25","co2","temperature_outside","favourite_speed","filter_intermediate","filter_inter_day","filter_efficient","filter_effi_day","control_speed","power","mode","ptc_on","ptc_level","ptc_status","child_lock","sound","display","screen_direction"],"id":1}'
{"id":1,"result":[1,550,24,241,100,90,100,180,241,true,"favourite",false,"low",false,false,true,false,"forward"]}
properties = ["pm25","co2","temperature_outside","favourite_speed","filter_intermediate","filter_inter_day","filter_efficient","filter_effi_day","control_speed","power","mode","ptc_on","ptc_level","ptc_status","child_lock","sound","display","screen_direction"]
set_mode set_power set_ptc_level set_ptc_on set_ptc_timer set_room_area set_child_lock set_display set_sound set_screen_direction set_favorite set_favorite_area set_favourite_speed set_filter_reset set_increase_speed
I also have this device. @syssi .
Came accross the same issue. @syssi kindly ask you to add dmaker.airfresh.t2017 support.
Subscribe!
I also have that device. @syssi, if you need any information I would be happy to provide it
Also wait desperatelly! This device needs smarter automation via HA. If I can be of help contact me please.
Got it! https://bbs.hassbian.com/thread-8218-1-1.html This works!
Could somebody explain the get_timer
, get_ptc_timer
and the property ptc_level
and ptc_status
?
Could somebody explain the
get_timer
,get_ptc_timer
and the propertyptc_level
andptc_status
?
Unlike the XFXT01ZM model, this device has a built-in PTC (Positive Temperature Coefficient) heater. So I assume these values related to heater control. Unfortunately, my fresh air system still in transit and I can't assist with troubleshooting.
get_timer: unit can set a weekly operation timer [Daily, Working days, Weekends, Custom MON-SUN], power-on time and power-off time.
PTC is auxiliary heater for inlet air.
get_ptc_level: unit has 3 heating level [Level 1 (less heat), Level 2, Level 3 (more heat)].
get_ptc_timer: auxiliary heater can set a weekly timer [Daily, Working days, Weekends, Custom MON-SUN], power-on time and power-off time.
ptc_status: auxiliary heat function will be temporary turned off if outside temperature is above 20c.
Could you provide some response examples for
miiocli device --ip IP --token TOKEN raw_command get_timer "[]"
miiocli device --ip IP --token TOKEN raw_command get_ptc_timer "[]"
miiocli device --ip IP --token TOKEN raw_command get_prop "['ptc_status', 'ptc_on', 'ptc_status']"
plus description? I want to understand the format of the responses. This is all in know:
value = time.index + '-' +
time.hexSum + '-' +
time.startTime + '-' +
time.ptcTimer.endTime + '-' +
time.level + '-' +
time.status;
return self.send("set_ptc_timer", [value])
raw_command get_timer "[]"
Running command raw_command
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']
raw_command get_ptc_timer "[]"
Running command raw_command
[' ']
Currently I have no timer / ptc_timer set. I will set various timer and get value again to find a format.
raw_command get_prop "['pm25', 'co2', 'temperature_outside', 'favourite_speed', 'filter_intermediate', 'filter_inter_day', 'filter_efficient', 'filter_effi_day', 'control_speed', 'power', 'mode', 'ptc_on', 'ptc_level', 'ptc_status', 'child_lock', 'sound', 'display', 'screen_direction']"
Running command raw_command
[25, 649, 27, 240, 70, 63, 85, 153, 240, True, 'auto', False, 'low', False, False, True, True, 'forward']
Could you set some timer just for testing? If you change the favorite area setting which property changes?
raw_command get_timer "[]"
Running command raw_command
['3e-08:00-09:00-enable', 'c0-09:30-10:30-enable', 'fe-11:00-99:99-enable', '2a-99:99-12:00-enable', '02-13:00-99:99-disable', '04-99:99-14:00-disable', '08-16:00-99:99-disable', '80-99:99-17:00-disable', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']
raw_command get_ptc_timer "[]"
Running command raw_command
['fe-21:00-08:00-null-enable']
Favorite area settings will change favourite_speed
. Value range is from 60 to 300, same as OperationMode
(0=OFF).
Good job! Thanks for your support!
I tested each command and here are results.
commands that work:
get_ptc_timer
get_timer
info
set_display_orientation
commands with errors:
miiocli airfresht2017 --ip IP --token TOKEN on
Powering on
Error: {'code': -9999, 'message': 'user ack timeout'}
miiocli airfresht2017 --ip IP --token TOKEN off
Powering off
Error: {'code': -9999, 'message': 'user ack timeout'}
miiocli airfresht2017 --ip IP --token TOKEN set_buzzer true
Turning on buzzer
Error: {'code': -9999, 'message': 'user ack timeout'}
miiocli airfresht2017 --ip IP --token TOKEN set_buzzer false
Turning off buzzer
Error: {'code': -9999, 'message': 'user ack timeout'}
miiocli airfresht2017 --ip IP --token TOKEN set_child_lock true
Turning on child lock
Error: {'code': -9999, 'message': 'user ack timeout'}
cset_child_lock false
Turning off child lock
Error: {'code': -9999, 'message': 'user ack timeout'}
miiocli airfresht2017 --ip IP --token TOKEN set_display true
Traceback (most recent call last):
File "/usr/local/bin/miiocli", line 11, in <module>
sys.exit(create_cli())
File "/usr/local/lib/python3.6/dist-packages/miio/cli.py", line 44, in create_cli
return cli(auto_envvar_prefix="MIIO")
File "/usr/local/lib/python3.6/dist-packages/miio/click_common.py", line 59, in __call__
return self.main(*args, **kwargs)
File "/home/administrator/.local/lib/python3.6/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/home/administrator/.local/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/administrator/.local/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/administrator/.local/lib/python3.6/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/administrator/.local/lib/python3.6/site-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 275, in wrap
msg = msg_fmt(**kwargs)
TypeError: <lambda>() got an unexpected keyword argument 'display'
miiocli airfresht2017 --ip IP --token TOKEN set_display false
Traceback (most recent call last):
File "/usr/local/bin/miiocli", line 11, in <module>
sys.exit(create_cli())
File "/usr/local/lib/python3.6/dist-packages/miio/cli.py", line 44, in create_cli
return cli(auto_envvar_prefix="MIIO")
File "/usr/local/lib/python3.6/dist-packages/miio/click_common.py", line 59, in __call__
return self.main(*args, **kwargs)
File "/home/administrator/.local/lib/python3.6/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/home/administrator/.local/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/administrator/.local/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/administrator/.local/lib/python3.6/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/administrator/.local/lib/python3.6/site-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 275, in wrap
msg = msg_fmt(**kwargs)
TypeError: <lambda>() got an unexpected keyword argument 'display'
set_ptc_level to low
medium
high
are ok, error only to off
.
miiocli airfresht2017 --ip IP --token TOKEN set_ptc_level off
Setting ptc level to 'off'
Error: {'code': -9999, 'message': 'user ack timeout'}
miiocli airfresht2017 --ip IP --token TOKEN set_ptc_timer
Running command set_ptc_timer
Traceback (most recent call last):
File "/usr/local/bin/miiocli", line 11, in <module>
sys.exit(create_cli())
File "/usr/local/lib/python3.6/dist-packages/miio/cli.py", line 44, in create_cli
return cli(auto_envvar_prefix="MIIO")
File "/usr/local/lib/python3.6/dist-packages/miio/click_common.py", line 59, in __call__
return self.main(*args, **kwargs)
File "/home/administrator/.local/lib/python3.6/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/home/administrator/.local/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/administrator/.local/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/administrator/.local/lib/python3.6/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/administrator/.local/lib/python3.6/site-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 280, in wrap
kwargs["result"] = func(*args, **kwargs)
File "/home/administrator/.local/lib/python3.6/site-packages/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/home/administrator/.local/lib/python3.6/site-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 245, in command_callback
return miio_command.call(miio_device, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/miio/click_common.py", line 193, in call
return method(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/miio/airfresh_t2017.py", line 408, in set_ptc_timer
raise NotImplementedError()
NotImplementedError
Some status has extra prefix. This Airfresh has 2 filters, in APP they are called Filter and Filter Pro. If we call one filter as Upper
, shall we call another as Lower
? (Both are dust filters.)
miiocli airfresht2017 --ip IP --token TOKEN status Power: on Mode: OperationMode.Favorite PM2.5: 17 CO2: 565 Temperature: 24 Favorite speed: 240 Control speed: 240 Dust filter life: 70 %, 63 days Upper filter life remaining: 85 %, 153 days PTC: False PTC level: PtcLevel.Medium PTC status: False Child lock: False Buzzer: True Display: True Display orientation: DisplayOrientation.Portrait
Spelling is not inline with other usage (should map raw returned favourite
to favorite
).
miiocli airfresht2017 --ip IP --token TOKEN set_mode favorite Setting mode to 'favourite' ['ok']
No help text explain possible value (60-300)
miiocli airfresht2017 --ip IP --token TOKEN set_favorite_speed Usage: miiocli airfresht2017 set_favorite_speed [OPTIONS] SPEED Try "miiocli airfresht2017 set_favorite_speed --help" for help.
Error: Missing argument "SPEED".
miiocli airfresht2017 --ip IP --token TOKEN set_favorite_speed 301 Setting favorite speed to 301 Error: Invalid favorite speed: 301
Command that not test yet:
reset_dust_filter
reset_upper_filter
Missing command set_timer
?
Any update on this one?
edit: Seems that python-miio has full support of dmaker.airfresh.t2017 now. Only lack of time to learn python stops me currently of making merge request :_(
Excuse me, just to make things clear: you plan no support for this model?
The device will be supported some day.
I am trying to complement the compatibility of the device, but I encountered difficulties that not all commands are being worked out(I get this response from device DeviceError: {'code': -9999, 'message': 'user ack timeout'} ). And also I can not compose an automation to switch the ptc_level mode.
Could you tell me the entity id of the device at your HA instance?
Could you create a pull request?
Are you able to control the PTC via the MiHome app? Do you have an external heater attached?
Are you able to control the PTC via the MiHome app? Do you have an external heater attached?
The heater is internal to the device. MiHome allows us to set 3 levels and turns it off completely.
These commands should work:
miiocli airfresht2017 --ip IP --token TOKEN set_ptc_on on
miiocli airfresht2017 --ip IP --token TOKEN set_ptc_on off
miiocli airfresht2017 --ip IP --token TOKEN set_ptc_level low
miiocli airfresht2017 --ip IP --token TOKEN set_ptc_level medium
miiocli airfresht2017 --ip IP --token TOKEN set_ptc_level high
Please give it a try.
➜ ~ miiocli airfresht2017 --ip 192.168.31.36 --token xxxx set_ptc_level high
Setting ptc level to 'high'
[11]
➜ ~ miiocli airfresht2017 --ip 192.168.31.36 --token xxxx set_ptc_level medium
Setting ptc level to 'medium'
[11]
➜ ~ miiocli airfresht2017 --ip 192.168.31.36 --token xxxx set_ptc_level low
Setting ptc level to 'low'
[11]
➜ ~ miiocli airfresht2017 --ip 192.168.31.36 --token xxxx set_ptc_level off
Setting ptc level to 'off'
Error: {'code': -9999, 'message': 'user ack timeout'}
➜ ~ miiocli airfresht2017 --ip 192.168.31.36 --token xxxx set_ptc_level off
Setting ptc level to 'off'
Error: {'code': -9999, 'message': 'user ack timeout'}
➜ ~ miiocli airfresht2017 --ip 192.168.31.36 --token xxxx set_ptc_level off
Setting ptc level to 'off'
Error: {'code': -9999, 'message': 'user ack timeout'}
➜ ~ miiocli airfresht2017 --ip 192.168.31.36 --token xxxx set_ptc_level off
Setting ptc level to 'off'
Error: {'code': -9999, 'message': 'user ack timeout'}
There is no such command like set_ptc_on available.
➜ ~ miiocli airfresht2017
Usage: miiocli airfresht2017 [OPTIONS] COMMAND [ARGS]...
Options:
--ip TEXT [required]
--token TEXT [required]
--help Show this message and exit.
Commands:
get_ptc_timer Returns a list of PTC timers.
get_timer Response unknown.
info Get miIO protocol information from the device.
off Power off.
on Power on.
raw_command Send a raw command to the device.
reset_dust_filter Resets filter lifetime of the dust filter.
reset_upper_filter Resets filter lifetime of the upper filter.
set_buzzer Set sound on/off.
set_child_lock Set child lock on/off.
set_display Turn led on/off.
set_display_orientation Set display orientation.
set_favorite_speed Storage register to enable extra features at the...
set_mode Set mode.
set_ptc_level Set PTC level.
set_ptc_timer value = time.index + '-' + time.hexSum + '-' +...
status Retrieve properties.
Power: off
Mode: OperationMode.Sleep
PM2.5: 4
CO2: 400
Temperature: 9
Favorite speed: 203
Control speed: 0
Dust filter life: 61 %, 54 days
Upper filter life remaining: 81 %, 145 days
PTC: True
PTC level: PtcLevel.Low
PTC status: True
Child lock: False
Buzzer: True
Display: False
Display orientation: DisplayOrientation.Portrait
bash-5.0# miiocli airfresht2017 --ip 172.16.112.52 --token TOKEN set_ptc_on on
Usage: miiocli airfresht2017 [OPTIONS] COMMAND [ARGS]...
Try 'miiocli airfresht2017 --help' for help.
Error: Unknown command (set_ptc_on)
bash-5.0# miiocli airfresht2017 --ip 172.16.112.52 --token TOKEN set_ptc_on off
Usage: miiocli airfresht2017 [OPTIONS] COMMAND [ARGS]...
Try 'miiocli airfresht2017 --help' for help.
Error: Unknown command (set_ptc_on)
bash-5.0# miiocli airfresht2017 --ip 172.16.112.52 --token TOKEN set_ptc_level low
Setting ptc level to 'low'
[9]
bash-5.0# miiocli airfresht2017 --ip 172.16.112.52 --token TOKEN set_ptc_level medium
Setting ptc level to 'medium'
[9]
bash-5.0# miiocli airfresht2017 --ip 172.16.112.52 --token TOKEN set_ptc_level high
Setting ptc level to 'high'
[9]
It seems set_ptc_on command doesn't work
Alright. I will check set_ptc_on
.
This is a bug and can be fixed easily.
What do you prefer: Two commands (set_ptc_on and set_ptc_level) or a combined command (set_ptc_level off/low/medium/high). Would be set_ptc_level on
useful?
➜ projects git:(develop) miiocli airfresht2017 --ip 192.168.31.36 --token xxxxx set_ptc_level
Usage: miiocli airfresht2017 set_ptc_level [OPTIONS] PTC_LEVEL
Try 'miiocli airfresht2017 set_ptc_level --help' for help.
Error: Missing argument 'PTC_LEVEL'. Choose from:
high,
low,
medium,
off.
I think there should not be such a command like set_ptc_on (on|off). Its good how it is, though should be fixed.
What do you prefer: Two commands (set_ptc_on and set_ptc_level) or a combined command (set_ptc_level off/low/medium/high). Would be
set_ptc_level on
useful?
set_ptc_on is useful because when you need PTC you don't have to memorize which the last mode was used, you just turn it on.
This PR introduces a new command: https://github.com/rytilahti/python-miio/pull/853
Could somebody test miiocli
of the current master
of python-miio
? I would like to know the new command is working fine.
2020-11-05 17:36:03 DEBUG (SyncWorker_7) [miio.miioprotocol] 192.168.1.108:54321 >>: {'id': 433, 'method': 'set_display', 'params': ['on']} 2020-11-05 17:36:07 DEBUG (SyncWorker_7) [miio.miioprotocol] 192.168.1.108:54321 (ts: 1970-01-08 20:19:39, id: 433) << {'id': 433, 'error': {'code': -9999, 'message': 'user ack timeout'}}
But the command set_favourite_speed I added works 2020-11-05 17:38:16 DEBUG (SyncWorker_14) [miio.miioprotocol] 192.168.1.36:54321 >>: {'id': 439, 'method': 'set_favourite_speed', 'params': [103]} 2020-11-05 17:38:16 DEBUG (SyncWorker_14) [miio.miioprotocol] 192.168.1.36:54321 (ts: 1970-01-19 05:14:35, id: 439) << {'id': 439, 'result': ['ok'], 'exe_time': 200}
@vartom It assume the command expects True
and False
instead on
and off
. Could you try this:
miiocli device --ip IP --token TOKEN raw_command set_display "[True]"
miiocli device --ip IP --token TOKEN raw_command set_display "[False]"
@syssi It works! DEBUG:miio.miioprotocol:192.168.1.108:54321 >>: {'id': 1, 'method': 'set_display', 'params': ['true']} DEBUG:miio.miioprotocol:192.168.1.108:54321 (ts: 1970-01-08 20:33:43, id: 1) << {'id': 1, 'result': ['ok']}
It looks like it needs to be fixed here https://github.com/rytilahti/python-miio/blob/master/miio/airfresh_t2017.py#L310
2020-11-05 17:57:15 DEBUG (SyncWorker_10) [miio.miioprotocol] 192.168.1.108:54321 >>: {'id': 3, 'method': 'set_display', 'params': ['false']} 2020-11-05 17:57:15 DEBUG (SyncWorker_10) [miio.miioprotocol] 192.168.1.108:54321 (ts: 1970-01-08 20:40:47, id: 3) << {'id': 3, 'result': ['ok']}
2020-11-05 17:57:23 DEBUG (SyncWorker_14) [miio.miioprotocol] 192.168.1.108:54321 >>: {'id': 6, 'method': 'set_sound', 'params': ['false']} 2020-11-05 17:57:23 DEBUG (SyncWorker_14) [miio.miioprotocol] 192.168.1.108:54321 (ts: 1970-01-08 20:40:56, id: 6) << {'id': 6, 'result': ['ok']}
fixed!!!
@vartom Could you test the other methods using "on" and "off", too? Thanks! :-)
2020-11-05 17:36:03 DEBUG (SyncWorker_7) [miio.miioprotocol] 192.168.1.108:54321 >>: {'id': 433, 'method': 'set_display', 'params': ['on']} 2020-11-05 17:36:07 DEBUG (SyncWorker_7) [miio.miioprotocol] 192.168.1.108:54321 (ts: 1970-01-08 20:19:39, id: 433) << {'id': 433, 'error': {'code': -9999, 'message': 'user ack timeout'}} As I mentioned earlier, "on" and "off" do not work.
and also 2020-11-05 18:04:21 DEBUG (SyncWorker_14) [miio.miioprotocol] 192.168.1.108:54321 >>: {'id': 1157, 'method': 'set_child_lock', 'params': ['true']} 2020-11-05 18:04:21 DEBUG (SyncWorker_14) [miio.miioprotocol] 192.168.1.108:54321 (ts: 1970-01-08 20:47:53, id: 1157) << {'id': 1157, 'result': ['ok']}
2020-11-05 18:04:39 DEBUG (SyncWorker_7) [miio.miioprotocol] 192.168.1.108:54321 >>: {'id': 1162, 'method': 'set_child_lock', 'params': ['false']} 2020-11-05 18:04:40 DEBUG (SyncWorker_7) [miio.miioprotocol] 192.168.1.108:54321 (ts: 1970-01-08 20:48:12, id: 1162) << {'id': 1162, 'result': ['ok']}
Could you test set_power
and set_child_lock
, too?
Unsupported device found! Please create an issue at https://github.com/syssi/xiaomi_airpurifier/issues and provide the following data: dmaker.airfresh.t2017