LightHub 4.6.0
Open-source smart home controller firmware
Loading...
Searching...
No Matches
out_AC Class Reference

Air conditioner driver (Haier IR-over-UART protocol), channel type CH_AC = 10. More...

#include <out_ac.h>

Inheritance diagram for out_AC:

Public Member Functions

 out_AC ()
 Default constructor; binds nothing until link() is called.
void link (Item *_item)
 Links the channel item, attaches persistent storage and reads the config.
void getConfig ()
 Reads itemArg and selects the UART port (0-3) for the AC line.
int Setup () override
 Initializes persistent storage and starts the UART at 9600 baud.
int Poll (short cause) override
 Polls the AC every 5 s, parses the 37-byte status frame and publishes the status topics.
int Stop () override
 Releases the persistent storage and marks the channel as unknown.
int isActive () override
 Returns 1 if the AC power bit is set, 0 otherwise.
int getChanType () override
 Returns CH_THERMO (5).
int Ctrl (itemCmd cmd, char *subItem=NULL, bool toExecute=true, bool authorized=false) override
 Applies a control command: /set, /cmd, /fan, /mode, and lock/swing/queit/raw subitems (see class doc).
void SubmitParameters (const char *name, itemCmd value)
 Invokes the named callback object ("fan"/"set"/"cmd"/"temp") from itemArg with a polled value.
Public Member Functions inherited from abstractOut
 abstractOut ()
virtual bool isAllowed (itemCmd cmd)
virtual itemCmd getDefaultOnVal ()
virtual int Status () override
virtual void setStatus (uint8_t status) override
Item * getItem ()
Public Member Functions inherited from abstractCh
 abstractCh ()
virtual ~abstractCh ()

Protected Member Functions

void InsertData (byte data[], size_t size)
void SendData (byte req[], size_t size)
Protected Member Functions inherited from abstractOut
int pubAction (bool state)
Protected Member Functions inherited from abstractCh
int publishTopic (const char *topic, long value, const char *subtopic=NULL)
int publishTopic (const char *topic, float value, const char *subtopic=NULL)
int publishTopic (const char *topic, const char *value, const char *subtopic=NULL, const char *suffix=NULL)

Protected Attributes

acPersistent * store
uint8_t portNum
HardwareSerial * ACSerial
Protected Attributes inherited from abstractOut
Item * item
 Item currently linked to this driver.

Detailed Description

Air conditioner driver (Haier IR-over-UART protocol), channel type CH_AC = 10.

Talks to a Haier AC over UART at 9600 baud using 13-byte request frames and 37-byte status frames (frame check = sum of bytes). Periodically polls the AC unit and applies control commands.

JSON config (itemArg): [portNum(0-3), callbacksObj]

  • portNum: 0 = default port (Serial3, or USB-CDC Serial), 1..3 = Serial1..Serial3;
  • callbacksObj (optional): object with keys "fan", "set", "cmd", "temp" holding execution objects invoked on every polled status update.

Ctrl commands:

  • /set 16-40 - set temperature;
  • /cmd - AUTO / HEAT / COOL / FAN_ONLY / DRY, plus ON / OFF;
  • /fan - LOW / MEDIUM / HIGH / AUTO / OFF, or a 0-255 value;
  • /mode <number> - raw mode code;
  • subitems: "lock" ON/OFF, "swing" ON/OFF, "queit" (sic) ON/OFF, "raw".

Published status topics: /set, /temp, /mode, /cmd, /fan, /fresh, /lock, /quiet, /compressor, /swing.

Constructor & Destructor Documentation

◆ out_AC()

out_AC::out_AC ( )
inline

Default constructor; binds nothing until link() is called.

Member Function Documentation

◆ Ctrl()

int out_AC::Ctrl ( itemCmd cmd,
char * subItem = NULL,
bool toExecute = true,
bool authorized = false )
overridevirtual

Applies a control command: /set, /cmd, /fan, /mode, and lock/swing/queit/raw subitems (see class doc).

ACSerial->flush();

Implements abstractOut.

◆ getChanType()

int out_AC::getChanType ( )
overridevirtual

Returns CH_THERMO (5).

Reimplemented from abstractOut.

◆ getConfig()

void out_AC::getConfig ( )

Reads itemArg and selects the UART port (0-3) for the AC line.

◆ InsertData()

void out_AC::InsertData ( byte data[],
size_t size )
protected

◆ isActive()

int out_AC::isActive ( )
overridevirtual

Returns 1 if the AC power bit is set, 0 otherwise.

Reimplemented from abstractOut.

◆ link()

void out_AC::link ( Item * _item)
inlinevirtual

Links the channel item, attaches persistent storage and reads the config.

Reimplemented from abstractOut.

◆ Poll()

int out_AC::Poll ( short cause)
overridevirtual

Polls the AC every 5 s, parses the 37-byte status frame and publishes the status topics.

Reimplemented from abstractCh.

◆ SendData()

void out_AC::SendData ( byte req[],
size_t size )
protected

◆ Setup()

int out_AC::Setup ( )
overridevirtual

Initializes persistent storage and starts the UART at 9600 baud.

Reimplemented from abstractOut.

◆ Stop()

int out_AC::Stop ( )
overridevirtual

Releases the persistent storage and marks the channel as unknown.

Reimplemented from abstractCh.

◆ SubmitParameters()

void out_AC::SubmitParameters ( const char * name,
itemCmd value )

Invokes the named callback object ("fan"/"set"/"cmd"/"temp") from itemArg with a polled value.

Member Data Documentation

◆ ACSerial

HardwareSerial* out_AC::ACSerial
protected

◆ portNum

uint8_t out_AC::portNum
protected

◆ store

acPersistent* out_AC::store
protected

The documentation for this class was generated from the following files: