denysdovhan/purifier-card

2021.9 broke the card ;-)

andriej opened this issue · 21 comments

Before submitting a bug

[X] I updated to the latest version available
[X] I cleared the cache of my browser

Describe the bug

In 2021.9 there are changes in purifier's native integration, that may break this card (attributes goes to sensors)

Steps to reproduce

  1. Go to '...'
  2. Click on '....'
  3. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.
For example, JavaScript errors are shown in the web inspector (if applicable).

Versions:

  • Release: [e.g. 0.2.0]
  • Browser: [e.g. chrome, safari]
  • HomeAssistant version: [e.g 0.109.4]

+1

+1

yep 2021.9 broke the card :-(
attrributes have been changed to sensors so card is not functioning

The card still works like a charm (see screenshot below).
You just need to modify your cards configuration to point to the new entities instead of the attributes like this

`
type: custom:purifier-card
entity: fan.luftreiniger
aqi:
entity_id: sensor.luftreiniger_pm2_5
stats:

  • entity_id: sensor.luftreiniger_filter_life_remaining
    unit: '%'
    subtitle: Filterzustand
  • entity_id: sensor.luftreiniger_humidity
    unit: '%'
    subtitle: Luftfeuchtigkeit
  • entity_id: sensor.luftreiniger_temperature
    unit: °C
    subtitle: Temperatur
    show_toolbar: true
    show_state: false
    `

The change is to use "entity_id" for stats and aqi section instead of "attribute"

image

and point to the correct entities (see developer tools)

How are you guys dealing with the fact that speed is now set via number.xxx_favorite_level in the card?

snp88 commented

I use different service
set fan percentage and for
low =33
mid =66
high =100

The card still works like a charm (see screenshot below).
You just need to modify your cards configuration to point to the new entities instead of the attributes like this

`
type: custom:purifier-card
entity: fan.luftreiniger
aqi:
entity_id: sensor.luftreiniger_pm2_5
[CUT]

The change is to use "entity_id" for stats and aqi section instead of "attribute"

[CUT]

and point to the correct entities (see developer tools)

Thank you for the nice trick.
I was able to configure the card to make it almost fully functional

However, in my case something is not working.

I cannot see the value of the pm 2.5 sensor but the word AQI appears in its place.

Also, I can't get the buttons of the various modes to work correctly but this problem is surely related to the automations of my package. I have to update them and I still don't understand how, because of the new sensors (they all work with the attributes of the previous "xiaomi platform")

Screeny Shot 8 Sep 2021 at 22 27 34

Edit:

I've solved my little AQI issue just taking a look at https://github.com/denysdovhan/purifier-card/issues/62
Now I have to understand how I should re-write my fan automations

image

Basically setting favourite level the way it's implemented in this card is no longer available.
Therefore custom actions no longer work.

I figured out workaround.
In order to change fav setting, we need to call two services, and since we can't do that for action, we create a script:

air_purifier_set_favorite_level:
  alias: "Air purifier favourite level"
  description: "Set favourite level for your purifier"
  fields:
    level:
      description: "Number from 0 to 17"
      example: "7"
  sequence:
    - service: fan.set_preset_mode
      data:
        entity_id: fan.zhimi_airpurifier_m1
        preset_mode: "Favorite"
    - service: number.set_value
      data:
        entity_id: number.zhimi_airpurifier_m1_favorite_level
        value: "{{ level }}"

Note:
You need to change entity_id for your use case but if you use default names chances are you have same ids.

Then we can use this script in service call of action.

Below you can see my updated yaml configuration of this card (includes fetched sensors from other entities):

type: custom:purifier-card
entity: fan.zhimi_airpurifier_m1
show_name: false
show_state: false
show_toolbar: true
show_preset_mode: true
aqi:
  entity_id: sensor.zhimi_airpurifier_m1_pm2_5
  attribute: aqi
  unit: µg/m³
  subtitle: AQI
stats:
  - entity_id: sensor.zhimi_airpurifier_m1_filter_life_remaining
    unit: '%'
    subtitle: Zużycie filtra
  - entity_id: sensor.zhimi_airpurifier_m1_temperature
    attribute: temperature
    unit: °C
    subtitle: Temperatura
  - entity_id: sensor.zhimi_airpurifier_m1_motor_speed
    attribute: motor_speed
    unit: RPS
    subtitle: Obroty
actions:
  - name: Cichy
    icon: mdi:circle-slice-1
    service: script.air_purifier_set_favorite_level
    service_data:
      level: 1
  - name: 25%
    icon: mdi:circle-slice-2
    service: script.air_purifier_set_favorite_level
    service_data:
      level: 3
  - name: 50%
    icon: mdi:circle-slice-4
    service: script.air_purifier_set_favorite_level
    service_data:
      level: 7
  - name: 75%
    icon: mdi:circle-slice-6
    service: script.air_purifier_set_favorite_level
    service_data:
      level: 10
  - name: 100%
    icon: mdi:circle-slice-8
    service: script.air_purifier_set_favorite_level
    service_data:
      level: 15
compact_view: true

@earglass you made my day! thank you very much!!!

@SaSa1983 answered this correctly. The card works fine, you just need to update your configuration.

leppa commented

I don't agree that it's enough to just update the configuration. There is broken functionality: for example, action icons no longer highlight active mode.

@leppa you're right. Reopening.

I don't agree that it's enough to just update the configuration. There is broken functionality: for example, action icons no longer highlight active mode.

So it's not me being stupid and futzing up my YAML config. Will wait for the bug to be fixed then.

This is my configuration right now. It sets the expected state on the purifier, but the 1/2/3 speeds all light up at the same time. Night mode and auto mode buttons light up as expected.

type: custom:purifier-card
entity: fan.mi_air_purifier_3h
actions:
  - name: Silent
    icon: mdi:weather-night
    preset_mode: Silent
  - name: '1'
    icon: mdi:circle-slice-3
    preset_mode: Fan
    speed: low
  - name: '2'
    icon: mdi:circle-slice-5
    speed: medium
    preset_mode: Fan
  - name: '3'
    icon: mdi:circle-slice-8
    speed: high
    preset_mode: Fan
  - name: Auto
    icon: mdi:brightness-auto
    preset_mode: Auto
aqi:
  entity_id: sensor.mi_air_purifier_3h_pm2_5
  unit: µg/m³
show_name: true
show_state: true
show_toolbar: true
stats:
  - entity_id: sensor.mi_air_purifier_3h_filter_life_remaining
    unit: '%'
    subtitle: Filter remaining

@martijnvandijk hey, I checked your config, preset_mode option is not supported. You can only pass speed, read more here: https://github.com/denysdovhan/purifier-card#actions-object

Indicators work fine on my Mi H3 with the latest version.

leppa commented

Previously, with this config (excerpt from the official documentation, by the way):

actions:
  - name: 50%
    icon: 'mdi:circle-slice-4'
    speed: Favorite
    xiaomi_miio_favorite_level: 7
  - name: 75%
    icon: 'mdi:circle-slice-6'
    speed: Favorite
    xiaomi_miio_favorite_level: 10

Clicking 50% icon would only highlight this icon. The 75% icon would remain inactive. Now, this config produces the following error message in the UI: "Failed to call service xiaomi_miio/fan_set_favorite_level. Service not found."

Using the hack, suggested by @earglass (calling a script), causes the action icon to always be highlighted, no matter which mode purifier is in.

So how do I get the old behavior back?

In addition to that, this config (official documentation, again):

actions:
  - name: Auto
    icon: 'mdi:brightness-auto'
    speed: Auto

produces the following warning in the Home Assistant log:

The fan.set_speed service is deprecated, use fan.set_percentage or fan.set_preset_mode instead

As this has been closed, can anyone post a config that works?

I don't have an issue with sensor readings, but do have an issue setting favourite speed via the icons.

"Failed to call service xiaomi_miio/fan_set_favorite_level. Service not found."

i agree with @Swiftnesses here. the config in the doc needs to be updated to make it work.
As it is since 2021.9 i was only able to get the info by tweaking the config like a member suggested
but all the buttons for setting speeds (25% to 100%) on the bottom are not functionnal
only buttons that function are auto, night and on/off toggle
image

Can we have an update on the documentation on how the config should be done for all the card to work as intended?

@denysdovhan Care to have a look at this config? The buttons perform the expected actions, but the icon highlighting does not work as expected. Switching from auto to low/medium/high does not make the new icon light up and the auto button does not dim. Switching between auto and silent does work as expected.

type: custom:purifier-card
entity: fan.mi_air_purifier_3h
actions:
  - name: Silent
    icon: mdi:weather-night
    speed: Silent
  - name: Low
    icon: mdi:circle-slice-3
    speed: low
  - name: Medium
    icon: mdi:circle-slice-5
    speed: medium
  - name: High
    icon: mdi:circle-slice-8
    speed: high
  - name: Auto
    icon: mdi:brightness-auto
    speed: Auto
aqi:
  entity_id: sensor.mi_air_purifier_3h_pm2_5
  unit: µg/m³
show_name: true
show_state: true
show_toolbar: true
stats:
  - entity_id: sensor.mi_air_purifier_3h_filter_life_remaining
    unit: '%'
    subtitle: Filter Remaining
  - entity_id: sensor.mi_air_purifier_3h_motor_speed
    unit: rpm
    subtitle: Motor Speed

Was this actually solved, there has been updates to the code, but the example config still appears to be wrong?