ESPHome
2024.11.0
esphome
esphome
components
pipsolar
switch
pipsolar_switch.cpp
Go to the documentation of this file.
1
#include "
pipsolar_switch.h
"
2
#include "
esphome/core/log.h
"
3
#include "
esphome/core/application.h
"
4
5
namespace
esphome
{
6
namespace
pipsolar {
7
8
static
const
char
*
const
TAG =
"pipsolar.switch"
;
9
10
void
PipsolarSwitch::dump_config
() { LOG_SWITCH(
""
,
"Pipsolar Switch"
,
this
); }
11
void
PipsolarSwitch::write_state
(
bool
state
) {
12
if
(state) {
13
if
(this->
on_command_
.length() > 0) {
14
this->
parent_
->switch_command(this->
on_command_
);
15
}
16
}
else
{
17
if
(this->
off_command_
.length() > 0) {
18
this->
parent_
->switch_command(this->
off_command_
);
19
}
20
}
21
}
22
23
}
// namespace pipsolar
24
}
// namespace esphome
pipsolar_switch.h
application.h
esphome::pipsolar::PipsolarSwitch::on_command_
std::string on_command_
Definition:
pipsolar_switch.h:19
esphome::pipsolar::PipsolarSwitch::dump_config
void dump_config() override
Definition:
pipsolar_switch.cpp:10
esphome::pipsolar::PipsolarSwitch::off_command_
std::string off_command_
Definition:
pipsolar_switch.h:20
esphome
Implementation of SPI Controller mode.
Definition:
a01nyub.cpp:7
esphome::pipsolar::PipsolarSwitch::write_state
void write_state(bool state) override
Definition:
pipsolar_switch.cpp:11
log.h
esphome::switch_::Switch::state
bool state
The current reported state of the binary sensor.
Definition:
switch.h:53
esphome::pipsolar::PipsolarSwitch::parent_
Pipsolar * parent_
Definition:
pipsolar_switch.h:21
Generated by
1.8.13