feat: add Panasonic A/C protocol and Hong Kong/Macau model#45
Draft
sam0737 wants to merge 2 commits into
Draft
Conversation
Introduce a generic PanasonicAcCommand that encodes the shared Panasonic A/C two-section framing (8-byte section 1 + variable section 2, LSB-first, 38 kHz), and a PanasonicAcHkCommand subclass that builds the full state and Quiet/Powerful short frames for Hong Kong/Macau models (CW-HU/HZ/SU/SUL). Co-authored-by: Cursor <cursoragent@cursor.com>
abmantis
requested changes
Jun 1, 2026
abmantis
requested changes
Jun 1, 2026
…stead, and add multi-frame data support to it. Remove PanasonicAcHkCommand - Modified KaseikyoCommand to accept `data` as either a single `bytes` or a `list[bytes]`, allowing for multi-frame IR commands. - Enhanced the initialization docstring to clarify the usage of `data`. - Removed the PanasonicAcHkCommand and its associated tests, consolidating functionality into the PanasonicAcCommand. - Updated PanasonicAcCommand to handle the new multi-frame structure and maintain compatibility with existing features.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for encoding Panasonic air-conditioner IR signals.
Following review, this was reworked to build on the existing Kaseikyo (AEHA) support rather than adding a separate framing layer: a Panasonic A/C frame is a Kaseikyo frame with the Panasonic vendor address
0x2002, and the full state is simply two such frames. The only missing piece inKaseikyoCommandwas multi-frame support, which had been removed in 869f5d8 (#27) and is re-added here.Changes
commands/kaseikyo.py— re-add multi-frame support.KaseikyoCommand(data=...)now accepts either a singlebytes(one frame, unchanged behaviour) or alist[bytes](several same-address frames emitted as one message, separated by an inter-frame gap). Single-frame callers (e.g. the Panasonic ceiling light) are unaffected.commands/panasonic_ac.py— a generic, model-agnostic Panasonic A/C encoder built onKaseikyoCommand:PanasonicAcCommand— full 27-byte state. Keyword-only__init__exposing the complete field set (power,mode,temperaturewith 0.5 °C step,fan, two swing axes,nanoex) with sensible defaults, so callers drive whichever combination their unit supports.temperatureis validated againstMIN_TEMP/MAX_TEMP.PanasonicAcToggleCommand— the short 16-byte Quiet/Powerful toggle frame.IntEnums carrying the protocol nibble as their value (no lookup dicts):PanasonicAcMode,PanasonicAcFanSpeed,PanasonicAcSwingAxis1(byte 16 low nibble),PanasonicAcSwingAxis2(byte 17 low nibble), andPanasonicAcToggle.Notes (responses to review)
PanasonicAcHkCommandand the separate framing base are gone; everything is the genericPanasonicAcCommandon top of Kaseikyo.Axis1/Axis2and the caller maps axis → real-world direction. The 2-axis swing values follow the IRremoteESP8266 constants.The reverse-engineered protocol (frame layout, field encodings, checksum, timings) is documented here: https://github.com/sam0737/panasonic_window_ac_hk/blob/main/custom_components/panasonic_window_ac_hk/PROTOCOL.md
Testing
tests/commands/test_panasonic_ac.py— encodes through the full stack, then decodes the raw timings back to bytes and asserts against the documented known-good frames. This keeps the tests robust to Kaseikyo timing-constant tweaks (those exact timings stay pinned intest_kaseikyo.py). Plus field-level checks: power bit, nanoeX, both swing axes, and out-of-range temperature.uv run pytest -q— all pass.uv run prek --all-files— ruff + basedpyright pass.Related work
This backs the Home Assistant
panasonic_window_ac_hkintegration (see home-assistant/home-assistant.io#45662), which has been updated to map its state onto these generic commands once this is released.Made with Cursor