Home IO Control
ESPHome add-on for IO-Homecontrol devices
Toggle main menu visibility
Loading...
Searching...
No Matches
platform_oneway_entities.cpp
Go to the documentation of this file.
1
/// @file platform_oneway_entities.cpp
2
/// @brief The per-identity 1W entities: command buttons, enrollment button, last-command sensor.
3
/// @ingroup hioc_platforms
4
5
#include "
platform_oneway_entities.h
"
6
7
#include "esphome/core/log.h"
8
9
namespace
esphome
{
10
namespace
home_io_control
{
11
12
std::string
format_oneway_command_report
(
const
OneWayCommandReport
&report) {
13
// "not sent" rather than "failed": the hub knows only that nothing left the radio. It never
14
// knows that a command failed, because it never learns that one succeeded either.
15
if
(!report.
sequence_reserved
)
16
return
"not sent (no sequence reserved)"
;
17
18
std::string summary = report.
intent
.empty() ?
"command"
: report.
intent
;
19
summary +=
" -> "
;
20
summary +=
device_type_name
(report.
target_type
);
21
summary +=
" seq "
;
22
summary += std::to_string(report.
sequence
);
23
if
(!report.
transmitted
)
24
summary +=
" (not sent)"
;
25
return
summary;
26
}
27
28
void
IOHomeOneWayCommandButton::dump_config
() {
29
ESP_LOGCONFIG(
"home_io_control.button"
,
"IO-Homecontrol 1W Command Button"
);
30
ESP_LOGCONFIG(
"home_io_control.button"
,
" Controller: %s"
, this->
controller_id_
.c_str());
31
ESP_LOGCONFIG(
"home_io_control.button"
,
" Action: %s"
,
oneway_button_action_name
(this->
action_
));
32
}
33
34
void
IOHomeOneWayEnrollButton::dump_config
() {
35
ESP_LOGCONFIG(
"home_io_control.button"
,
"IO-Homecontrol 1W Enroll Button"
);
36
ESP_LOGCONFIG(
"home_io_control.button"
,
" Controller: %s"
, this->
controller_id_
.c_str());
37
}
38
39
void
IOHomeOneWayLastCommandTextSensor::setup
() {
40
if
(this->
parent_
==
nullptr
)
41
return
;
42
this->
parent_
->
add_oneway_command_report_callback
([
this
](
const
OneWayCommandReport
&report) {
43
// Every sensor sees every report; each keeps only its own identity's. Filtering here rather
44
// than at the hub keeps the hub from having to know which sensors exist.
45
if
(report.
controller_id
!= this->controller_id_)
46
return
;
47
this->publish_state(
format_oneway_command_report
(report));
48
});
49
}
50
51
void
IOHomeOneWayLastCommandTextSensor::dump_config
() {
52
ESP_LOGCONFIG(
"home_io_control.text_sensor"
,
"IO-Homecontrol Last 1W Command Sensor"
);
53
ESP_LOGCONFIG(
"home_io_control.text_sensor"
,
" Controller: %s"
, this->
controller_id_
.c_str());
54
}
55
56
}
// namespace home_io_control
57
}
// namespace esphome
esphome::home_io_control::HubBoundEntity::parent_
IOHomeControlComponent * parent_
Definition
platform_entity_base.h:201
esphome::home_io_control::IOHomeControlComponent::add_oneway_command_report_callback
void add_oneway_command_report_callback(OneWayCommandReportFn callback)
Subscribe to the report emitted after every 1W command attempt.
Definition
hub_core.h:384
esphome::home_io_control::IOHomeOneWayCommandButton::action_
OneWayButtonAction action_
Definition
platform_oneway_entities.h:59
esphome::home_io_control::IOHomeOneWayCommandButton::dump_config
void dump_config() override
Definition
platform_oneway_entities.cpp:28
esphome::home_io_control::IOHomeOneWayEnrollButton::dump_config
void dump_config() override
Definition
platform_oneway_entities.cpp:34
esphome::home_io_control::IOHomeOneWayLastCommandTextSensor::setup
void setup() override
Subscribe to the hub's per-command reports.
Definition
platform_oneway_entities.cpp:39
esphome::home_io_control::IOHomeOneWayLastCommandTextSensor::dump_config
void dump_config() override
Dump text-sensor configuration to the log.
Definition
platform_oneway_entities.cpp:51
esphome::home_io_control::OneWayControllerBound::controller_id_
std::string controller_id_
Definition
platform_entity_base.h:218
esphome::home_io_control::oneway_button_action_name
const char * oneway_button_action_name(OneWayButtonAction action)
Human-readable name for a button action, as it appears in the diagnostic sensor.
Definition
oneway_controller.cpp:22
esphome::home_io_control
Definition
device_registry.cpp:13
esphome::home_io_control::device_type_name
const char * device_type_name(DeviceType type)
Convert a DeviceType to a lowercase string identifier.
Definition
proto_device_model.cpp:113
esphome::home_io_control::format_oneway_command_report
std::string format_oneway_command_report(const OneWayCommandReport &report)
Build the sensor string for one command report.
Definition
platform_oneway_entities.cpp:12
esphome
Definition
device_registry.cpp:12
platform_oneway_entities.h
The per-identity 1W entities: command buttons, the enrollment button, and the "Last 1W Command" diagn...
esphome::home_io_control::OneWayCommandReport
What a 1W command attempt did — the only feedback this feature can ever produce.
Definition
oneway_transmitter.h:44
esphome::home_io_control::OneWayCommandReport::intent
std::string intent
Decoded intent, e.g. "STOP" or "CLOSE".
Definition
oneway_transmitter.h:46
esphome::home_io_control::OneWayCommandReport::sequence_reserved
bool sequence_reserved
True if a sequence was consumed (0 is a valid sequence).
Definition
oneway_transmitter.h:49
esphome::home_io_control::OneWayCommandReport::target_type
DeviceType target_type
Device class addressed.
Definition
oneway_transmitter.h:47
esphome::home_io_control::OneWayCommandReport::transmitted
bool transmitted
True if at least one copy reached the radio.
Definition
oneway_transmitter.h:50
esphome::home_io_control::OneWayCommandReport::controller_id
std::string controller_id
Identity that transmitted (empty if unresolved).
Definition
oneway_transmitter.h:45
esphome::home_io_control::OneWayCommandReport::sequence
uint16_t sequence
Sequence consumed; meaningless unless sequence_reserved.
Definition
oneway_transmitter.h:48
components
home_io_control
platform_oneway_entities.cpp
Generated by
1.18.0