|
LightHub 4.6.0
Open-source smart home controller firmware
|
Item (virtual channel) system of LightHub. More...
Go to the source code of this file.
Classes | |
| class | Item |
| A single LightHub item (virtual channel). More... | |
| class | driverFactory |
| Creates and shares output drivers for items. More... | |
| union | thermostatStore |
| CH_THERMO runtime state packed into one int32 (stored in I_EXT). More... | |
Macros | |
| #define | S_NOTFOUND 0 |
| #define | S_CMD 1 |
| #define | S_SET 2 |
| #define | S_VAL 3 |
| #define | S_DELAYED 4 |
| #define | S_HSV 5 |
| #define | S_RGB 6 |
| #define | S_FAN 7 |
| #define | S_MODE 8 |
| #define | S_CTRL 9 |
| #define | S_HUE 10 |
| #define | S_SAT 11 |
| #define | S_TEMP 12 |
| #define | S_RAW 13 |
| #define | suffixNum sizeof(suffix_P)/sizeof(suffixstr) |
| #define | S_ADDITIONAL 13 |
| #define | CH_DIMMER 0 |
| #define | CH_RGBW 1 |
| #define | CH_RGB 2 |
| #define | CH_PWM 3 |
| #define | CH_MODBUS 4 |
| #define | CH_THERMO 5 |
| #define | CH_RELAY 6 |
| #define | CH_GROUP 7 |
| #define | CH_VCTEMP 8 |
| #define | CH_VC 9 |
| #define | CH_AC 10 |
| #define | CH_SPILED 11 |
| #define | CH_MOTOR 12 |
| #define | CH_PID 13 |
| #define | CH_MBUS 14 |
| #define | CH_UARTBRIDGE 15 |
| #define | CH_RELAYX 16 |
| #define | CH_RGBWW 17 |
| #define | CH_MULTIVENT 18 |
| #define | CH_ELEVATOR 19 |
| #define | CH_COUNTER 20 |
| #define | CH_HUMIDIFIER 21 |
| #define | CH_MERCURY 22 |
| #define | CH_SPRINKLER 23 |
| #define | CH_MAX 23 |
| #define | POLLING_SLOW 1 |
| #define | POLLING_FAST 2 |
| #define | POLLING_INT 3 |
| #define | POLLING_1S 4 |
| #define | CTRL_DISABLE_RECURSION 1 |
| #define | CTRL_DISABLE_NON_GRP 2 |
| #define | CTRL_SCHEDULED_CALL_RECURSION (CTRL_DISABLE_RECURSION | CTRL_DISABLE_NON_GRP) |
| #define | I_TYPE 0 |
| #define | I_ARG 1 |
| #define | I_VAL 2 |
| #define | I_CMD 3 |
| #define | I_EXT 4 |
| #define | I_TIMESTAMP 5 |
| #define | MODBUS_CMD_ARG_ADDR 0 |
| #define | MODBUS_CMD_ARG_REG 1 |
| #define | MODBUS_CMD_ARG_MASK 2 |
| #define | MODBUS_CMD_ARG_MAX_SCALE 3 |
| #define | MODBUS_CMD_ARG_REG_TYPE 4 |
| #define | MODBUS_COIL_REG_TYPE 0 |
| #define | MODBUS_DISCRETE_REG_TYPE 1 |
| #define | MODBUS_HOLDING_REG_TYPE 2 |
| #define | MODBUS_INPUT_REG_TYPE 3 |
Typedefs | |
| typedef char | suffixstr[5] |
Functions | |
| short | thermoSetCurTemp (char *name, float t) |
| int | txt2cmd (char *payload) |
| int | txt2subItem (char *payload) |
Variables | |
| const suffixstr suffix_P[] | PROGMEM |
| aJsonObject * | items |
Item (virtual channel) system of LightHub.
LightHub models every controllable device, sensor or service as an "item" (virtual channel) stored as a JSON array inside the global items object: [type, arg, val, cmd, ext, timestamp] (element indexes I_TYPE..I_TIMESTAMP). The item name is the key of the array; the type (CH_*) selects the driver module (DMX dimmer, relay, Modbus, thermostat, AC, ...) that handles it.
An item can be a single channel (CH_DIMMER, CH_RELAY, ...) or a CH_GROUP pseudo-channel which fans commands out recursively to its members. Commands and values travel to/from items as itemCmd structures and are published to MQTT topics with the suffixes of suffix_P (cmd/set/val/del/HSV/RGB/fan/mode/ctrl/hue/sat/temp/raw).
| #define CH_AC 10 |
| #define CH_COUNTER 20 |
| #define CH_DIMMER 0 |
Channel (item) types, indexes CH_DIMMER(0)..CH_SPRINKLER(23)=CH_MAX. The type is stored in the I_TYPE element of the item array and selects the output driver module that handles the item.
| #define CH_ELEVATOR 19 |
| #define CH_GROUP 7 |
| #define CH_HUMIDIFIER 21 |
| #define CH_MAX 23 |
| #define CH_MBUS 14 |
| #define CH_MERCURY 22 |
| #define CH_MODBUS 4 |
| #define CH_MOTOR 12 |
| #define CH_MULTIVENT 18 |
| #define CH_PID 13 |
| #define CH_PWM 3 |
| #define CH_RELAY 6 |
| #define CH_RELAYX 16 |
| #define CH_RGB 2 |
| #define CH_RGBW 1 |
| #define CH_RGBWW 17 |
| #define CH_SPILED 11 |
| #define CH_SPRINKLER 23 |
| #define CH_THERMO 5 |
| #define CH_UARTBRIDGE 15 |
| #define CH_VC 9 |
| #define CH_VCTEMP 8 |
| #define CTRL_DISABLE_NON_GRP 2 |
| #define CTRL_DISABLE_RECURSION 1 |
Group execution flags passed to Item::Ctrl(itemCmd, ...):
| #define CTRL_SCHEDULED_CALL_RECURSION (CTRL_DISABLE_RECURSION | CTRL_DISABLE_NON_GRP) |
| #define I_ARG 1 |
| #define I_CMD 3 |
| #define I_EXT 4 |
| #define I_TIMESTAMP 5 |
| #define I_TYPE 0 |
Element indexes of the item JSON array:
| #define I_VAL 2 |
| #define MODBUS_CMD_ARG_ADDR 0 |
Argument array indexes of a CH_MODBUS item: I_ARG = [addr, reg, mask, maxScale, regType].
| #define MODBUS_CMD_ARG_MASK 2 |
| #define MODBUS_CMD_ARG_MAX_SCALE 3 |
| #define MODBUS_CMD_ARG_REG 1 |
| #define MODBUS_CMD_ARG_REG_TYPE 4 |
| #define MODBUS_COIL_REG_TYPE 0 |
Modbus register types: 0 - coils, 1 - discrete inputs, 2 - holding, 3 - input.
| #define MODBUS_DISCRETE_REG_TYPE 1 |
| #define MODBUS_HOLDING_REG_TYPE 2 |
| #define MODBUS_INPUT_REG_TYPE 3 |
| #define POLLING_1S 4 |
| #define POLLING_FAST 2 |
| #define POLLING_INT 3 |
| #define POLLING_SLOW 1 |
Polling rates/causes passed to Item::Poll() and driver Poll():
| #define S_ADDITIONAL 13 |
| #define S_CMD 1 |
| #define S_CTRL 9 |
| #define S_DELAYED 4 |
| #define S_FAN 7 |
| #define S_HSV 5 |
| #define S_HUE 10 |
| #define S_MODE 8 |
| #define S_NOTFOUND 0 |
Suffix (subtopic) codes - indexes of the suffix_P table below. S_NOTFOUND means "no suffix given" (universal/empty OpenHAB topic).
| #define S_RAW 13 |
| #define S_RGB 6 |
| #define S_SAT 11 |
| #define S_SET 2 |
| #define S_TEMP 12 |
| #define S_VAL 3 |
| #define suffixNum sizeof(suffix_P)/sizeof(suffixstr) |
| typedef char suffixstr[5] |
MQTT topic suffixes (subtopics) used per item:
|
extern |
Store the current measured temperature of a CH_THERMO item by name.
| int txt2cmd | ( | char * | payload | ) |
Translate a text payload to a command code.
| payload | - text command word ("ON", "HALT", ...), number or color |
| int txt2subItem | ( | char * | payload | ) |
Translate a subtopic text to a suffix code (index of suffix_P).
| payload | - suffix text ("cmd", "set", "val", ...) |
|
extern |
Global JSON object with all items (virtual channels) of this device.
| const suffixstr suffix_P [] PROGMEM |