Home IO Control
ESPHome add-on for IO-Homecontrol devices
Toggle main menu visibility
Loading...
Searching...
No Matches
pairing_advisor.h
Go to the documentation of this file.
1
#pragma once
2
3
/// @file pairing_advisor.h
4
/// @brief Read-only advisor that turns PairingTelemetry into actionable diagnostics.
5
/// @ingroup hioc_hub
6
///
7
/// PairingAdvisor is a pure, stateless consumer of a completed PairingTelemetry attempt: it
8
/// never touches the radio or the pairing state machine, only inspects the events already
9
/// recorded. It exists to convert the most common field failures (a 1W remote's PROG gesture
10
/// overheard while no device answers, issues #27/#121; a busy channel; a foreign controller
11
/// mid-pairing; dead RF)
12
/// from a hex-dump exercise into a self-explaining WARN line.
13
14
#include "
pairing_telemetry.h
"
15
#include "
proto_frame.h
"
16
17
#include <cstdint>
18
#include <string>
19
20
namespace
esphome
{
21
namespace
home_io_control
{
22
namespace
advisor
{
23
24
/// @brief Actionable diagnosis derived from a completed pairing attempt's telemetry.
25
enum class
PairingAdviceCode
: uint8_t {
26
NONE,
///< Nothing actionable to report.
27
ONE_WAY_PAIRING_TRAFFIC
,
///< A 1W remote's PROG gesture was overheard. Proves a gesture happened,
28
///< not the device's state: the same frames also precede successful
29
///< pairings (issue #19).
30
CHANNEL_BUSY_LBT_DELAYED
,
///< LBT retries were consumed while a source kept repeating; the
31
///< reported subject_node is a best-effort correlation (LBT's
32
///< carrier-sense doesn't parse frames, so the actual jammer may
33
///< not be among the parsed events attributed here).
34
FOREIGN_CONTROLLER_PAIRING
,
///< A discovery response was seen addressed to another controller.
35
RF_SILENT
,
///< Nothing at all was heard during the whole window.
36
KEY_PUSH_NOT_ACCEPTED
,
///< The device does not take a pushed key: it answered 0x32 with
37
///< RESULT_COMMAND_UNKNOWN, or it answered discovery as a remote
38
///< controller and the push failed. Suggests `pairing_key_transfer: pull` or `auto`.
39
KEY_TRANSFER_REFUSED
,
///< The device answered the key transfer with any other CMD_ERROR_RESP.
40
KEY_PULL_NOT_OFFERED
,
///< `pairing_key_transfer: pull` was refused with CMD_ERROR_RESP: the
41
///< device does not hand out its key. Suggests forcing `pairing_key_transfer: push`.
42
KEY_PULL_UNPROVEN
,
///< The device answered the pull with a key, but sent no 0x3D that
43
///< verifies under it; the key is not printed.
44
PULLED_KEY_RECEIVED
,
///< The pull got a different key that the device proved, and a roll-call
45
///< under it found no registrable device (outcome KEY_RECEIVED). Says to
46
///< put the key into the controlling entity's `system_key:`.
47
HUB_KEY_NO_RESPONDER
,
///< The pull returned the hub's own key from a node no platform drives, and no
48
///< device that holds it answered (outcome HUB_KEY_RETURNED). Says to run Scan
49
///< Paired Devices.
50
};
51
52
/// @brief One piece of advice, with the node/RSSI it pertains to (if any).
53
struct
PairingAdvice
{
54
PairingAdviceCode
code
{
PairingAdviceCode::NONE
};
55
uint8_t
subject_node
[NODE_ID_SIZE]{};
///< Node the advice is about; zero if not applicable.
56
int16_t
rssi
{0};
///< RSSI associated with the observation; zero if not applicable.
57
bool
has_result_code
{
false
};
///< True when result_code carries the device's CMD_ERROR_RESP byte.
58
uint8_t
result_code
{0};
///< CMD_ERROR_RESP byte the advice is about.
59
bool
answered_as_controller
{
false
};
///< True when the device answered discovery as a remote controller.
60
};
61
62
/// @brief Maximum number of advice entries a single attempt can produce (each advice source adds at most one).
63
static
constexpr
uint8_t
PAIRING_ADVICE_MAX
= 6;
64
65
/// @brief Inspect a completed pairing attempt's telemetry and produce actionable advice.
66
///
67
/// Read-only: never mutates telemetry, never touches the radio or pairing state machine.
68
/// @param telemetry Completed (or in-progress) telemetry for one pairing attempt.
69
/// @param own_node_id This controller's node ID, used to detect discovery responses addressed
70
/// to a different controller.
71
/// @param out Output buffer, must hold at least PAIRING_ADVICE_MAX entries.
72
/// @return Number of advice entries written to `out` (0 if nothing actionable was found).
73
uint8_t
analyze_pairing_telemetry
(
const
PairingTelemetry
&telemetry,
const
uint8_t own_node_id[NODE_ID_SIZE],
74
PairingAdvice
out[PAIRING_ADVICE_MAX]);
75
76
/// @return Short, stable code string for the `;advice=` result-sensor field (e.g. "1w_traffic").
77
const
char
*
pairing_advice_code_name
(
PairingAdviceCode
code);
78
79
/// @return The full actionable, human-readable WARN message for one piece of advice.
80
std::string
pairing_advice_message
(
const
PairingAdvice
&advice);
81
82
}
// namespace advisor
83
}
// namespace home_io_control
84
}
// namespace esphome
esphome::home_io_control::PairingTelemetry
Fixed-size per-attempt telemetry recorder for the pairing flow.
Definition
pairing_telemetry.h:99
esphome::home_io_control::advisor
Definition
pairing_advisor.cpp:16
esphome::home_io_control::advisor::pairing_advice_message
std::string pairing_advice_message(const PairingAdvice &advice)
Definition
pairing_advisor.cpp:217
esphome::home_io_control::advisor::PAIRING_ADVICE_MAX
static constexpr uint8_t PAIRING_ADVICE_MAX
Maximum number of advice entries a single attempt can produce (each advice source adds at most one).
Definition
pairing_advisor.h:63
esphome::home_io_control::advisor::pairing_advice_code_name
const char * pairing_advice_code_name(PairingAdviceCode code)
Definition
pairing_advisor.cpp:189
esphome::home_io_control::advisor::PairingAdviceCode
PairingAdviceCode
Actionable diagnosis derived from a completed pairing attempt's telemetry.
Definition
pairing_advisor.h:25
esphome::home_io_control::advisor::PairingAdviceCode::PULLED_KEY_RECEIVED
@ PULLED_KEY_RECEIVED
The pull got a different key that the device proved, and a roll-call under it found no registrable de...
Definition
pairing_advisor.h:44
esphome::home_io_control::advisor::PairingAdviceCode::RF_SILENT
@ RF_SILENT
Nothing at all was heard during the whole window.
Definition
pairing_advisor.h:35
esphome::home_io_control::advisor::PairingAdviceCode::KEY_PULL_NOT_OFFERED
@ KEY_PULL_NOT_OFFERED
pairing_key_transfer: pull was refused with CMD_ERROR_RESP: the device does not hand out its key.
Definition
pairing_advisor.h:40
esphome::home_io_control::advisor::PairingAdviceCode::KEY_PULL_UNPROVEN
@ KEY_PULL_UNPROVEN
The device answered the pull with a key, but sent no 0x3D that verifies under it; the key is not prin...
Definition
pairing_advisor.h:42
esphome::home_io_control::advisor::PairingAdviceCode::KEY_PUSH_NOT_ACCEPTED
@ KEY_PUSH_NOT_ACCEPTED
The device does not take a pushed key: it answered 0x32 with RESULT_COMMAND_UNKNOWN,...
Definition
pairing_advisor.h:36
esphome::home_io_control::advisor::PairingAdviceCode::NONE
@ NONE
Nothing actionable to report.
Definition
pairing_advisor.h:26
esphome::home_io_control::advisor::PairingAdviceCode::KEY_TRANSFER_REFUSED
@ KEY_TRANSFER_REFUSED
The device answered the key transfer with any other CMD_ERROR_RESP.
Definition
pairing_advisor.h:39
esphome::home_io_control::advisor::PairingAdviceCode::FOREIGN_CONTROLLER_PAIRING
@ FOREIGN_CONTROLLER_PAIRING
A discovery response was seen addressed to another controller.
Definition
pairing_advisor.h:34
esphome::home_io_control::advisor::PairingAdviceCode::ONE_WAY_PAIRING_TRAFFIC
@ ONE_WAY_PAIRING_TRAFFIC
A 1W remote's PROG gesture was overheard.
Definition
pairing_advisor.h:27
esphome::home_io_control::advisor::PairingAdviceCode::HUB_KEY_NO_RESPONDER
@ HUB_KEY_NO_RESPONDER
The pull returned the hub's own key from a node no platform drives, and no device that holds it answe...
Definition
pairing_advisor.h:47
esphome::home_io_control::advisor::PairingAdviceCode::CHANNEL_BUSY_LBT_DELAYED
@ CHANNEL_BUSY_LBT_DELAYED
LBT retries were consumed while a source kept repeating; the reported subject_node is a best-effort c...
Definition
pairing_advisor.h:30
esphome::home_io_control::advisor::analyze_pairing_telemetry
uint8_t analyze_pairing_telemetry(const PairingTelemetry &telemetry, const uint8_t own_node_id[NODE_ID_SIZE], PairingAdvice out[PAIRING_ADVICE_MAX])
Inspect a completed pairing attempt's telemetry and produce actionable advice.
Definition
pairing_advisor.cpp:171
esphome::home_io_control
Definition
device_registry.cpp:15
esphome
Definition
device_registry.cpp:14
pairing_telemetry.h
Structured per-attempt telemetry recorder for the pairing flow.
proto_frame.h
IO-Homecontrol 2W frame container: control bytes, IoFrame and (de)serialization.
esphome::home_io_control::advisor::PairingAdvice
One piece of advice, with the node/RSSI it pertains to (if any).
Definition
pairing_advisor.h:53
esphome::home_io_control::advisor::PairingAdvice::subject_node
uint8_t subject_node[NODE_ID_SIZE]
Node the advice is about; zero if not applicable.
Definition
pairing_advisor.h:55
esphome::home_io_control::advisor::PairingAdvice::has_result_code
bool has_result_code
True when result_code carries the device's CMD_ERROR_RESP byte.
Definition
pairing_advisor.h:57
esphome::home_io_control::advisor::PairingAdvice::answered_as_controller
bool answered_as_controller
True when the device answered discovery as a remote controller.
Definition
pairing_advisor.h:59
esphome::home_io_control::advisor::PairingAdvice::result_code
uint8_t result_code
CMD_ERROR_RESP byte the advice is about.
Definition
pairing_advisor.h:58
esphome::home_io_control::advisor::PairingAdvice::code
PairingAdviceCode code
Definition
pairing_advisor.h:54
esphome::home_io_control::advisor::PairingAdvice::rssi
int16_t rssi
RSSI associated with the observation; zero if not applicable.
Definition
pairing_advisor.h:56
components
home_io_control
pairing_advisor.h
Generated by
1.18.0