GithubHelp home page GithubHelp logo

syssi / xiaomi_airpurifier Goto Github PK

View Code? Open in Web Editor NEW
446.0 24.0 109.0 459 KB

Xiaomi Mi Air Purifier and Xiaomi Mi Air Humidifier integration for Home Assistant

License: Apache License 2.0

Python 100.00%
airpurifier airhumidifier fan airfresh xiaomi miio-protocol miot miio home-assistant custom-component

xiaomi_airpurifier's Introduction

Xiaomi Mi Air Purifier & Xiaomi Mi Air Humidifier

GitHub actions GitHub stars GitHub forks GitHub watchers "Buy Me A Coffee"

This is a custom component for home assistant to integrate the Xiaomi Mi Air Purifier 2, Air Purifier 2S, Air Purifier Pro, Air Humidifier, Air Fresh and Pedestal Fan.

Please follow the instructions on Retrieving the Access Token to get the API token to use in the configuration.yaml file.

Credits: Thanks to Rytilahti for all the work.

What is the difference between this custom component and the one in Home Assistant Core?

This custom component is more or less the beta version of the official component. Furthermore, this custom component supports a number of additional devices which cannot be merged into the official component at the moment. The handling/values of the fan_speed property need to be refactored first because this and the official component don't align with some new architecture decisions.

Supported devices

Name Model Model no. Specs
Air Purifier zhimi.airpurifier.v1
Air Purifier 2 zhimi.airpurifier.v2 FJY4006CN, AC-M2-AA 37m2, 310m3/h CADR, 31W
Air Purifier V3 zhimi.airpurifier.v3
Air Purifier V5 zhimi.airpurifier.v5
Air Purifier Pro zhimi.airpurifier.v6
Air Purifier Pro V7 zhimi.airpurifier.v7
Air Purifier 2 (mini) zhimi.airpurifier.m1
Air Purifier (mini) zhimi.airpurifier.m2
Air Purifier MA1 zhimi.airpurifier.ma1
Air Purifier MA2 zhimi.airpurifier.ma2
Air Purifier 2S zhimi.airpurifier.mc1 XM200003(?), AC-M4-AA 37m2, 310m3/h CADR, 66dB, 29W (max)
Air Purifier 2H zhimi.airpurifier.mc2 FJY4026GL(?), AC-M9-AA 31m2, 260m3/h CADR, 66dB, 31W (max)
Air Purifier Super zhimi.airpurifier.sa1
Air Purifier Super 2 zhimi.airpurifier.sa2
Air Purifier 3 (2019) zhimi.airpurifier.ma4
Air Purifier 3H (2019) zhimi.airpurifier.mb3 FJY4031GL(?), XM200017 45m2, 380m3/h CADR, 64dB, 38W (max)
Air Purifier ZA1 zhimi.airpurifier.za1
Air Dog X3 airdog.airpurifier.x3
Air Dog X5 airdog.airpurifier.x5
Air Dog X7SM airdog.airpurifier.x7sm
Air Humidifier zhimi.humidifier.v1
Air Humidifier CA1 zhimi.humidifier.ca1 CJXJSQ02ZM, SKV6001RT 8W, 240x240x363mm
Smartmi Humidifier Evaporator 2 zhimi.humidifier.ca4 CJXJSQ04ZM
Smartmi Evaporative Humidifier zhimi.humidifier.cb1 CJXJSQ02ZM, SKV6001EU 8W, 240x240x363mm
Smartmi Evaporative Humidifier (Korea Version) zhimi.humidifier.cb2 CJXJSQ02ZM 8W, 240x240x363mm
Mijia Smart Sterilization Humidifier S deerma.humidifier.mjjsq MJJSQ03DY 4.5L, <=39dB, 450mL/h, 40W
Mijia Intelligent Sterilization Humidifier (EU version?) deerma.humidifier.jsq ZNJSQ01DEM 4.5L, <=38dB, 300mL/h, 24W
Mijia Smart Humidifier 2 (EU version) deerma.humidifier.jsq2w MJJSQ05DY 4.5L, <=32dB, 300mL/h, 28 W
Mijia Humidifier 4L deerma.humidifier.jsq3 MJJSQ04DY 4L, <=38dB, 300mL/h, 25W
Mijia Intelligent Sterilization Humidifier (EU version?) deerma.humidifier.jsq5 ZNJSQ01DEM 4.5L, <=38dB, 300mL/h, 24W
Mijia Smart Sterilization Humidifier S (EU version?) deerma.humidifier.jsqs MJJSQ03DY 4.5L, <=39dB, 450mL/h, 40W
Mijia Intelligent Sterilization Humidifier SCK0A45 deerma.humidifier.jsq1 SCKOA45, SCK0A45 4.5L, <=38dB, 300mL/h, 25W
Zero Fog Humidifier shuii.humidifier.jsq001
New Widetech Internet Dehumidifier nwt.derh.wdh318efw1 WDH318EFW1 2.7L tank, 38dB, 18L/d, 240W
Smartmi Fresh Air System XFXT01ZM zhimi.airfresh.va2 XFXT01ZM
Smartmi Fresh Air System XFXTDFR02ZM zhimi.airfresh.va4 XFXTDFR02ZM PTC/Heater support
Mi Fresh Air Ventilator dmaker.airfresh.t2017 MJXFJ-300-G1**?** 300m3/h (Air volume), 35W, 36db(A), 16kg
Mi Fresh Air Ventilator dmaker.airfresh.a1 MJXFJ-150-A1 150m3/h (Air volume), 20W, 36db(A), 8kg
Pedestal Fan Fan V2 zhimi.fan.v2
Pedestal Fan Fan V3 zhimi.fan.v3
Pedestal Fan Fan SA1 zhimi.fan.sa1
Pedestal Fan Fan ZA1 zhimi.fan.za1
Pedestal Fan Fan ZA3 zhimi.fan.za3
Pedestal Fan Fan ZA4 zhimi.fan.za4
Pedestal Fan Fan 1C dmaker.fan.1c
Pedestal Fan Fan P5 dmaker.fan.p5
Pedestal Fan Fan P8 dmaker.fan.p8
Pedestal Fan Fan P9 dmaker.fan.p9
Pedestal Fan Fan P10 dmaker.fan.p10
Mijia Pedestal Fan dmaker.fan.p11 BPLDS03DM 2800mAh, 24W, <=58dB
Rosou SS4 Ventilator leshow.fan.ss4

Unsupported devices:

  • Mijia Humidifer 4L (MJJSQ02LX): This device isn't smart / has no WiFi support.

Features

Air Purifier 2 et al.

  • Power (on, off)
  • Preset modes (auto, silent, favorite, idle)
  • Buzzer (on, off)
  • Child lock (on, off)
  • LED (on, off), LED brightness (bright, dim, off)
  • Favorite Level (0...16)
  • Attributes
    • model
    • temperature
    • humidity
    • aqi
    • mode
    • filter_hours_used
    • filter_life_remaining
    • favorite_level
    • child_lock
    • led
    • motor_speed
    • average_aqi
    • purify_volume
    • learn_mode
    • sleep_time
    • sleep_mode_learn_count
    • extra_features
    • turbo_mode_supported
    • auto_detect
    • use_time
    • button_pressed
    • buzzer
    • led_brightness
    • sleep_mode

Air Purifier 2H (zhimi.airpurifier.mc2)

  • Power (on, off)
  • Preset modes (auto, silent, favorite, idle)
  • Buzzer (on, off)
  • Child lock (on, off)
  • LED (on, off), LED brightness (bright, dim, off)
  • Favorite Level (0...16)
  • Attributes
    • model
    • temperature
    • humidity
    • aqi
    • mode
    • filter_hours_used
    • filter_life_remaining
    • favorite_level
    • child_lock
    • led
    • motor_speed
    • average_aqi
    • learn_mode
    • extra_features
    • turbo_mode_supported
    • buzzer
    • led_brightness

Air Purifier Pro (zhimi.airpurifier.v6)

  • Power (on, off)
  • Preset modes (auto, silent, favorite)
  • Child lock (on, off)
  • LED (on, off)
  • Favorite Level (0...16)
  • Attributes
    • model
    • temperature
    • humidity
    • aqi
    • mode
    • filter_hours_used
    • filter_life_remaining
    • favorite_level
    • child_lock
    • led
    • motor_speed
    • average_aqi
    • purify_volume
    • learn_mode
    • sleep_time
    • sleep_mode_learn_count
    • extra_features
    • turbo_mode_supported
    • auto_detect
    • use_time
    • button_pressed
    • filter_rfid_product_id
    • filter_rfid_tag
    • filter_type
    • illuminance
    • motor2_speed
    • volume

Air Purifier Pro V7 (zhimi.airpurifier.v7)

  • Power (on, off)
  • Preset modes (auto, silent, favorite)
  • Child lock (on, off)
  • LED (on, off)
  • Favorite Level (0...16)
  • Attributes
    • model
    • temperature
    • humidity
    • aqi
    • mode
    • filter_hours_used
    • filter_life_remaining
    • favorite_level
    • child_lock
    • led
    • motor_speed
    • average_aqi
    • learn_mode
    • extra_features
    • turbo_mode_supported
    • button_pressed
    • filter_rfid_product_id
    • filter_rfid_tag
    • filter_type
    • illuminance
    • motor2_speed
    • volume

Air Purifier 2S (zhimi.airpurifier.mc1) and 2H (zhimi.airpurifier.mc2)

  • Power (on, off)
  • Preset modes (auto, silent, favorite)
  • Buzzer (on, off)
  • Child lock (on, off)
  • LED (on, off)
  • Favorite Level (0...16)
  • Attributes
    • model
    • temperature
    • humidity
    • aqi
    • mode
    • filter_hours_used
    • filter_life_remaining
    • favorite_level
    • child_lock
    • led
    • motor_speed
    • average_aqi
    • learn_mode
    • extra_features
    • turbo_mode_supported
    • button_pressed
    • filter_rfid_product_id
    • filter_rfid_tag
    • filter_type
    • illuminance
    • buzzer

Air Purifier 3/3H (2019) (zhimi.airpurifier.ma4/zhimi.airpurifier.mb3)

This model uses newer MiOT communication protocol.

  • Power (on, off)
  • Preset modes (auto, silent, favorite, fan)
  • Buzzer (on, off)
  • Child lock (on, off)
  • LED (on, off)
  • Favorite Level (0...16)
  • Fan Level (1...3)
  • Attributes
    • model
    • temperature
    • humidity
    • aqi
    • mode
    • filter_hours_used
    • filter_life_remaining
    • favorite_level
    • child_lock
    • led
    • motor_speed
    • average_aqi
    • purify_volume
    • use_time
    • buzzer
    • led_brightness
    • filter_rfid_product_id
    • filter_rfid_tag
    • filter_type
    • fan_level

Air Purifier V3 (zhimi.airpurifier.v3)

  • Power (on, off)
  • Preset modes (auto, silent, favorite, idle, medium, high, strong)
  • Child lock (on, off)
  • LED (on, off)
  • Attributes
    • model
    • aqi
    • mode
    • led
    • buzzer
    • child_lock
    • illuminance
    • filter_hours_used
    • filter_life_remaining
    • motor_speed
    • average_aqi
    • volume
    • motor2_speed
    • filter_rfid_product_id
    • filter_rfid_tag
    • filter_type
    • purify_volume
    • learn_mode
    • sleep_time
    • sleep_mode_learn_count
    • extra_features
    • auto_detect
    • use_time
    • button_pressed

Air Humidifier (zhimi.humidifier.v1)

  • On, Off
  • Preset modes (silent, medium, high, strong)
  • Buzzer (on, off)
  • Child lock (on, off)
  • LED (on, off), LED brightness (bright, dim, off)
  • Target humidity (30, 40, 50, 60, 70, 80)
  • Attributes
    • model
    • temperature
    • humidity
    • mode
    • buzzer
    • child_lock
    • trans_level
    • target_humidity
    • led_brightness
    • button_pressed
    • use_time
    • hardware_version

Air Humidifier CA (zhimi.humidifier.ca1)

  • On, Off
  • Preset modes (silent, medium, high, auto)
  • Buzzer (on, off)
  • Child lock (on, off)
  • LED (on, off), LED brightness (bright, dim, off)
  • Target humidity (30, 40, 50, 60, 70, 80)
  • Dry mode (on, off)
  • Attributes
    • model
    • temperature
    • humidity
    • mode
    • buzzer
    • child_lock
    • trans_level
    • target_humidity
    • led_brightness
    • button_pressed
    • use_time
    • hardware_version
    • motor_speed
    • depth
    • dry

Air Humidifier CA4 (zhimi.humidifier.ca4)

  • On, Off
  • Preset modes (auto, low, mid, high)
  • Buzzer (on, off)
  • Child lock (on, off)
  • LED brightness (off, dim, bright)
  • Target humidity (30 - 80)
  • Dry mode (on, off)
  • Clean mode (on, off)
  • Motor speed rpm (200 - 2000)
  • Attributes
    • model
    • temperature
    • humidity
    • mode
    • buzzer
    • child_lock
    • target_humidity
    • led_brightness
    • use_time
    • actual_speed
    • button_pressed
    • dry
    • fahrenheit
    • motor_speed
    • power_time
    • water_level
    • use_time
    • clean_mode

Air Humidifier CB (zhimi.humidifier.cb1)

  • On, Off
  • Preset modes (silent, medium, high, auto)
  • Buzzer (on, off)
  • Child lock (on, off)
  • LED (on, off), LED brightness (bright, dim, off)
  • Target humidity (30, 40, 50, 60, 70, 80)
  • Dry mode (on, off)
  • Attributes
    • speed
    • speed_list
    • model
    • temperature
    • humidity
    • mode
    • buzzer
    • child_lock
    • target_humidity
    • led_brightness
    • use_time
    • hardware_version
    • motor_speed
    • depth
    • dry
    • supported_features

Zero Fog Humidifier (shuii.humidifier.jsq001)

  • Power (on, off)
  • Preset modes (Intelligent, Level1, Level2, Level3, Level4)
  • Buzzer (on, off)
  • Child lock (on, off)
  • LED (on, off), LED brightness (high, low, off)
  • Attributes
    • model
    • temperature
    • humidity
    • mode
    • buzzer
    • child_lock
    • led
    • led_brightness
    • no_water
    • lid_opened

Air Fresh VA2 and VA4 (zhimi.airfresh.va2, zhimi.airfresh.va4)

  • Power (on, off)
  • Preset modes (auto, silent, interval, low, middle, strong)
  • Buzzer (on, off)
  • Child lock (on, off)
  • LED (on, off), LED brightness (bright, dim, off)
  • PTC (on, off) (zhimi.airfresh.va4 only)
  • Attributes
    • model
    • aqi
    • average_aqi
    • temperature
    • humidity
    • co2
    • mode
    • led
    • led_brightness
    • buzzer
    • child_lock
    • filter_life_remaining
    • filter_hours_used
    • use_time
    • motor_speed
    • extra_features
    • ptc (zhimi.airfresh.va4 only)
    • ntc_temperature (zhimi.airfresh.va4 only)

Mi Fresh Air Ventilator (dmaker.airfresh.t2017, dmaker.airfresh.a1)

This paragraph was moved to docs/dmaker-airfresh-t2017.md.

Air Humidifier MJJSQ, JSQ1, JSQ5 and JSQS (deerma.humidifier.mjjsq, deerma.humidifier.jsq1, deerma.humidifier.jsq5, deerma.humidifier.jsqs)

  • Power (on, off)
  • Preset modes (low, medium, high, humidity)
  • Buzzer (on, off)
  • LED (on, off)
  • Target humidity (0...99)
  • Wet protection (on, off) (deerma.humidifier.jsq1 only)
  • Attributes
    • model
    • temperature
    • humidity
    • mode
    • buzzer
    • target_humidity
    • led
    • no_water
    • water_tank_detached
    • wet_protection (deerma.humidifier.jsq1 only)

Air Dehumidifier (nwt.derh.wdh318efw1)

  • HVAC mode (dry, off)
  • Preset modes (on, auto, dryCloth)
  • Target humidity (40, 50, 60)
  • Fan mode (sleep, low, medium, high, strong)
  • Buzzer (on, off)
  • Child lock (on, off)
  • LED (on, off)
  • Attributes
    • model
    • _current_temperature
    • humidity
    • mode
    • buzzer
    • child_lock
    • target_humidity
    • led
    • fan_speed
    • tank_full
    • compressor_status
    • defrost_status
    • fan_st
    • alarm

Pedestal Fan

  • Power (on, off)
  • Preset modes (Level 1, Level 2, Level 3, Level 4)
  • Speed percentage (0...100)
  • Oscillate (on, off)
  • Oscillation angle (30, 60, 90, 120, 140, 150)
  • Natural mode (on, off)
  • Rotate by 5 degrees (left, right)
  • Child lock (on, off)
  • LED brightness (bright, dim, off)
  • Attributes
    • model
    • temperature (zhimi.fan.v2 and v3 only)
    • humidity (zhimi.fan.v2 and v3 only)
    • led_brightness
    • buzzer
    • child_lock
    • natural_level
    • oscillate
    • delay_off_countdown
    • speed
    • direct_speed
    • natural_speed
    • angle
    • use_time
    • ac_power
    • battery (zhimi.fan.v2 and v3 only)
    • battery_charge (zhimi.fan.v2 & v3 only)
    • button_pressed (zhimi.fan.v2 & v3 only)
    • led (zhimi.fan.v2 only)
    • battery_state (zhimi.fan.v2 only)

Rosou SS4 Ventilator (leshow.fan.ss4)

  • Power (on, off)

  • Operation modes (manual, sleep, strong, natural)

  • Preset modes (Level 1, Level 2, Level 3, Level 4)

  • Speed percentage (0...100)

  • Oscillate (on, off)

  • Buzzer (on, off)

  • Delayed turn off (minutes)

  • Attributes

    • model
    • mode
    • speed
    • buzzer
    • oscillate
    • delay_off_countdown
    • error_detected

Install

You can install this custom component via HACS. Search for for 'Xiaomi Mi Air Purifier and Xiaomi Mi Air Humidifier Integration' at the integration page of HACS. Alternatively, you can install it manually by copying the custom_compon ent folder to your Home Assistant configuration folder.

As next step you have to setup the custom component at your configuration.yaml. This custom component doesn't provide a config-flow right now. A restart of Home Assistant is required afterwards.

Setup

# configuration.yaml

fan:
  - platform: xiaomi_miio_airpurifier
    name: Xiaomi Air Purifier 2
    host: 192.168.130.71
    token: b7c4a758c251955d2c24b1d9e41ce47d
    model: zhimi.airpurifier.m1

  - platform: xiaomi_miio_airpurifier
    name: Xiaomi Air Purifier Pro
    host: 192.168.130.73
    token: 70924d6fa4b2d745185fa4660703a5c0
    model: zhimi.airpurifier.v6

  - platform: xiaomi_miio_airpurifier
    name: Xiaomi Air Humidifier
    host: 192.168.130.72
    token: 2b00042f7481c7b056c4b410d28f33cf
    model: zhimi.humidifier.v1

  - platform: xiaomi_miio_airpurifier
    name: Xiaomi Air Fresh
    host: 192.168.130.74
    token: 91d89cf53c4090f4c653174f6737102f
    model: zhimi.airfresh.va2

  - platform: xiaomi_miio_airpurifier
    name: Xiaomi Smart Fan
    host: 192.168.130.75
    token: b7c4a758c251955d2c24b1d9e41ce4ff

climate:
  - platform: xiaomi_miio_airpurifier
    name: Xiaomi Air Dehumidifier
    host: 192.168.130.76
    token: 86c4c41dc7af0e0520e170c8a1f92f62

Configuration variables:

  • host (Required): The IP of your light.
  • token (Required): The API token of your light.
  • name (Optional): The name of your light.
  • model (Optional): The model of your device. This setting can be used to bypass the device model detection and is recommended if your device isn't always available.

Fan device

Template sensor example

If your entity has another name the value xiaomi_air_purifier and xiaomi_air_humidifier must be updated.

# configuration.yaml

