LightHub 4.6.0
Open-source smart home controller firmware
Loading...
Searching...
No Matches
out_ac.h
Go to the documentation of this file.
1
2#pragma once
3#ifndef AC_DISABLE
4#include <abstractout.h>
5#include <item.h>
6#include "itemCmd.h"
7
9#define LEN_B 37
10#define B_CUR_TMP 13 //Текущая температура
11#define B_CMD 17 // 00-команда 7F-ответ ???
12#define B_MODE 23 //04 - DRY, 01 - cool, 02 - heat, 00 - smart 03 - вентиляция
13#define B_FAN_SPD 25 //Скорость 02 - min, 01 - mid, 00 - max, 03 - auto
14#define B_SWING 27 //01 - верхний и нижний предел вкл. 00 - выкл. 02 - левый/правый вкл. 03 - оба вкл
15#define B_LOCK_REM 28 //80 блокировка вкл. 00 - выкл
16#define B_POWER 29 //on/off 01 - on, 00 - off (10, 11)-Компрессор??? 09 - QUIET
17#define B_FRESH 31 //fresh 00 - off, 01 - on
18#define B_SET_TMP 35 //Установленная температура
19
21#define S_LOCK S_ADDITIONAL+1
22#define S_QUIET S_ADDITIONAL+2
23#define S_SWING S_ADDITIONAL+3
24//#define S_RAW S_ADDITIONAL+4
25
26extern void modbusIdle(void) ;
27
35class acPersistent : public chPersistent {
36public:
37 byte data[37];
38 byte power;
39 byte mode;
40 byte inCheck;
41 uint32_t timestamp;
42};
43
66class out_AC : public abstractOut {
67public:
68
70 out_AC():store(NULL),portNum(0),ACSerial(NULL){};
72 void link(Item * _item){abstractOut::link(_item); if (_item) {store = (acPersistent *) item->getPersistent(); getConfig();} else store = NULL;};
74 void getConfig();
76 int Setup() override;
78 int Poll(short cause) override;
80 int Stop() override;
82 int isActive() override;
84 int getChanType() override;
85 // int getDefaultStorageType(){return ST_FLOAT_CELSIUS;};
87 int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true, bool authorized = false) override;
89 void SubmitParameters(const char * name, itemCmd value);
90
91protected:
93 void InsertData(byte data[], size_t size);
94 void SendData(byte req[], size_t size);
95 uint8_t portNum;
96 #if defined (__SAM3X8E__)
97 UARTClass *ACSerial;
98 #else
99 HardwareSerial *ACSerial;
100 #endif
101
102};
103#endif
A single LightHub item (virtual channel).
Definition item.h:232
chPersistent * getPersistent()
Definition item.cpp:641
abstractOut()
Definition abstractout.h:22
virtual void link(Item *_item)
Definition abstractout.h:24
Item * item
Item currently linked to this driver.
Definition abstractout.h:55
Persistent per-item state of an AC channel, stored in the config tree.
Definition out_ac.h:35
byte power
Definition out_ac.h:38
byte inCheck
Definition out_ac.h:40
byte mode
Definition out_ac.h:39
byte data[37]
Definition out_ac.h:37
uint32_t timestamp
Definition out_ac.h:41
Placeholder for driver-persistent data attached to an item (I_EXT field).
Definition abstractout.h:8
Command + value container passed between items, drivers and MQTT.
Definition itemCmd.h:306
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)...
Definition out_ac.cpp:497
int Setup() override
Initializes persistent storage and starts the UART at 9600 baud.
Definition out_ac.cpp:325
int Poll(short cause) override
Polls the AC every 5 s, parses the 37-byte status frame and publishes the status topics.
Definition out_ac.cpp:398
uint8_t portNum
Definition out_ac.h:95
int Stop() override
Releases the persistent storage and marks the channel as unknown.
Definition out_ac.cpp:367
void getConfig()
Reads itemArg and selects the UART port (0-3) for the AC line.
Definition out_ac.cpp:48
void SendData(byte req[], size_t size)
Definition out_ac.cpp:284
HardwareSerial * ACSerial
Definition out_ac.h:99
acPersistent * store
Definition out_ac.h:92
int isActive() override
Returns 1 if the AC power bit is set, 0 otherwise.
Definition out_ac.cpp:392
out_AC()
Default constructor; binds nothing until link() is called.
Definition out_ac.h:70
void link(Item *_item)
Links the channel item, attaches persistent storage and reads the config.
Definition out_ac.h:72
void InsertData(byte data[], size_t size)
Definition out_ac.cpp:92
int getChanType() override
Returns CH_THERMO (5).
Definition out_ac.cpp:769
Item (virtual channel) system of LightHub.
void modbusIdle(void)
Idle hook invoked by the Modbus code between serial operations to let the main system breathe.
Definition main.cpp:3008
void SubmitParameters(aJsonObject *callbackObj, const char *name, itemCmd value, bool doMapping)
Definition out_multivent.cpp:420