Skip to main content

Encode and decode Gree air-conditioner IR remote control signals

Project description

gree-rc-encoder

Python library to encode and decode Gree air-conditioner IR remote-control signals (pulse timings ↔ high-level state).

Install

From PyPI:

pip install gree-rc-encoder

From a local checkout (editable, with test deps):

pip install -e ".[dev]"

Quick start

from gree_rc import (
    GreeState,
    Mode,
    FanSpeed,
    encode_control,
    encode_temperature,
    decode,
    to_ir_ctl,
)

state = GreeState(
    is_on=True,
    mode=Mode.COOL,
    temperature=24,
    fan_speed=FanSpeed.AUTO,
    light_on=True,
)

timings = encode_control(state)       # list[int] durations in microseconds
print(to_ir_ctl(timings))             # "+9000 -4500 +655 ..." for ir-ctl

result = decode(timings)
assert result.state.temperature == 24

# I Feel: remote sensor reading (sent periodically while ifeel_mode is on)
temp_frame = encode_temperature(27)
assert decode(temp_frame).temperature == 27

API overview

Function Purpose
encode_control(state) GreeState → 559 timing values
decode_control(timings) timings / ir-ctl string → GreeState
encode_temperature(temp) I Feel ambient °C (0–255) → 35 timing values
decode_temperature(timings) → int °C
decode(timings) auto-detect control / temperature / combined → DecodeResult
to_ir_ctl / from_ir_ctl convert to/from ir-ctl pulse strings
encode_gree / parse_gree nibble-level frame without IR timings

The library performs no I/O and does not print; raise GreeEncodeError, GreeDecodeError, or GreeValidationError on failure.

Hardware demo

Real receive/transmit via ir-ctl lives in examples/ir_ctl_demo.py:

python3 examples/ir_ctl_demo.py receive
python3 examples/ir_ctl_demo.py send --dry-run
python3 examples/ir_ctl_demo.py temperature --dry-run

Tests

pytest

Protocol notes

Control frame

A typical control frame is four subsignals (139 timings each) separated by ~40 ms spaces. Each subsignal carries 16 nibbles (LSB-first bits), a 0,1,0 delimiter with a 20 ms space in the middle, a marker nibble, and a CRC nibble.

Markers identify the logical signal index (0..4). Captures may include more than four subsignals and may list them in any order; the decoder places each subsignal into a fixed 5-slot array by marker before parsing GreeState.

I Feel (ambient temperature)

When I Feel is enabled (GreeState.ifeel_mode), the remote periodically sends a short 35-sample frame with a different leading pulse. That frame carries the reading from the remote’s built-in temperature sensor so the indoor unit can hold the setpoint at the remote’s location rather than only at the AC.

Sleep mode level 3

sleep_mode_level values 1–2 are fixed sleep curves. Level 3 lets the user program an automatic temperature change every hour for up to eight hours. That schedule needs an extra subsignal (logical slot 4 / ~699-sample capture). This library decodes the level flag and will accept/arrange the extra subsignal by marker, but encoding and full parsing of the eight hourly setpoints is not implemented yet.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gree_rc_encoder-0.1.0.tar.gz (30.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gree_rc_encoder-0.1.0-py3-none-any.whl (29.7 kB view details)

Uploaded Python 3

File details

Details for the file gree_rc_encoder-0.1.0.tar.gz.

File metadata

  • Download URL: gree_rc_encoder-0.1.0.tar.gz
  • Upload date:
  • Size: 30.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for gree_rc_encoder-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2fb2b4f7478530ac69d1edbbf04e8c70c9124e86e777dead29013b4e5a322438
MD5 d39ae64d624c37b1e27f98440fedea81
BLAKE2b-256 4eedba7c520e3a96e2114e45b33237c9fb99e4c87e879b82da3d9b8f5dd92c0d

See more details on using hashes here.

File details

Details for the file gree_rc_encoder-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for gree_rc_encoder-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4392023a7d7a70a6c4827ef1a7b2163aee69d96ba6856194e4f6cb35b4576e75
MD5 09c3ed6283be7c91f172e116fd1f2e91
BLAKE2b-256 ac95af22d07a79de2b3959e7e96961f0531ad80c971966ffbcc91e2d3d440037

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page