sensor:
  - platform: template
    sensors:
      airpurifier_aqi:
        friendly_name: Air Purifier Air Quality Index
        value_template: '{{ states.fan.xiaomi_air_purifier.attributes.aqi }}'
        icon_template: mdi:weather-windy
      airpurifier_temperature:
        friendly_name: Air Purifier Temperature
        value_template: '{{ states.fan.xiaomi_air_purifier.attributes.temperature }}'
        unit_of_measurement: '°C'
      airpurifier_humidity:
        friendly_name: Air Purifier Humidity
        value_template: '{{ states.fan.xiaomi_air_purifier.attributes.humidity }}'
        unit_of_measurement: '%'
        icon_template: mdi:water-percent

      airhumidifier_temperature:
        friendly_name: Air Humidifier Temperature
        value_template: '{{ states.fan.xiaomi_air_humidifier.attributes.temperature }}'
        unit_of_measurement: '°C'
      airhumidifier_humidity:
        friendly_name: Air Humidifier Humidity
        value_template: '{{ states.fan.xiaomi_air_humidifier.attributes.humidity }}'
        unit_of_measurement: '%'
        icon_template: mdi:water-percent

Template switch example

switch:
  - platform: template
    switches:
      xiaomi_airpurifier_child_lock:
        friendly_name: "Child lock"
        value_template: "{{ is_state_attr('fan.xiaomi_air_purifier', 'child_lock', True) }}"
        turn_on:
          service: xiaomi_miio_airpurifier.fan_set_child_lock_on
          data:
            entity_id: fan.xiaomi_air_purifier
        turn_off:
          service: xiaomi_miio_airpurifier.fan_set_child_lock_off
          data:
            entity_id: fan.xiaomi_air_purifier
        icon_template: "mdi:lock-outline"

      xiaomi_airpurifier_buzzer:
        friendly_name: "Buzzer"
        value_template: "{{ is_state_attr('fan.xiaomi_air_purifier', 'buzzer', True) }}"
        turn_on:
          service: xiaomi_miio_airpurifier.fan_set_buzzer_on
          data:
            entity_id: fan.xiaomi_air_purifier
        turn_off:
          service: xiaomi_miio_airpurifier.fan_set_buzzer_off
          data:
            entity_id: fan.xiaomi_air_purifier
        icon_template: "mdi:volume-off"

      xiaomi_airpurifier_led:
        friendly_name: "LED"
        value_template: "{{ is_state_attr('fan.xiaomi_air_purifier', 'led', True) }}"
        turn_on:
          service: xiaomi_miio_airpurifier.fan_set_led_on
          data:
            entity_id: fan.xiaomi_air_purifier
        turn_off:
          service: xiaomi_miio_airpurifier.fan_set_led_off
          data:
            entity_id: fan.xiaomi_air_purifier
        icon_template: "mdi:lightbulb-outline"

Lovelace entities card

Input select example

input_select:
  airpurifier_mode:
    name: Operation mode
    options:
     - Low
     - Medium
     - High
     - Humidity

automation:
  - alias: Select operation mode by input select
    trigger:
      entity_id: input_select.airpurifier_mode
      platform: state
    action:
      service: fan.set_speed
      data_template:
        entity_id: fan.xiaomi_air_purifier
        speed: '{{ states.input_select.airpurifier_mode.state }}'

  - alias: Monitor operation mode and update input select
    trigger:
      platform: state
      entity_id: fan.xiaomi_air_purifier
    action:
      service: input_select.select_option
      entity_id: input_select.airpurifier_mode
      data_template:
        option: '{{ states.fan.xiaomi_air_purifier.attributes.speed }}'

Input number example

sensor:
  - platform: template
    sensors:
      airpurifier_favorite_level:
        friendly_name: Favorite level
        value_template: '{{ states.fan.xiaomi_air_purifier.attributes.favorite_level }}'

input_number:
  airpurifier_favorite_level:
    name: Favorite Level
    initial: 1
    min: 0
    max: 16
    step: 1

automation:
  - alias: Select favorite level by slider
    trigger:
      platform: state
      entity_id: input_number.airpurifier_favorite_level
    action:
      - service: xiaomi_miio_airpurifier.fan_set_favorite_level
        data_template:
          entity_id: fan.xiaomi_air_purifier
          level: '{{ states.input_number.airpurifier_favorite_level.state|int }}'

  - alias: Monitor favorite level and update slider
    trigger:
      platform: state
      entity_id: sensor.airpurifier_favorite_level
    action:
      service: input_number.set_value
      entity_id: input_number.airpurifier_favorite_level
      data_template:
        value: '{{ states.fan.xiaomi_air_purifier.attributes.favorite_level }}'

Input number example

The following example can be used to setup a input_numer entity to control the target humidity of an Air Humidifier. Make sure to replace all occurrences of fan.xiaomi_air_humidifier with the entity_id of your device.

sensor:
  - platform: template
    sensors:
      airhumidifier_target_humidity:
        friendly_name: Target humidity
        value_template: '{{ states.fan.xiaomi_air_humidifier.attributes.target_humidity }}'
        unit_of_measurement: '%'
        icon_template: mdi:water-percent

input_number:
  airhumidifier_target_humidity:
    name: Target humidity
    min: 1
    max: 99
    step: 1

automation:
  - alias: Select target humidity by slider
    trigger:
      platform: state
      entity_id: input_number.airhumidifier_target_humidity
    action:
      - service: xiaomi_miio_airpurifier.fan_set_target_humidity
        data_template:
          entity_id: fan.xiaomi_air_humidifier
          humidity: '{{ states.input_number.airhumidifier_target_humidity.state|int }}'

  - alias: Monitor target humidity and update slider
    trigger:
      platform: state
      entity_id: sensor.airhumidifier_target_humidity
    action:
      service: input_number.set_value
      entity_id: input_number.airhumidifier_target_humidity
      data_template:
        value: '{{ states.fan.xiaomi_air_humidifier.attributes.target_humidity }}'

Debugging

If the custom component doesn't work out of the box for your device please update your configuration to increase the log level:

logger:
  default: warn
  logs:
    custom_components.xiaomi_miio_airpurifier: debug
    miio: debug

Platform services

Service fan.set_preset_mode

Set the fan operation/preset mode.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.
preset_mode no Preset mode. Valid values are Auto, Silent, Favorite and Idle. Valid values of the Pedestal Fan are Level 1, Level 2, Level 3 and Level 4.

Service fan.set_percentage (Pedestal Fan only)

Set the fan speed percentage.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.
percentage no Percentage speed setting. Valid values are between 0 and 100.

Service xiaomi_miio_airpurifier.fan_set_buzzer_on (Air Purifier Pro excluded)

Turn the buzzer on.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.

Service xiaomi_miio_airpurifier.fan_set_buzzer_off (Air Purifier Pro excluded)

Turn the buzzer off.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.

Service xiaomi_miio_airpurifier.fan_set_led_on (Air Purifier only)

Turn the led on.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.

Service xiaomi_miio_airpurifier.fan_set_led_off (Air Purifier only)

