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

Auto-summing (virtual) counter driver, channel type CH_COUNTER = 20. More...

#include <out_counter.h>

Inheritance diagram for out_counter:

Public Member Functions

int Setup () override
 Initializes the channel state (CST_INITIALIZED); no hardware.
int Poll (short cause) override
 When the tick period expires, adds impulse_coef to the stored value and sends the status.
int Stop () override
 Marks the channel as unknown.
int getChanType () override
 Returns CH_COUNTER (20).
int Ctrl (itemCmd cmd, char *subItem=NULL, bool toExecute=true, bool authorized=false) override
 Starts/stops accumulation via /set (non-zero value) and /cmd on/off (see class doc).
Public Member Functions inherited from abstractOut
 abstractOut ()
virtual void link (Item *_item)
virtual int isActive ()
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 ()

Additional Inherited Members

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 inherited from abstractOut
Item * item
 Item currently linked to this driver.

Detailed Description

Auto-summing (virtual) counter driver, channel type CH_COUNTER = 20.

No GPIO involved: every configured period the driver adds a fixed impulse value to the stored channel value (software "tick" generator).

JSON config (itemArg): [impulse_coef, period_sec]

  • impulse_coef: value added to the counter on each tick (may be fractional);
  • period_sec: period between ticks in seconds.

Ctrl:

  • /set - a non-zero value starts accumulation, zero stops it;
  • /cmd - on-like commands (on/heat/cool/auto/fan/dry/heatcool) start, off stops.

Status: the accumulated counter value, republished after every tick.

Member Function Documentation

◆ Ctrl()

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

Starts/stops accumulation via /set (non-zero value) and /cmd on/off (see class doc).

Implements abstractOut.

◆ getChanType()

int out_counter::getChanType ( )
overridevirtual

Returns CH_COUNTER (20).

Reimplemented from abstractOut.

◆ Poll()

int out_counter::Poll ( short cause)
overridevirtual

When the tick period expires, adds impulse_coef to the stored value and sends the status.

Reimplemented from abstractCh.

◆ Setup()

int out_counter::Setup ( )
overridevirtual

Initializes the channel state (CST_INITIALIZED); no hardware.

Reimplemented from abstractOut.

◆ Stop()

int out_counter::Stop ( )
overridevirtual

Marks the channel as unknown.

Reimplemented from abstractCh.


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