Custom purifier-card for Home Assistant

I build my own card for an air purifier. It allows to control it, check current AQI, and display additional statistics about the purifier.

Check this out here: purifier-card

And here is how it looks:

Similar to denysdovhan/vacuum-card .

Looking for feedback!

3 Likes

Looks great!

I guess adding a link to your repo won’t hurt?
I’ll try using this with my Venta LW74 later :slightly_smiling_face:

Oh, sorry, I’ve thought I included it. Sorry fo my forgetfulness :pray:

1 Like

Is my browser broken or are you trolling me with the new link now also pointing to the vacuum card :laughing:
Don’t think this will fit my device since it’s functionally more of a humidifier, still good stuff!

Do you know how to integrate Venta LW74 to Home Assistant?

You need to buy their overpriced WiFi-module, use the old app to integrate it into your network.
It doesn’t require an internet connection.
To get the data, send an empty POST request to http://IP/datastructure, it’ll return the data you see on the webserver in JSON, here’s an example for the sensor data:

sensor:
- platform: rest
  name: Venta LW74 Action
  resource: http://192.168.xxx.xxx/datastructure
  method: POST
  payload: ""
  value_template: "{{ value_json.Action.Power }}"
  json_attributes_path: "$.Action"
  json_attributes:
    - Power
    - FanSpeed
    - SleepMode
    - Automatic
    - TargetHum
    - LEDStripActive
    - LEDStripMode
    - LEDStrip
- platform: rest
  name: Venta LW74 Info
  resource: http://192.168.xxx.xxx/datastructure
  method: POST
  payload: ""
  value_template: "{{ value_json.Info.Warnings }}"
  json_attributes_path: "$.Measure"
  json_attributes:
    - Temperature
    - Humidity
    - WaterLevel
    - FanRpm
    - FanRpm2

I haven’t integrated it as a Humidifier since there’s no native integration for generic or REST humidifiers, so I’ve set it up as a fan:

- platform: template
  fans:
    lw74:
      friendly_name: "Venta LW74 LuftwÀscher"
      value_template: "{% if is_state('sensor.venta_lw74_action', 'True') %}on{% else %}off{% endif %}"
      percentage_template: "{{ state_attr('sensor.venta_lw74_action', 'FanSpeed') * 25 }}"
      preset_mode_template: "{% if is_state_attr('sensor.venta_lw74_action', 'Automatic', True) %}auto{% else %}None{% endif %}"
      availability_template: "{{ is_state('sensor.venta_lw74_action', 'True') or is_state('sensor.venta_lw74_action', 'False') }}"
      preset_modes:
        - 'auto'
      speed_count: 5
      turn_on:
        service: rest_command.venta
        data:
          power: 'on'
      turn_off:
        service: rest_command.venta
        data:
          power: 'off'
      set_percentage:
        service: rest_command.venta
        data:
          speed: "{% if percentage == 0 %}0{% elif percentage <= 25 %}1{% elif percentage <= 50 %}2{% elif percentage <= 75 %}3{% elif percentage <= 100%}4{% endif%}"
      set_preset_mode:
        service: rest_command.venta
        data:
          speed: auto

Here are the rest commands you’ll need:

  venta:
    url: http://192.168.6.42/datastructure
    method: POST
    headers:
      content-type: application/json
    payload: >-
      {% if power == 'on' %}
        {"Action":{"Power":true}}
      {% elif power == 'off' %}
        {"Action":{"Power":false}}
      {% elif speed == 'auto' %}
        {"Action":{"Power":true, "Automatic": true}}
      {% elif speed %}
        {"Action":{"Power":true, "FanSpeed": {{ speed }}}}
      {% elif target_hum %}
        {"Action":{"TargetHum": {{ target_hum }}}}
      {% endif %}

It doesn’t work perfectly, but I don’t really care right now since I leave it running in Auto mode anyway.
Create an automation as well so the state gets updated immediately after sending a command:

alias: Venta LW74 State Update
description: ''
trigger:
  - platform: event
    event_type: call_service
    event_data:
      domain: rest_command
      service: venta
condition: []
action:
  - service: homeassistant.update_entity
    data: {}
    entity_id: sensor.venta_lw74_action, sensor.venta_lw74_info
mode: single

You can now create automations based on the sensor data, have a look around.
I have mine trigger when sensor.venta_lw74_info changes to 1 or 17, with a condition of the WaterLevel being below 50000. If that’s the case it indicates low water, so you could throw a notification or whatever.

I’m really disappointed in the Venta Software, what you’ll realize looking at the Data is that the device knows very well when you’ve refilled the water tank, but it doesn’t auto-restart. To fix that:

alias: Venta LuftwÀscher Auto Restart
description: ''
trigger:
  - platform: state
    entity_id: sensor.venta_lw74_info
    from: '1'
    to: '0'
  - platform: state
    entity_id: sensor.venta_lw74_info
    from: '17'
    to: '16'
condition: []
action:
  - service: fan.turn_off
    data: {}
    entity_id: fan.lw74
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - service: fan.turn_on
    data: {}
    entity_id: fan.lw74
mode: single
3 Likes

Can you please help to check the UI’s problem in 2022.3.3

It’s always show the full list in the left corner.

1 Like

Nice looking card you have made, thanks for sharing!
Hopefully you will be able to have it working with 2022.3.3

I was wondering, would I be able to change the color theme? And if so
how?
So I can change the blue color in a different color instead?

Thanks!

I’m having some trouble getting this card to work with my Xiaomi Mi Air Purifier 3H. This is how I have configured my card:

type: custom:purifier-card
entity: fan.mi_air_purifier
stats:
  - entity_id: sensor.mi_air_purifier_filter_life_remaining
    unit: '%'
    subtitle: Filter Remaining
  - entity_id: sensor.mi_air_purifier_filter_use
    unit: h
    subtitle: Filter Use
  - entity_id: sensor.mi_air_purifier_motor_speed
    unit: rpm
    subtitle: Motor Speed
aqi:
  - entity_id: sensor.mi_air_purifier_pm2_5
    unit: ”g/m³
shortcuts:
  - name: Silent
    icon: mdi:weather-night
    preset_mode: Silent
  - name: 25%
    icon: mdi:circle-slice-2
    percentage: 25
  - name: 50%
    icon: mdi:circle-slice-4
    percentage: 50
  - name: 75%
    icon: mdi:circle-slice-6
    percentage: 75
  - name: 100%
    icon: mdi:circle-slice-8
    percentage: 100
  - name: Auto
    icon: mdi:brightness-auto
    preset_mode: Auto
show_name: true
show_state: true
show_toolbar: true
compact_view: false

I cannot figure out how to get the AQI to display, nor how to fix the control for the speed. This is what the card looks like right now:

What am I doing wrong?

type: custom:purifier-card
entity: fan.mi_air_purifier
aqi:
  entity_id: sensor.mi_air_purifier_pm2_5
  unit: ”g/m³
stats:
1 Like

Thanks @trance77 . I was able to get things to work more to some extent. I was not able to get the slider to control the speed to work, so I ended up using compact mode. I was also not able to get the presets buttons to be grayed out when the preset is not active. This is the code that I have right now:

type: custom:purifier-card
entity: fan.mi_air_purifier
aqi:
  entity_id: sensor.mi_air_purifier_pm2_5
  unit: ”g/m³
stats:
  - entity_id: sensor.mi_air_purifier_motor_speed
    unit: RPM
    subtitle: Speed
  - entity_id: sensor.mi_air_purifier_filter_life_remaining
    subtitle: Filter
    unit: '%'
shortcuts:
  - name: Silent
    icon: mdi:weather-night
    preset_mode: Silent
  - name: 25%
    icon: mdi:circle-slice-2
    service: number.set_value
    service_data:
      value: '550'
      entity_id: number.mi_air_purifier_favorite_motor_speed
  - name: 50%
    icon: mdi:circle-slice-4
    service_data:
      value: '1100'
      entity_id: number.mi_air_purifier_favorite_motor_speed
  - name: 75%
    icon: mdi:circle-slice-6
    service_data:
      value: '1650'
      entity_id: number.mi_air_purifier_favorite_motor_speed
  - name: Auto
    icon: mdi:refresh-auto
    preset_mode: Auto
show_name: false
show_status: true
show_state: true
show_toolbar: true
compact_view: true

Any suggestions for how to fix the parts that are not working would be much appreciated.

Try this:
type: custom:purifier-card
entity: fan.mi_air_purifier
aqi:
  entity_id: sensor.mi_air_purifier_pm2_5
  unit: ”g/m³
stats:
  - entity_id: sensor.mi_air_purifier_motor_speed
    unit: RPM
    subtitle: Speed
  - entity_id: sensor.mi_air_purifier_filter_life_remaining
    subtitle: Filter
    unit: '%'
shortcuts:
  - name: Silent
    icon: mdi:weather-night
    preset_mode: Silent
  - name: 25%
    icon: mdi:circle-slice-2
    percentage: 25
  - name: 50%
    icon: mdi:circle-slice-4
    percentage: 50
  - name: 75%
    icon: mdi:circle-slice-6
    percentage: 75
  - name: 100%
    icon: mdi:circle-slice-8
    percentage: 100
  - name: Auto
    icon: mdi:brightness-auto
    preset_mode: Auto
show_name: true
show_state: true
show_toolbar: true
compact_view: false

Otherwise,I don't have any idea!

fan/set_fan_percentage is not supported by this device when i try to use the slider or any of the presets.

I have encountered a similar problem! When using the slider, an error appears: Failed to call service fan/set_percentage. сonnection lost
After investigating a bit, I found out that my Air Purifier 3C does not support this command and that the fan speed is changed using the command number.set_value.
@denysdovhan it would be cool to have some sort of choice regarding which service the slider should call (fan.set_percentage or number.set_value), or in general, for the whole card.

Any ideas how I could just have a small card with just one touch fan speed options? The slider is fine, but with a couple of air purifiers in the house, would be kinda cool to do a couple quick taps and have all the fans boost up to 100% for a few minutes versus using the sliders