Turn the led off.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.

Service xiaomi_miio_airpurifier.fan_set_child_lock_on

Turn the child lock on.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.

Service xiaomi_miio_airpurifier.fan_set_child_lock_off

Turn the child lock off.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.

Service xiaomi_miio_airpurifier._fan_set_delay_off

Set the scheduled turn off time. Supported values are 0, 60, 120, 180, 240, 300, 360, 420, 480 minutes. When 0 is passed, delay_off is disabled.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.
delay_off_countdown no Time in minutes. Valid values are 0, 60, 120, 180, 240, 300, 240, 300, 360, 420, 480 minutes.

Service xiaomi_miio_airpurifier.fan_set_led_brightness (Air Purifier Pro excluded)

Set the led brightness. Supported values are 0 (Bright), 1 (Dim), 2 (Off).

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.
brightness no Brightness, between 0 and 2.

Service xiaomi_miio_airpurifier.fan_set_favorite_level (Air Purifier only)

Set the favorite level of the operation mode "favorite".

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.
level no Level, between 0 and 16.

Service xiaomi_miio_airpurifier.fan_set_auto_detect_on (Air Purifier Pro only)

Turn the auto detect on.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.

Service xiaomi_miio_airpurifier.fan_set_auto_detect_off (Air Purifier Pro only)

Turn the auto detect off.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.

Service xiaomi_miio_airpurifier.fan_set_learn_mode_on (Air Purifier 2 only)

Turn the learn mode on.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.

Service xiaomi_miio_airpurifier.fan_set_learn_mode_off (Air Purifier 2 only)

Turn the learn mode off.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.

Service xiaomi_miio_airpurifier.fan_set_volume (Air Purifier Pro only)

Set the sound volume.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.
volume no Volume, between 0 and 100.

Service xiaomi_miio_airpurifier.fan_reset_filter (Air Purifier 2 and Air Fresh only)

Reset the filter lifetime and usage.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.

Service xiaomi_miio_airpurifier.fan_set_extra_features (Air Purifier and Air Fresh only)

Set the extra features.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.
features no Integer, known values are 0 and 1.

Service xiaomi_miio_airpurifier.fan_set_target_humidity (Air Humidifier only)

Set the target humidity.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.
humidity no Target humidity. The allowed values varies by model.

Service xiaomi_miio_airpurifier.fan_set_dry_on (Air Humidifier CA only)

Turn the dry mode on.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.

Service xiaomi_miio_airpurifier.fan_set_dry_off (Air Humidifier CA only)

Turn the dry mode off.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.

Service fan.oscillate (Pedestal Fan only)

Oscillates the fan.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.
oscillating no Flag to turn on/off oscillation. Valid values are True and False.

Service fan.set_direction (Pedestal Fan only)

Rotates the fan 5 degrees to the left/right.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.
direction no Rotate the fan 5 degrees. Valid values are left and right.

Service xiaomi_miio_airpurifier.fan_set_oscillation_angle (Pedestal Fan only)

Set the oscillation angle. Supported values are 30, 60, 90 and 120 degrees.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.
angle no Angle in degrees. Valid values are 30, 60, 90 and 120.

Service xiaomi_miio_airpurifier.fan_set_natural_mode_on (Pedestal Fan only)

Turn the natural mode on.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.

Service xiaomi_miio_airpurifier.fan_set_natural_mode_off (Pedestal Fan only)

Turn the natural mode off.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.

Service xiaomi_miio_airpurifier.fan_set_motor_speed (Air Humidifier CA4)

Set motor speed RPM.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.
motor_speed no Motor speed RPM. Allowed values are between 200 and 2000

Service xiaomi_miio_airpurifier.fan_set_clean_mode_on (Air Humidifier CA4)

Turn the clean mode on.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.

Service xiaomi_miio_airpurifier.fan_set_clean_mode_off (Air Humidifier CA4)

Turn the clean mode off.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.

Service xiaomi_miio_airpurifier.fan_set_fan_level (Air Purifier 3H only)

Set the level when on fan mode.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.
level no Valid values are 1, 2 and 3.

Service xiaomi_miio_airpurifier.fan_set_ptc_on (Air Fresh VA4 and T2017 only)

Turn the ptc on.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.

Service xiaomi_miio_airpurifier.fan_set_ptc_off (Air Fresh VA4 and T2017 only)

Turn the ptc off.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.

Service xiaomi_miio_airpurifier.fan_set_favorite_speed (Air Fresh T2017 only)

Set the favorite speed.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.
speed no Volume, between 60 and 300.

Service xiaomi_miio_airpurifier.fan_set_ptc_level (Air Fresh T2017 only)

Set the ptc level.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.
level no PTC level. Valid values are Low, Medium, High.

Service xiaomi_miio_airpurifier.fan_set_display_orientation (Air Fresh T2017 only)

Set the display orientation.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.
display_orientation no Display orientation. Valid values are Portrait, LandscapeLeft and LandscapeRight.

Service xiaomi_miio_airpurifier.fan_set_display_on (Air Fresh T2017 only)

Turn the display on.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.

Service xiaomi_miio_airpurifier.fan_set_display_off (Air Fresh T2017 only)

Turn the display off.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.

Service xiaomi_miio_airpurifier.fan_set_wet_protection_on (deerma.humidifier.jsq1 only)

Turn the wet protection on.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.

Service xiaomi_miio_airpurifier.fan_set_wet_protection_on (deerma.humidifier.jsq1 only)

Turn the wet protection off.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.

xiaomi_airpurifier's People

Contributors

1337hium avatar alexeypetrenko avatar anhnvme avatar anonym-tsk avatar baizulin avatar bieniu avatar deese avatar dpozimski avatar ehn avatar g1k avatar harrisony avatar iromeo avatar istitch07 avatar kristofgyuracz avatar ktibow avatar skvalex avatar sneakythr0ws avatar syssi avatar toxblh avatar tranzior avatar vartom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xiaomi_airpurifier's Issues

Add zhimi.aircondition.ma3 support

Could you add support the device zhimi.aircondition.ma3, please.
I can provide any necessary information and help with testing/debugging.

Add support of zhimi.humidifier.cb1

Hello!
Can you add support of zhimi.humidifier.cb1 - it is Smartmi Evaporative Humidifier:

akoznov@netbox:~/php-miio$ php miio-cli.php --ip 10.255.254.58 --token XXXXXXXXXX --info

Используем авто-формирование уникальных ID для команд из файла id.json
Информация об устройстве:
{"result":{"life":138354,"token":"061a870d52830625aaeea7aeb13a25ec","mac":"04:CF:8C:AA:DC:2B","fw_ver":"1.6.3","hw_ver":"MTK7697","uid":"155047449","model":"zhimi.humidifier.cb1","mcu_fw_ver":"1005","wifi_fw_ver":"20180702211408","config_type":"app","ap":{"rssi":-61,"ssid":"XXXXXXX","bssid":"XXXXXXXXXXX"},"netif":{"localIp":"10.255.254.58","mask":"255.255.255.0","gw":"10.255.254.1","gw_mac":"XXXXXX"},"mmfree":63968},"id":3}

Can i add some more data about it? If yes - what do you need in addition?
Thanks!

Device nwt.derh.wdh318efw1

Hello @syssi

Can you write a custom component for nwt.derh.wdh318efw1 device for Home Assisstant ?
I see you commit something like nwt.derh.wdh318efw1 to miio.
I think you can do it

Thanks you

Filter statuses

Hi,

The "filter_hours_used" and "filter_life_remaining" seems to be mixed.

Home Assistant
0.54
Hassio 1.0

Add support for deerma.humidifier.mjjsq

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.

Compile error

2018-01-29 10:33:31 ERROR (MainThread) [homeassistant.components.fan] Error while setting up platform xiaomi_miio File "/config/custom_components/fan/xiaomi_miio.py", line 97, in async_setup_platform

Release: 0.4.0

Problem with homekit

Hello.
I added zhimi.humidifier.ca1, all works great, but i have strange errors in my log.
2019-03-04 21:38:52 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved Traceback (most recent call last): File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run result = self.fn(*self.args, **self.kwargs) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/homekit/type_fans.py", line 132, in update_state hk_speed_value = self.speed_mapping.speed_to_homekit(speed) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/homekit/util.py", line 150, in speed_to_homekit speed_range = self.speed_ranges[speed] KeyError: 864

Stats frequency pulls.

Home Assistant
0.54.0
Hassio 1.1

Built using Python 3

Not a bug but suggestion. The stats of the purifier are pulled way too frequently (by my estimation once 1 minute, but might be wrong since chart is too "fuzzy") which creates rather large overhead on history of HA and makes chart reading rather hard.

  • Is it possible define median like algorithm which will average the value for defined number of pulls.
  • Or at least not put any value in to history if the value didn't change comparing with previous one

Retrieving Temperature and Humidity

Hello,

First of all thank you for this component!
I would like to ask you if there is any way to retrieve the temperature as well the humidity from Xiomi AirPurifier?
Regards

Xiaomi Mijia Smart Sterilization Humidifier (SCK0A45) error - Platform xiaomi_miio_airpurifier not ready yet. Retrying in 180 seconds.

I'm trying to connect with Xiaomi Mijia Smart Sterilization Humidifier (SCK0A45) Platform and get the error in logs:
xiaomi_miio_airpurifier not ready yet. Retrying in 180 seconds.

My configuration looks like this:

fan:
  - platform: xiaomi_miio_airpurifier
    name: Nawilzacz
    host: 10.0.0.74
    token: 022938e31562f9036688c0f0e80de7b2

If I include model: deerma.humidifier.mjjsq I get other error:

Got exception while fetching the state: No response from the device
10:16:36 – custom_components/xiaomi_miio_airpurifier/fan.py (ERROR) - wiadomość pojawiła się po raz pierwszy o godzinie 10:15:14 i powtarzała się 3 razy
Got error when receiving: timed out

10:16:36 – /usr/local/lib/python3.7/site-packages/miio/device.py (ERROR) - wiadomość pojawiła się po raz pierwszy o godzinie 10:15:14 i powtarzała się 3 razy
Update of fan.nawilzacz is taking over 10 seconds

10:16:26 – __main__.py (WARNING) - wiadomość pojawiła się po raz pierwszy o godzinie 10:15:55 i powtarzała się 2 razy
Header missing

10:16:12 – components/stream/worker.py (ERROR)
['Low', 'Medium', 'High', 'Humidity'] does not contain the speed setting off as its first element. Assuming that Low is equivalent to 'off'.

10:15:20 – homekit (WARNING)
Setup of fan platform xiaomi_miio_airpurifier is taking over 10 seconds.
10:15:02 – Wentylator (WARNING)

Manual mirobo command run in debug mode reports:

.env/bin/mirobo -d status
INFO:miio.vacuum_cli:Debug mode active
DEBUG:miio.vacuum_cli:Connecting to 10.0.0.74 with token cd2be39bd7274dfd36d7051cba9a5650
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\x10\\/^\x00\x00\x02\x07' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = unhexlify('105c2f5e')
            ts = 1970-01-01 00:08:39
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
DEBUG:miio.device:Discovered 105c2f5e with ts: 1970-01-01 00:08:39, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.device:10.0.0.74:54321 >>: {'id': 1, 'method': 'get_status', 'params': []}
DEBUG:miio.device:Retrying with incremented id, retries left: 3
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\x10\\/^\x00\x00\x02\x0c' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = unhexlify('105c2f5e')
            ts = 1970-01-01 00:08:44
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
DEBUG:miio.device:Discovered 105c2f5e with ts: 1970-01-01 00:08:44, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.device:10.0.0.74:54321 >>: {'id': 102, 'method': 'get_status', 'params': []}
DEBUG:miio.device:Retrying with incremented id, retries left: 2
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\x10\\/^\x00\x00\x02\x11' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = unhexlify('105c2f5e')
            ts = 1970-01-01 00:08:49
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
DEBUG:miio.device:Discovered 105c2f5e with ts: 1970-01-01 00:08:49, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.device:10.0.0.74:54321 >>: {'id': 203, 'method': 'get_status', 'params': []}
DEBUG:miio.device:Retrying with incremented id, retries left: 1
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\x10\\/^\x00\x00\x02\x16' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = unhexlify('105c2f5e')
            ts = 1970-01-01 00:08:54
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
DEBUG:miio.device:Discovered 105c2f5e with ts: 1970-01-01 00:08:54, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.device:10.0.0.74:54321 >>: {'id': 304, 'method': 'get_status', 'params': []}
ERROR:miio.device:Got error when receiving: timed out
DEBUG:miio.click_common:Exception: No response from the device
Traceback (most recent call last):
  File "/Users/krzysztofkajkowski/miio/.env/lib/python3.7/site-packages/miio/device.py", line 272, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/krzysztofkajkowski/miio/.env/lib/python3.7/site-packages/miio/device.py", line 272, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/krzysztofkajkowski/miio/.env/lib/python3.7/site-packages/miio/device.py", line 272, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/krzysztofkajkowski/miio/.env/lib/python3.7/site-packages/miio/device.py", line 272, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/krzysztofkajkowski/miio/.env/lib/python3.7/site-packages/miio/click_common.py", line 59, in __call__
    return self.main(*args, **kwargs)
  File "/Users/krzysztofkajkowski/miio/.env/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/Users/krzysztofkajkowski/miio/.env/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/krzysztofkajkowski/miio/.env/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/krzysztofkajkowski/miio/.env/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/Users/krzysztofkajkowski/miio/.env/lib/python3.7/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/Users/krzysztofkajkowski/miio/.env/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/Users/krzysztofkajkowski/miio/.env/lib/python3.7/site-packages/miio/vacuum_cli.py", line 112, in status
    res = vac.status()
  File "/Users/krzysztofkajkowski/miio/.env/lib/python3.7/site-packages/miio/vacuum.py", line 176, in status
    return VacuumStatus(self.send("get_status")[0])
  File "/Users/krzysztofkajkowski/miio/.env/lib/python3.7/site-packages/miio/device.py", line 310, in send
    return self.send(command, parameters, retry_count - 1)
  File "/Users/krzysztofkajkowski/miio/.env/lib/python3.7/site-packages/miio/device.py", line 310, in send
    return self.send(command, parameters, retry_count - 1)
  File "/Users/krzysztofkajkowski/miio/.env/lib/python3.7/site-packages/miio/device.py", line 310, in send
    return self.send(command, parameters, retry_count - 1)
  File "/Users/krzysztofkajkowski/miio/.env/lib/python3.7/site-packages/miio/device.py", line 313, in send
    raise DeviceException("No response from the device") from ex
