Package: eakon
eakoneakon is a simple python library to control air-conditioners.There are many examples of such code on the web, but I found none did not cover my needs:Each HVAC unit to control needs to have its own instance created (the instance being dependent on the unit maker).Each instance keeps track of the current status of the air-conditioner (assuming it is not changed with the unit
remote control)The status can be made persistenthandle japanese market air-conditionersMoreover, the code was to be kept the least esoteric as possible, to ensure readability and evolutions.Usage ofbitstringgreatly helped to reach this objective.UsageDuring or after instantiation, settings are made, and you get either a bitstring or a wave.
The wave is in a format to be consumed by thepigpio library, following the example of
thesample irrp.pyscript.N.B. : The irrp.py script has length limitations.
You can refer to (or better yet, use) myAnaviInfraredPhatlibrary
which handles compression of waves for working around length limitations of pigpio.The compression algorithm is credit ofhttps://korintje.com/archives/28hvac=Daikin()hvac.power=daikin_enum.Power.ONhvac.temperature=21hvac.mode=daikin_enum.Mode.COOLhvac.fan_vertical_mode=daikin_enum.FanVerticalMode.TOPlogging.info("\r{}".format(hvac))logging.info(hvac.bitstring)logging.info(hvac.wave)>>2020-01-0100:00:00.000UTC[INFO]__init__:Model:Daikinpower:ONmode:COOLtemperature:21°Cwide_vanne_mode:NOT_AVAILABLEarea_mode:NOT_AVAILABLEfan_power:AUTOfan_high_power:NOT_AVAILABLEfan_vertical_mode:TOPfan_horizontal_mode:UNDEFINEDfan_long:NOT_AVAILABLE2020-01-0100:00:00.000UTC[INFO]__init__:1000100001011011111001000000000001000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000100100100010000101101111100100000000000000000010011100010101000000000000000101000000000000000001100000000001100000000000000000110000110000000000000000011111002020-01-0100:00:00.000UTC[INFO]__init__:[433,440,433,440,433,440,433,440,433,440,433,25194,3495,1746,433,1288,433,440,433,440,433,440,433,1288,433,440,433,440,433,440,433,440,433,1288,433,440,433,1288,433,1288,433,440,433,1288,433,1288,433,1288,433,1288,433,1288,433,440,433,440,433,1288,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,1288,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,1288,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,1288,433,440,433,440,433,1288,433,440,433,440,433,25194,3495,1746,433,1288,433,440,433,440,433,440,433,1288,433,440,433,440,433,440,433,440,433,1288,433,440,433,1288,433,1288,433,440,433,1288,433,1288,433,1288,433,1288,433,1288,433,440,433,440,433,1288,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,1288,433,440,433,440,433,1288,433,1288,433,1288,433,440,433,440,433,440,433,1288,433,440,433,1288,433,440,433,1288,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,1288,433,440,433,1288,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,1288,433,1288,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,1288,433,1288,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,1288,433,1288,433,440,433,440,433,440,433,440,433,1288,433,1288,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,1288,433,1288,433,1288,433,1288,433,1288,433,440,433,440,433]hvac.power=daikin_enum.Power.OFFlogging.info("\r{}".format(hvac))logging.info(hvac.bitstring)logging.info(hvac.wave)>>2020-01-0100:00:00.000UTC[INFO]__init__:Model:Daikinpower:OFFmode:COOLtemperature:21°Cwide_vanne_mode:NOT_AVAILABLEarea_mode:NOT_AVAILABLEfan_power:AUTOfan_high_power:NOT_AVAILABLEfan_vertical_mode:TOPfan_horizontal_mode:UNDEFINEDfan_long:NOT_AVAILABLE2020-01-0100:00:00.000UTC[INFO]__init__:1000100001011011111001000000000001000000000000000000000000000000000000000000000000000000000000010000100000000000000000000000000000000000000000000000000000100101100010000101101111100100000000000000000000011100010101000000000000000101000000000000000001100000000001100000000000000000110000110000000000000000101111002020-01-0100:00:00.000UTC[INFO]__init__:[433,440,433,440,433,440,433,440,433,440,433,25194,3495,1746,433,1288,433,440,433,440,433,440,433,1288,433,440,433,440,433,440,433,440,433,1288,433,440,433,1288,433,1288,433,440,433,1288,433,1288,433,1288,433,1288,433,1288,433,440,433,440,433,1288,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,1288,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,1288,433,440,433,440,433,440,433,440,433,1288,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,1288,433,440,433,440,433,1288,433,440,433,1288,433,25194,3495,1746,433,1288,433,440,433,440,433,440,433,1288,433,440,433,440,433,440,433,440,433,1288,433,440,433,1288,433,1288,433,440,433,1288,433,1288,433,1288,433,1288,433,1288,433,440,433,440,433,1288,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,1288,433,1288,433,1288,433,440,433,440,433,440,433,1288,433,440,433,1288,433,440,433,1288,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,1288,433,440,433,1288,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,1288,433,1288,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,1288,433,1288,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,1288,433,1288,433,440,433,440,433,440,433,440,433,1288,433,1288,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,440,433,1288,433,440,433,1288,433,1288,433,1288,433,1288,433,440,433,440,433]The bitstring is mostly used for debugging purpose, but I assume it could be used for other purpose.Now, you may have multiple HVAC of different models in your housing, and you may need an easy way to configure which
model is in which room.For such cases, a helper method is available for dynamically instantiating by name:try:e=get_eakon_instance_by_model("toshiba")e.power=e.enums["Power"].ONe.temperature=26e.mode=e.enums["Mode"].COOLlogging.info("\r\n{}".format(e))logging.info(e.bitstring)exceptNotImplementedErrorase:logging.warning(e)>>2020-01-0100:00:00.000UTC[INFO]__init__:Model:Toshibapower:ONmode:COOLtemperature:26°Cwide_vanne_mode:NOT_AVAILABLEarea_mode:NOT_AVAILABLEfan_power:UNDEFINEDfan_high_power:NOT_AVAILABLEfan_vertical_mode:UNDEFINEDfan_horizontal_mode:NOT_AVAILABLEfan_long:NOT_AVAILABLE2020-01-0100:00:00.000UTC[INFO]__init__:1100001000111101101111110100000011010000001011112020-01-0100:00:00.000UTC[WARNING]__init__:NomoduletotoimplementingclassTotowasfound.Modeltotoisunsupported.As you can notice comparing the two above examples, the Daikin class supports setting the 'fan_horizontal_mode' (but is
currently UNDEFINED) but the Toshiba class doesn't.Moreover, the first example shows settings the properties by direct use of the associated enumerations, while the second
example shows setting properties by name.N.B.: The purpose here is to allow accessing the model specific enumerations without having to refer to them in a
hardcoded manner.Settings values can also be set with strings, i.e.e.power = e.enums["Power"].ONis equivalent
toe.power = e.enums["Power"]["ON"]Accessing an unavailable enumeration element will raise either anAttributeErroror aKeyError, depending on the
access method employed:e.power=e.enums["Power"].PARTIALLY_ON>>AttributeError:PARTIALLY_ONe.power=e.enums["Power"]["PARTIALLY_ON"]>>KeyError:'PARTIALLY_ON'Lastly, if a model is unsupported, aNotImplementedErroris raised:try:e=get_eakon_instance_by_model("toto")exceptNotImplementedErrorase:logging.warning(e)>>2020-01-0100:00:00.000UTC[WARNING]__init__:NomoduletotoimplementingclassTotowasfound.Modeltotoisunsupported.(Known) Supported modelsAs the name (エアコン) of the library implies, there is a strong focus on japanese brands, and quite possibly is limited to
recent (2020) japanese models.Development was done with the following models of remote controls:Daikin ARC47850 (Units models C and CX at least)
Daikin has at least 2 other protocols available in Japan (Moreover, it is likely that protocols used for non-domestic
market differs).Hitachi SP-RC4 (coversa lot of hitachi models)Toshiba RG66J5 (apparently all units from 2020, possibly also few years before ?)Panasonic ACRA75C series (CS-xxxCF* air-conditioning units -
seehttps://ec-plus.panasonic.jp/store/ap/storeaez/a2A/ProductDetail?HB=ACRA75C13970X)Implementation of additional models should be relatively easy.LimitationsOnly standard functions are implemented,in extenso:timers aren't supported (by lack of interest)extra functions like unit cleaning, triggering of diagnostic, etc... aren't supportedhalf degrees available on some units aren't supportedInstallationpython3-mpipinstalleakon