|
LightHub 4.6.0
Open-source smart home controller firmware
|
Command + value container passed between items, drivers and MQTT. More...
#include <itemCmd.h>
Public Member Functions | |
| itemCmd (uint8_t _type=ST_VOID, uint8_t _code=CMD_VOID) | |
| Constructor with definition of type and command. | |
| itemCmd (float val) | |
| Constructor with definition of FLOAT value in storage. | |
| itemCmd (Item *item) | |
| Constructor with loading value from Item. | |
| itemCmd (char *cmd) | |
| itemCmd | assignFrom (itemCmd from, short chanType=-1) |
| bool | loadItem (Item *item, uint16_t optionsFlag=FLAG_PARAMETERS) |
| bool | loadItemDef (Item *item, uint16_t optionsFlag=FLAG_PARAMETERS) |
| bool | saveItem (Item *item, uint16_t optionsFlag=FLAG_PARAMETERS) |
| itemCmd | Int (int32_t i) |
| itemCmd | uInt (uint32_t i) |
| itemCmd | Float (float f) |
| itemCmd | Tens (int32_t i) |
| itemCmd | Tens_raw (int32_t i) |
| itemCmd | Cmd (uint8_t i) |
| itemCmd | Cmd (itemCmd i) |
| itemCmd | HSV (uint16_t h, uint8_t s, uint8_t v) |
| itemCmd | HSV255 (uint16_t h, uint8_t s, uint8_t v) |
| itemCmd | HS (uint16_t h, uint8_t s) |
| itemCmd | RGB (uint8_t r, uint8_t g, uint8_t b) |
| itemCmd | RGBW (uint8_t r, uint8_t g, uint8_t b, uint8_t w) |
| itemCmd | Str (char *str) |
| bool | setH (uint16_t) |
| bool | setS (uint8_t) |
| bool | setColorTemp (int) |
| int | getColorTemp () |
| uint16_t | getH () |
| uint16_t | getS () |
| itemCmd | setArgType (uint8_t) |
| itemCmd | convertTo (uint8_t) |
| uint8_t | getStoragetypeByChanType (short chanType) |
| itemCmd | Percents (int i) |
| itemCmd | Percents255 (int i) |
| uint8_t | getSuffix () |
| itemCmd | setSuffix (uint8_t suffix) |
| bool | incrementPercents (long int, long int limit) |
| bool | incrementH (long int) |
| bool | incrementS (long int) |
| bool | incrementTemp (long int dif) |
| long int | getInt () |
| long int | getTens () |
| long int | getTens_raw () |
| float | getFloat () |
| char * | getString () |
| long int | getSingleInt () |
| short | getPercents (bool inverse=false) |
| short | getPercents255 (bool inverse=false) |
| bool | setPercents (int percents) |
| uint8_t | getCmd () |
| uint8_t | getArgType () |
| uint8_t | getCmdParam () |
| char * | toString (char *Buffer, int bufLen, int sendFlags=FLAG_COMMAND|FLAG_PARAMETERS, bool scale100=false) |
| bool | isCommand () |
| bool | isChannelCommand () |
| bool | isValue () |
| bool | isColor () |
| itemCmd | setDefault () |
| itemCmd | setChanType (short chanType) |
| void | debugOut () |
| itemCmd | doMapping (aJsonObject *mappingData) |
| itemCmd | doReverseMapping (aJsonObject *mappingData) |
| bool | scale100 () |
Public Attributes | |
| itemCmdStore | cmd |
| Packed command word: code, storage type, suffix. | |
| itemArgStore | param |
| Packed parameter: number / float / string / color. | |
Command + value container passed between items, drivers and MQTT.
itemCmd packs a command code (CMD_*), a typed value (ST_* storage) and a topic suffix (S_*) into two 32-bit words (itemCmdStore + itemArgStore). It is the universal currency of the control core: parsed from text or JSON, converted to the channel's storage type, executed by the driver and serialized back to text for status publishing.
Constructor with definition of type and command.
Create a command of the given code with an empty parameter of the given storage type.
| type | - type of value (ST_???, ST_VOID by default) |
| code | - code of command (CMD_VOID by default) |
| itemCmd::itemCmd | ( | float | val | ) |
Constructor with definition of FLOAT value in storage.
Create a value with ST_FLOAT storage.
| float | |
| type | - type of value (ST_FLOAT or ST_FLOAT_CELSIUS or ST_FLOAT_FARENHEIT) - optional |
| itemCmd::itemCmd | ( | Item * | item | ) |
Constructor with loading value from Item.
Create a copy of the currently stored command/value of the item.
| Item |
| itemCmd::itemCmd | ( | char * | _cmd | ) |
Parse a text command/value ("ON", "50", "-1.5", "#FF0000", "HSV:100,50,255").
\brief Constructor with textual definition of command \param cmd - name of cmd
todo - extend to values
Convert the value of from to the storage type appropriate for chanType and copy it to *this.
| itemCmd itemCmd::Cmd | ( | uint8_t | i | ) |
Set the command code (and S_CMD suffix).
| itemCmd itemCmd::convertTo | ( | uint8_t | type | ) |
Convert the stored value to the given storage type (ST_*).
| void itemCmd::debugOut | ( | ) |
Dump the command to the debug serial.
| itemCmd itemCmd::doMapping | ( | aJsonObject * | mappingData | ) |
Map the unified command/value to a device-specific value via mappingData.
| itemCmd itemCmd::doReverseMapping | ( | aJsonObject * | mappingData | ) |
Map a device-specific value back to the unified representation.
| itemCmd itemCmd::Float | ( | float | f | ) |
Set the parameter to a float (ST_FLOAT).
| uint8_t itemCmd::getArgType | ( | ) |
| uint8_t itemCmd::getCmd | ( | ) |
| uint8_t itemCmd::getCmdParam | ( | ) |
| int itemCmd::getColorTemp | ( | ) |
Return color tempetature parameter from HSV or HSV255 types. return 153..500 value in success. -1 - if no value stored
| float itemCmd::getFloat | ( | ) |
| uint16_t itemCmd::getH | ( | ) |
| long int itemCmd::getInt | ( | ) |
| short itemCmd::getPercents | ( | bool | inverse = false | ) |
| short itemCmd::getPercents255 | ( | bool | inverse = false | ) |
| uint16_t itemCmd::getS | ( | ) |
| long int itemCmd::getSingleInt | ( | ) |
| uint8_t itemCmd::getStoragetypeByChanType | ( | short | chanType | ) |
| char * itemCmd::getString | ( | ) |
| uint8_t itemCmd::getSuffix | ( | ) |
| long int itemCmd::getTens | ( | ) |
| long int itemCmd::getTens_raw | ( | ) |
| itemCmd itemCmd::HS | ( | uint16_t | h, |
| uint8_t | s ) |
Set hue and saturation only (ST_HS).
| itemCmd itemCmd::HSV | ( | uint16_t | h, |
| uint8_t | s, | ||
| uint8_t | v ) |
Set an HSV255 color (hue 0..365, sat 0..100, value 0..255).
| itemCmd itemCmd::HSV255 | ( | uint16_t | h, |
| uint8_t | s, | ||
| uint8_t | v ) |
Set an HSV255 color (ST_HSV255 storage).
| bool itemCmd::incrementH | ( | long int | dif | ) |
Increase/decrease the hue by step (with wrap-around).
| bool itemCmd::incrementPercents | ( | long int | dif, |
| long int | limit ) |
Increase/decrease a percent/int/float value by step, clamped to [0, limit].
| bool itemCmd::incrementS | ( | long int | dif | ) |
Increase/decrease the saturation by step.
| bool itemCmd::incrementTemp | ( | long int | dif | ) |
Increase/decrease the temperature by step.
| itemCmd itemCmd::Int | ( | int32_t | i | ) |
Set the parameter to a signed 32-bit int (ST_INT32).
| bool itemCmd::isChannelCommand | ( | ) |
| bool itemCmd::isColor | ( | ) |
| bool itemCmd::isCommand | ( | ) |
| bool itemCmd::isValue | ( | ) |
| bool itemCmd::loadItem | ( | Item * | item, |
| uint16_t | optionsFlag = FLAG_PARAMETERS ) |
Load the stored command/value of the item into *this according to optionsFlag.
| bool itemCmd::loadItemDef | ( | Item * | item, |
| uint16_t | optionsFlag = FLAG_PARAMETERS ) |
Like loadItem(), but falls back to channel defaults for a never-controlled item.
| itemCmd itemCmd::Percents | ( | int | i | ) |
Set the parameter to a percent value 0..100 (ST_PERCENTS255 storage).
| itemCmd itemCmd::Percents255 | ( | int | i | ) |
Set the parameter to a percent value 0..255 (ST_PERCENTS255 storage).
| itemCmd itemCmd::RGB | ( | uint8_t | r, |
| uint8_t | g, | ||
| uint8_t | b ) |
Set an RGB color (ST_RGB).
| itemCmd itemCmd::RGBW | ( | uint8_t | r, |
| uint8_t | g, | ||
| uint8_t | b, | ||
| uint8_t | w ) |
Set an RGBW color (ST_RGBW).
| bool itemCmd::saveItem | ( | Item * | item, |
| uint16_t | optionsFlag = FLAG_PARAMETERS ) |
Write *this back to the item storage (command, value, flags) according to optionsFlag.
| bool itemCmd::scale100 | ( | ) |
Scale a 0..255 value to 0..100 in place.
| itemCmd itemCmd::setArgType | ( | uint8_t | type | ) |
Change the parameter storage type (ST_*).
| itemCmd itemCmd::setChanType | ( | short | chanType | ) |
Set the storage type appropriate for the given channel type.
| bool itemCmd::setColorTemp | ( | int | t | ) |
Set the color temperature in mireds (153..500).
Setup color tempetature parameter for HSV or HSV255 types. It must be 153..500 (mireds) value. Internally 1 - cold, 101 - warm light
| itemCmd itemCmd::setDefault | ( | ) |
Set the value to the channel default for the current storage type.
| bool itemCmd::setH | ( | uint16_t | h | ) |
Set the hue component (0..365).
| bool itemCmd::setPercents | ( | int | percents | ) |
Set the value from a percent 0..100.
| bool itemCmd::setS | ( | uint8_t | s | ) |
Set the saturation component (0..100).
| itemCmd itemCmd::setSuffix | ( | uint8_t | suffix | ) |
Set the topic suffix code (S_*).
| itemCmd itemCmd::Str | ( | char * | str | ) |
Set the parameter to a string pointer (ST_STRING).
| itemCmd itemCmd::Tens | ( | int32_t | i | ) |
Set the parameter to a fixed-point value in tens (ST_TENS, scaled by TENS_BASE).
| itemCmd itemCmd::Tens_raw | ( | int32_t | i | ) |
Set the parameter to a raw fixed-point value in tens (ST_TENS, pre-scaled).
| char * itemCmd::toString | ( | char * | Buffer, |
| int | bufLen, | ||
| int | sendFlags = FLAG_COMMAND | FLAG_PARAMETERS, | ||
| bool | scale100 = false ) |
Serialize the command and/or value to a text payload for MQTT.
| sendFlags | - FLAG_COMMAND and/or FLAG_PARAMETERS select what to print |
| scale100 | - scale 0..255 values to 0..100 |
| itemCmd itemCmd::uInt | ( | uint32_t | i | ) |
Set the parameter to an unsigned 32-bit int (ST_UINT32).
| itemCmdStore itemCmd::cmd |
Packed command word: code, storage type, suffix.
| itemArgStore itemCmd::param |
Packed parameter: number / float / string / color.