Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with Xiaomi Air Purifier 4 Lite #1

Open
nightshadow931 opened this issue Feb 18, 2024 · 0 comments
Open

Compatibility with Xiaomi Air Purifier 4 Lite #1

nightshadow931 opened this issue Feb 18, 2024 · 0 comments

Comments

@nightshadow931
Copy link

nightshadow931 commented Feb 18, 2024

Hey mate,

I'm trying to get this to work with 4 lite, but having some issues :D
I'm not very good with yaml, so might be something is wrong in my code. Could you please check?

# Shows powerState, speed, mode
 - platform: template
    sensors:
      bedroom_fan_combined:
        friendly_name: "Bedroom Fan Combined"
        value_template: "{{ states('fan.zhimi_rmb1_b30a_air_purifier') }}, 
        {{ states.fan.bedroom_fan.attributes.percentage }}%, 
        {{ states.input_select.air_purifier_mode.state }}"

# Fan oscillation modes (without sleep mode)
input_select:
  air_purifier_mode:
    name: Air Purifier Mode
    options:
      - "Auto"
      - "Favorite"
    initial: "Auto"
    
# Actual entity for smart air purifier
fan:
  - platform: template
    fans:
      bedroom_fan:
        friendly_name: "Bedroom fan"
        value_template: "{{ is_state('fan.zhimi_rmb1_b30a_air_purifier', 'on') }}"
        percentage_template: >-
          {% if is_state('input_select.air_purifier_mode', 'Auto') %}
            {{ ((state_attr('fan.zhimi_rmb1_b30a_air_purifier', 'custom_service.moto_speed_rpm') - 400)
            / (2050 - 400)) * 100 | round(0, 'floor') }}
          {% else %}
            {{ (states('number.zhimi_rmb1_b30a_air_purifier_favorite_level') | int) * (100/14) }}
          {% endif %}
        preset_mode_template: "{{ states('input_select.air_purifier_mode') }}"
        oscillating_template: "{{ states('input_select.air_purifier_mode') }}"
        turn_on:
          service: fan.turn_on
          target:
            entity_id: fan.zhimi_rmb1_b30a_air_purifier
        turn_off:
          service: fan.turn_off
          target:
            entity_id: fan.zhimi_rmb1_b30a_air_purifier
        set_percentage:
          service: number.set_value
          target:
            entity_id: number.zhimi_rmb1_b30a_air_purifier_favorite_level
          data:
            value: "{{ (percentage * 14) / 100 | round(0, 'floor') }}"
        set_oscillating:
          - service: input_select.select_next
            target:
              entity_id: input_select.air_purifier_mode
          - service: fan.set_preset_mode
            target:
              entity_id: fan.zhimi_rmb1_b30a_air_purifier
            data_template:
              preset_mode: "{{ states('input_select.air_purifier_mode') }}"
        speed_count: 15
        preset_modes:
          - 'Auto'
          - 'Favorite'

Basically it doesn't let me change the fan speed in Favorite mode, only in Auto(which. obviously, doesn't work).

Also, some errors I've got:
image

Also, FWIW
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant