LightHub 4.6.0
Open-source smart home controller firmware
Loading...
Searching...
No Matches
out_relay.h
Go to the documentation of this file.
1
2#pragma once
3#include "options.h"
4#ifndef RELAY_DISABLE
5
6#include <abstractout.h>
7#include <item.h>
8
27class out_relay : public abstractOut {
28public:
30 void link(Item * _item){abstractOut::link(_item); if (_item) getConfig();};
32 void getConfig();
34 void relay(bool state);
36 int Setup() override;
38 int Poll(short cause) override;
40 int Stop() override;
41
43 int getChanType() override;
45 int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true, bool authorized = false) override;
46
47protected:
48 short pin;
50 uint32_t period;
51};
52#endif
A single LightHub item (virtual channel).
Definition item.h:232
abstractOut()
Definition abstractout.h:22
virtual void link(Item *_item)
Definition abstractout.h:24
Command + value container passed between items, drivers and MQTT.
Definition itemCmd.h:306
Relay (ON/OFF output) driver (CH_RELAY = 6 / CH_RELAYX = 16).
Definition out_relay.h:27
void link(Item *_item)
Attach to an item and read its pin/period configuration.
Definition out_relay.h:30
int Setup() override
Initialize the pin (OUTPUT, inactive) and remember the state if the item is active.
Definition out_relay.cpp:34
bool inverted
Definition out_relay.h:49
uint32_t period
Definition out_relay.h:50
int Ctrl(itemCmd cmd, char *subItem=NULL, bool toExecute=true, bool authorized=false) override
Handle /set (duration/turn-on) and /cmd (ON/OFF/TOGGLE/XON/XOFF/HALT/REST) commands.
Definition out_relay.cpp:104
short pin
Definition out_relay.h:48
int getChanType() override
Channel type of the driver.
Definition out_relay.cpp:186
int Poll(short cause) override
For CH_RELAYX: toggle the relay on/off according to the configured period and /set value.
Definition out_relay.cpp:72
void getConfig()
Read pin and pulse period from the item arguments (negative pin = inverted).
Definition out_relay.cpp:12
void relay(bool state)
Physically switch the relay and publish the new action state.
Definition out_relay.cpp:61
int Stop() override
Release the pin and mark the driver uninitialized.
Definition out_relay.cpp:53
Item (virtual channel) system of LightHub.