miio.exceptions.DeviceException: No response from the device
Error: No response from the device

In order to remedy the problem, I reset Mi Hub, which re-generated toke, reset humidifier (both button for 5s) and reconnected to Mi Home app (iOS 4.26.1). I can read token in Android Mi Home app 5.4.49 but for some reason, I cannot connect to the humidifier from there (I get extension cannot be initialized error). Everything works from iOS though.

Support for device zhimi.airpurifier.v7

Hi Everyone,

At the beginning I would like to thank you for great work. I finally got the toke, what was really hard, and I found new problem: "Unsupported device found". Is it possible to add support for Xiaomi Air Purifier Pro 2018 (model: zhimi.airpurifier.v7)?

Bellow you can find log from info method:
{'result': {'life': 1761, 'cfg_time': 0, 'token': 'HIDEN', 'mac': HIDEN, 'fw_ver': '1.4.3_19105', 'hw_ver': 'MW300', 'uid': 1900358663, 'model': 'zhimi.airpurifier.v7', 'wifi_fw_ver': 'SD878x-14.76.36.p84-702.1.0-WM', 'ap': {'rssi': -51, 'ssid': 'HIDEN', 'bssid': 'HIDEN'}, 'netif': {'localIp': 'HIDEN', 'mask': '255.255.255.0', 'gw': 'HIDEN', 'gw_mac': 'HIDEN'}, 'mmfree': 134204, 'ot': 'ott', 'otu_stat': [0, 0, 0, 0, 0, 27], 'ott_stat': [1, 0, 14, 201]}, 'id': 1}

Thanks in advance :)

Unsupported device found: zhimi.airfresh.va2 (智米新风)

Please help support the SmartMi Air Fresh System. The device model ID is zhimi.airfresh.va2

With the following configuration, it can almost work well (Turn On/Off, aqi, humidity, etc.) :

  - platform: xiaomi_miio
    name: Fresher
    host: 192.168.1.x
    model: zhimi.airpurifier.m1
    token: ****************

BTW, Could you please tell me how to sniffer/analyze miio traffic payload with the new device? I found https://github.com/OpenMiHome/mihome-binary-protocol, but it can't analysis the traffic between MiHome app and Xiaomi Cloud, and I couldn't find how to enforce/repeat the device and MiHome app to communication via local protocol. Your help will be highly appreciated:)

How Can I add Button to Add control/Switch Operation modes (auto, silent, favorite, idle)

Hi,
I am new to Home assistant
I managed to add Xiaomi Air purifier 2 to HA & successfully!!
I am able to ON & OFF the device using Home Assitant UI

I want to add a button(s) to change the Operation Mode of the Xiaomi Air purifier 2 in Home assitant
Also, want to Display the following data in my Home assistant front page

  1. temperature
  2. humidity
  3. aqi
  4. mode
  5. filter_hours_used
  6. filter_life_remaining

Please help me with an example so that I can get the same

Thanks in advance.

home assistant 0.60 not compatible

This module stopped working.

`
2017-12-18 14:53:38 ERROR (Thread-9) [miio.device] Got error when receiving: timed out
2017-12-18 14:53:38 ERROR (MainThread) [homeassistant.components.fan.xiaomi_miio] Got exception while fetching the state:
2017-12-18 14:53:38 ERROR (Thread-13) [miio.device] Got error when receiving: timed out
2017-12-18 14:53:38 ERROR (MainThread) [homeassistant.components.fan.xiaomi_miio] Got exception while fetching the state:

`

Debug
2017-12-18 14:55:21 DEBUG (Thread-11) [miio.device] 192.168.x.x:54321 >>: {'id': 3649, 'params': ['power', 'aqi', 'humidity', 'temp_dec', 'mode', 'led', 'led_b', 'buzzer', 'child_lock', 'bright', 'favorite_level', 'filter1_life', 'f1_hour_used', 'use_time', 'motor1_speed'], 'method': 'get_prop'} 2017-12-18 14:55:27 DEBUG (Thread-11) [miio.device] 192.168.x.x:54321 >>: {'id': 3750, 'params': ['power', 'aqi', 'humidity', 'temp_dec', 'mode', 'led', 'led_b', 'buzzer', 'child_lock', 'bright', 'favorite_level', 'filter1_life', 'f1_hour_used', 'use_time', 'motor1_speed'], 'method': 'get_prop'} 2017-12-18 14:55:32 DEBUG (Thread-11) [miio.device] 192.168.x.x:54321 >>: {'id': 3851, 'params': ['power', 'aqi', 'humidity', 'temp_dec', 'mode', 'led', 'led_b', 'buzzer', 'child_lock', 'bright', 'favorite_level', 'filter1_life', 'f1_hour_used', 'use_time', 'motor1_speed'], 'method': 'get_prop'}

Error while setting up platform xiaomi_miio_airpurifier

Hello,

yesterday after install, it's working, but today, i need update other device and tried restart home asssistant, i got this error
i'm already tried remove folder and recreate folder xiaomi_miio_airpurifier

2019-12-14 11:30:21 ERROR (MainThread) [homeassistant.components.fan] Error while setting up platform xiaomi_miio_airpurifier
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_airpurifier/fan.py", line 609, in async_setup_platform
    from miio import AirHumidifierMjjsq
ImportError: cannot import name 'AirHumidifierMjjsq' from 'miio' (/usr/local/lib/python3.7/site-packages/miio/__init__.py)

Extend some air purifiers by light sensor readings

you can add for following models:

zhimi.airpurifier.ma2
zhimi.airpurifier.mb1
zhimi.airpurifier.mc1
zhimi.airpurifier.v6
zhimi.airpurifier.v7

{"method":"get_prop","params":["bright","light"],"id":1}
{"result":[93,9484],"id":1}

flashlight

{"method":"get_prop","params":["bright","light"],"id":1}
{"result":[200,29512],"id":1}

covered

{"method":"get_prop","params":["bright","light"],"id":1}
{"result":[0,51],"id":1}

light is raw sensor data, bright is more or less light/100, but capped to 200.

average_aqi detail ?

Hi,

Not really issue but information

Would you mind share how to does the average_aqi calculated ?

Thanks you in advance for the great work

Receive error when setting favorite_level

There was no response when I set favorite_level under Favorite Mode.
Service call data :
{ "entity_id": "fan.xiaomi_air_purifier_2",
"level": 5}
Logs:
2017-10-30 17:43:24 DEBUG (MainThread) [homeassistant.components.fan.xiaomi_miio] Response received from air purifier: {'id': 3, 'error': {'code': -32601, 'message': 'Method not found.'}}
2017-10-30 17:43:24 DEBUG (MainThread) [homeassistant.components.fan.xiaomi_miio] Got new state:

Add support for zhimi.airpurifier.ma4

Hi
I bought recently the newest air purifier Xiaomi Air Purifier 3 and it is recognized as model zhimi.airpurifier.ma4, HA i received error {'code': -5001, 'message': 'command error'}
Unfortunately i do not know how to add some more information.

Expose some settings via service calls

There are some features which aren't accessible at the moment which should be exposed via service calls.

    def set_favorite_level(self, level: int):
        """Set favorite level."""

    def set_led_brightness(self, brightness: LedBrightness):
        """Set led brightness."""

    def set_led(self, led: bool):
        """Turn led on/off."""

    def set_buzzer(self, buzzer: bool):
        """Set buzzer on/off."""

Unable to discover the device

A couple of versions back my Air Purifier 2 stopped appearing in HASS and I just got these errors:

2018-03-06 18:14:06 ERROR (Thread-12) [miio.device] Unable to discover a device at address 10.0.2.26
2018-03-06 18:14:06 ERROR (MainThread) [homeassistant.components.fan.xiaomi_miio] Got exception while fetching the state: Unable to discover the device 10.0.2.26

I've done a factory reset of the purifier and retrieved the token more then once from my iPhone so it should be correct. I've also got a Mi Vacuum and it works without problems.

Right now I'm on version 0.65.5 and this is my configuration.yaml:

logger:
  default: warn
  logs:
    miio: debug
    homeassistant.components.fan.xiaomi_miio: debug

fan:
  - platform: xiaomi_miio
    name: Mi Purifier
    host: 10.0.2.26
    token: *token*

This is the log when starting HASS with debug enabled (and disabling the vacuum):

2018-03-29 01:05:47 INFO (MainThread) [homeassistant.components.fan.xiaomi_miio] Initializing with host 10.0.2.26 (token c53b5...)
2018-03-29 01:05:52 ERROR (Thread-10) [miio.device] Unable to discover a device at address 10.0.2.26
2018-03-29 01:05:52 ERROR (MainThread) [homeassistant.components.fan.xiaomi_miio] Got exception while fetching the state: Unable to discover the device 10.0.2.26

I've tried looking around but can't seem to figure out what it's not working.

Error while setting up platform xiaomi_miio_airpurifier

I have this error:

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_airpurifier/fan.py", line 605, in async_setup_platform
from miio import AirHumidifierMjjsq
ImportError: cannot import name 'AirHumidifierMjjsq' from 'miio' (/usr/local/lib/python3.7/site-packages/miio/init.py)

My config:

fan:

  • platform: xiaomi_miio_airpurifier
    name: Humidificador_habitacion
    model: deerma.humidifier.mjjsq
    host: !secret humidifier_hostname
    token: !secret humidifier_token

Only ocurrs when there are sensors declared like this:

  • platform: template
    sensors:
    alerta_deposito_humidificador:
    friendly_name: Air Humidifier alerta deposito
    value_template: '{{ states.fan.humidificador_habitacion.attributes.water_tank_detached }}'

Is it possible to add more time to import miio?

xiaomi_miio_airpurifier: Error on device update! xiaomi humidifier 2

I have an error
xiaomi_miio_airpurifier: 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_airpurifier/fan.py", line 1068, in async_update
for key, value in self._available_attributes.items()
File "/config/custom_components/xiaomi_miio_airpurifier/fan.py", line 1068, in
for key, value in self._available_attributes.items()
File "/config/custom_components/xiaomi_miio_airpurifier/fan.py", line 727, in _extract_value_from_attribute
value = getattr(state, attribute)
AttributeError: 'AirHumidifierStatus' object has no attribute 'speed'

in configuration.yaml
fan:

  • platform: xiaomi_miio_airpurifier
    name: Xiaomi Air Humidifier
    host: 192.168.1.215
    token: 982de7b70xxxxxxxx7485765fab062
    model: zhimi.humidifier.ca1

Xiaomi Zero Fog Humidifier (shuii.humidifier.jsq001) support is missing

The Xiaomi Zero Fog Humidifier (or "The fog free of humidifier" in MiHome app) has model ID shuii.humidifier.jsq001. I managed to get it's token and finally get an error Unsupported device found! Please create an issue at https://github.com/syssi/xiaomi_airpurifier/issues and provide the following data: shuii.humidifier.jsq001

Could you please add support for it.

Initialization error.

Hi,

Have an error during setup of the custom component:

Home Assistant
0.52.1
Hassio 1.0

Built using Python 3

ERROR (MainThread) [homeassistant.components.fan] Error while setting up platform xiaomi_airpurifier
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 164, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
File "/usr/lib/python3.6/asyncio/tasks.py", line 352, in wait_for
return fut.result()
File "/usr/lib/python3.6/asyncio/futures.py", line 244, in result
raise self._exception
File "/usr/lib/python3.6/asyncio/tasks.py", line 179, in _step
result = coro.send(None)
File "/usr/lib/python3.6/asyncio/coroutines.py", line 210, in coro
res = func(*args, **kw)
File "/config/custom_components/fan/xiaomi_airpurifier.py", line 55, in async_setup_platform
from mirobo import AirPurifier, DeviceException
ImportError: cannot import name 'AirPurifier'

Let me know if you need any additional info.

KeyError: 'motor1_speed' error

Everything was fine if i comment out the line 191.

home-assistant = 0.52.1 (on rpi3)
mirobo = 0.1.4

2017-09-03 08:34:38 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 235, in _step
    result = coro.send(value)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 381, in async_process_entity
    new_entity, self, update_before_add=update_before_add
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 210, in async_add_entity
    yield from entity.async_update()
  File "/home/homeassistant/.homeassistant/custom_components/fan/xiaomi_airpurifier.py", line 191, in async_update
    ATTR_MOTOR_SPEED: state.motor_speed
  File "/srv/homeassistant/lib/python3.4/site-packages/mirobo/airpurifier.py", line 166, in motor_speed
    return self.data["motor1_speed"]
KeyError: 'motor1_speed'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.