Skip to content
This repository was archived by the owner on Nov 19, 2026. It is now read-only.

Add support for the LIFAair LM05 air purifier - #2

Closed
pit3k wants to merge 9 commits into
async-masterfrom
feat/lifaair-lm05-async
Closed

pit3k wants to merge 9 commits into
async-masterfrom
feat/lifaair-lm05-async

Conversation

@pit3k

@pit3k pit3k commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Context

The LIFAair LM05 (devtype 0x4EC2, firmware 10026) is already supported on this repository's synchronous master, in pit3k/python-broadlink#1, which continued mjg59/python-broadlink#807. Home Assistant pins broadlink-async==1.3.0, and a separate fork of DAB-LABS/broadlink-async cannot be created because the two repositories share a fork network. This change hosts that device support on async-master, which points at DAB-LABS/broadlink-async 9c96c75 (tag v1.3.0).

This pull request is ready to be proposed to DAB-LABS/broadlink-async later. It is opened here, against async-master, only.

Proposed change

Adds a lifaair class for the LM05 and registers product id 0x4EC2 as model LM05, manufacturer LIFAair. Fan modes are the nested enum lifaair.FanMode.

  • get_state returns the station readings (CO2, TVOC, formaldehyde, PM1, PM2.5, PM10) and the purifier's fan mode, speed, temperature and humidity. Fan mode, speed, temperature and humidity are None when the purifier is offline. purifier_online is bit 7 of the fan-state byte. Bytes 27-29 of 00 00 00 on the first poll after reconnect are None, which is the placeholder, rather than 0.0 °C / 0 %.
  • set_fan_mode and set_fan_speed each send one packet carrying the encoded argument and return the decoded SET response. The call does not read before writing, and it does not verify or retry.
  • lifaair.FanMode.MANUAL, lifaair.FanMode.UNKNOWN and None have no mode command and raise ValueError. A speed is an int in 0..121; a bool is rejected.
  • Device errors are raised unchanged. Error -5 is StorageError.
  • While the main unit is offline, a mode command is rejected with -5 and a speed command is answered with the offline state. Neither change is applied after the unit reconnects.
  • Mode and speed stay independent. Anti-allergy is fan state 0x85 with flags bit 0x40 clear. Bit 0 of the fan-state byte is ignored when naming the mode. PM offsets match the device display (PM1, then PM2.5, then PM10).

broadlink_cli reads an LM05 with the existing --getstate option and sets the fan with --fanmode and --fanspeed, printing the decoded state. The behaviour was checked on an LM05 with firmware 10026 in #1. This port is checked against those captured frames.

Type of change

  • New device

Additional information

Checklist

  • The code change is tested and works locally (pytest).
  • ruff check . passes.
  • New device support was verified on real hardware, or the PR says it was not. Verified on an LM05 with firmware 10026 in Fix LIFAair LM05 readings found on the device #1; this port is checked against the captured frames.
  • CHANGELOG.md has an entry under Unreleased.
Open in Web Open in Cursor 

cursoragent and others added 9 commits November 18, 2026 10:45
Adds the lifaair class for the LM05 (0x4EC2). get_state decodes firmware
10026 frames. set_fan_mode and set_fan_speed each send one encoded
argument and return the decoded response. Fan mode, speed, temperature
and humidity are None when the purifier is offline. Tested on an LM05
with firmware 10026.

Co-authored-by: Piotr Paczyński <pit3k@users.noreply.github.com>
Device enums live on the device class and are not re-exported. FanMode
is now lifaair.FanMode. The two lookup tables are private, matching the
other device classes.

Co-authored-by: Piotr Paczyński <pit3k@users.noreply.github.com>
lifaair_state_data assigns each decoded field on its own line. The three
canned frames stay the bytes captured on firmware 10026.

Co-authored-by: Piotr Paczyński <pit3k@users.noreply.github.com>
One sentence of what the class supports, the CLI script, and who
contributed it.

Co-authored-by: Piotr Paczyński <pit3k@users.noreply.github.com>
broadlink_cli sets the fan with --fanmode and --fanspeed and prints
the decoded state. --sensors prints get_state for an LM05. The
per-device script is removed.

Co-authored-by: Piotr Paczyński <pit3k@users.noreply.github.com>
Drop the lifaair branch from --sensors. --getstate already prints
get_state, and --fanmode and --fanspeed stay.

Co-authored-by: Piotr Paczyński <pit3k@users.noreply.github.com>
--fanmode uses FanMode[name] only. The LM05 tests build the device
with the shared HOST and MAC and keep their helpers with the others.

Co-authored-by: Piotr Paczyński <pit3k@users.noreply.github.com>
Drop the tests that spy on _send or repeat the oracle. ValueError
cases only check the raise, and each decode test asserts its point.

Co-authored-by: Piotr Paczyński <pit3k@users.noreply.github.com>
The LM05 stops answering a source port after 10 received packets, and a
new port works with the same session key. lifaair drops its endpoint
after each exchange; other devices keep the one they already hold.

Co-authored-by: Piotr Paczyński <pit3k@users.noreply.github.com>
@pit3k pit3k closed this Nov 19, 2026
@pit3k
pit3k deleted the feat/lifaair-lm05-async branch November 19, 2026 17:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants