Skip to content

Add support for LIFAair air purifier - #807

Closed
pit3k wants to merge 8 commits into
mjg59:devfrom
pit3k:master
Closed

pit3k wants to merge 8 commits into
mjg59:devfrom
pit3k:master

Conversation

@pit3k

@pit3k pit3k commented Jul 14, 2024

Copy link
Copy Markdown

Context

I have LIFAair air purifier that talks broadlink protocol. I've added support for it.
It supports controlling the fan and reading it's various sensors: temperature, humidity, co2, TVOC, PM2.5.
Product link: https://lifa-air.com/products/lifa-air-la330-air-purifier

Proposed change

Implement support for it and add a simple cli script that can be used to test this device.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New device
  • New product id (the device is already supported with a different id)
  • New feature (which adds functionality to an existing device)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests
  • Documentation

Additional information

  • This PR fixes issue: fixes #
  • This PR is related to:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • The code has been formatted using Black.
  • The code follows the Zen of Python.
  • I am creating the Pull Request against the correct branch.
  • Documentation added/updated.

@pit3k

pit3k commented May 10, 2025

Copy link
Copy Markdown
Author

Is there any reason this pull request does not get approved? Anything I should change or improve?

I have added support for this device to home assistant but this pull request is a prerequisite.

@xain

xain commented Oct 26, 2026

Copy link
Copy Markdown

I've been reverse-engineering the same device family (a LIFAair LAM01, the monitor supplied with the LA500/LA350A, firmware 10026, model string LM05, type 0x4ec2) and have a few corrections that matter if anyone uses this PR to build an integration. Each field below was verified by stimulating the corresponding sensor and correlating the decoded value with what the device displays, rather than by guessing.

1. pm1 and pm10 are swapped

On an 80-byte GET_STATE payload from a LAM01:

offset current code measured
37 pm10 PM1.0
39 pm2_5 PM2.5 (agrees)
41 pm1 PM10

Across 315 consecutive frames offset37 <= offset39 <= offset41 always holds. Since PM1.0 is a subset of PM2.5 which is a subset of PM10, the ascending order fixes the labels. Cross-check against the display: it showed PM2.5 = 30 while offset 39 read 30.1 (15-frame mean), and when I heated rosin flux next to the sensor the display read "2000+" while offset 39 peaked at 2022.

2. Formaldehyde is at offset 33 and isn't decoded at all

u16_le(33) / 100 gives mg/m³. I held an alcohol swab near the intake (the manual warns the electrochemical cell cross-reacts strongly with alcohol): the display went 0 → 0.3 → 1.2 mg/m³ while the data went 0 → 30 → 120, then decayed back to 0 over ~60 s in step with the display.

3. temperature / humidity come back as constants, not None

With no purifier paired, offsets 27/29 return 25/45 forever — which the current code decodes as a permanent 2.5 °C / 45 %. The docstring says those keys can be None when the main unit is offline; on this firmware they are stale defaults instead. That is arguably worse than None for a sensor entity, so it may be worth handling explicitly (e.g. treating unchanged 25/45 as "unavailable").

4. Offsets 66..79 look like uninitialised memory

They change on every request — all zeros in the first frame after boot, then random bytes. Nothing meaningful to decode there.

Happy to share the raw frame dumps, captures, or the stimulation methodology if useful.

- Swap PM1/PM10 offsets (verified ascending order vs device display)
- Decode formaldehyde at offset 33 (mg/m3)
- Treat fan_state 0x01 as offline before anti-allergy flag
- Export FanMode from package; update README and test CLI

Co-authored-by: Piotr Paczyński <pit3k@users.noreply.github.com>
Placeholder temperature and humidity zeros now return None, including the
first poll after the purifier reconnects. On this device, error -5 is no
longer reported as a full storage. Fan mode and speed stay as reported.

CO2 400 after boot is unchanged: no other byte marks that warm-up.

Co-authored-by: Piotr Paczyński <pit3k@users.noreply.github.com>
cursoragent and others added 5 commits November 17, 2026 14:55
One sighting during power-cycling and pairing is not enough to call -5
pairing mode. Drop the device-specific mapping and its tests. A short
comment records that the cause is unknown.

Co-authored-by: Piotr Paczyński <pit3k@users.noreply.github.com>
AUTO at speed 0 and OFF at speed 50 are reported values. Drop standby
and any claim about whether the fan was physically spinning.

Co-authored-by: Piotr Paczyński <pit3k@users.noreply.github.com>
set_fan_mode and set_fan_speed send one argument and return the decoded
SET response. MANUAL has no mode command. Reads expose purifier_online
from bit 7 of the fan-state byte and ignore bit 0 when naming the mode.

Co-authored-by: Piotr Paczyński <pit3k@users.noreply.github.com>
The station accepts a speed and returns the offline state, and it
rejects a mode with error -5. Neither change is applied after reconnect.

Co-authored-by: Piotr Paczyński <pit3k@users.noreply.github.com>
Fix LIFAair LM05 readings found on the device
@pit3k

pit3k commented Nov 18, 2026

Copy link
Copy Markdown
Author

Thanks @xain, this matches what I found on my LM05.

  1. PM1/PM10 swap: confirmed and fixed.
  2. Formaldehyde: now decoded from offset 33 (/100, mg/m³). My unit always reads 0 there, so the scale is taken from your test.
  3. Temperature/humidity: on my firmware an offline or unpaired purifier reports fan_state 0x01, and those keys are returned as None. I never saw the 25/45 defaults.
  4. Offsets 66–79: not decoded.

Home Assistant now uses broadlink-async instead of this library, so I've moved LM05 support there: DAB-LABS#29. Closing this one in favour of it.

@pit3k pit3k closed this Nov 18, 2026
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

Successfully merging this pull request may close these issues.

3 participants