Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
home_io_control.platform_common Namespace Reference

Functions

 _companion_sensor_name (config, suffix)
 companion_id_base (config, parent_id_key)
 inject_companion_sensor_ids (config, parent_id_key)
 validate_entity_name (value)
 platform_schema_extension ()
 wire_device_binding (var, parent, config)
 _create_companion_text_sensor (config, parent, sensor_id, name, disabled_by_default)
 _create_link_health_sensor (config, parent, sensor_id, name, **sensor_kwargs)
 create_companion_sensors (config, parent)

Variables

str CONF_IO_DEVICE_ID = "io_device_id"
str CONF_LINKED_REMOTES = "linked_remotes"
str CONF_DEVICE_TYPE = "io_device_type"
str CONF_SUBTYPE = "io_subtype"
str CONF_STATUS_POLL_INTERVAL = "status_poll_interval"
str CONF_LOW_POWER = "low_power"
str CONF_DEVICE_NAME_SENSOR_ID = "_device_name_sensor_id"
str CONF_ACTIVE_ISSUE_SENSOR_ID = "_active_issue_sensor_id"
str CONF_RSSI_SENSOR_ID = "_rssi_sensor_id"
str CONF_LAST_CONTACT_SENSOR_ID = "_last_contact_sensor_id"
str CONF_EXCHANGE_FAILURES_SENSOR_ID = "_exchange_failures_sensor_id"
str CONF_LAST_COMMANDED_BY_SENSOR_ID = "_last_commanded_by_sensor_id"
str CONF_LAST_COMMAND_SOURCE_SENSOR_ID = "_last_command_source_sensor_id"
 IOHomeDeviceNameTextSensor
 IOHomeActiveIssueTextSensor
 IOHomeRssiSensor = home_io_control_ns.class_("IOHomeRssiSensor", sensor.Sensor, cg.Component)
 IOHomeLastContactSensor
 IOHomeExchangeFailuresSensor
 IOHomeLastCommandedByTextSensor
 IOHomeLastCommandSourceTextSensor
tuple _COMPANION_SENSOR_IDS

Function Documentation

◆ _companion_sensor_name()

home_io_control.platform_common._companion_sensor_name ( config,
suffix )
protected
Derive a companion sensor's entity name from the parent entity name.

Definition at line 104 of file platform_common.py.

◆ _create_companion_text_sensor()

home_io_control.platform_common._create_companion_text_sensor ( config,
parent,
sensor_id,
name,
disabled_by_default )
protected
Shared body for the auto-generated companion `text_sensor:` entities.

Definition at line 250 of file platform_common.py.

◆ _create_link_health_sensor()

home_io_control.platform_common._create_link_health_sensor ( config,
parent,
sensor_id,
name,
** sensor_kwargs )
protected
Shared body for the three auto-generated link-health `sensor:` companions.

All three (RSSI, Last Contact, Exchange Failures) are numeric, diagnostic, and disabled by
default (noise control); only the name and sensor-specific schema keys
(unit/device_class/state_class/accuracy_decimals) differ between them, so those are the
only things each call in create_companion_sensors() supplies.

Definition at line 267 of file platform_common.py.

◆ companion_id_base()

home_io_control.platform_common.companion_id_base ( config,
parent_id_key )
Return the shared ID prefix for a platform's companion entity IDs.

ESPHome 2026.x sizes its runtime component vector (StaticVector) from the number of
component IDs known at the end of schema validation — before to_code() runs.  If
companion entities are only created inside to_code(), their IDs are not counted and
the StaticVector overflows at runtime, silently dropping later components whose
setup() then never executes.  Companion IDs must therefore be declared during
validation, and they all share the prefix returned here.

``parent_id_key`` differs per platform: light reads the entity ID from
CONF_OUTPUT_ID, while cover, switch and lock read it from CONF_ID. Falls back to the
entity's CONF_ID (the sibling LightState, for light) when parent_id_key's own field wasn't
manually set, then to a sanitized form of the entity name. Raises cv.Invalid when neither an
explicit id: nor a non-empty name: is available to derive a unique prefix from — reachable via
the `name: ""`/`name: None` device-name idiom (see validate_entity_name()) without an id:.

Definition at line 112 of file platform_common.py.

◆ create_companion_sensors()

home_io_control.platform_common.create_companion_sensors ( config,
parent )
Create and register every auto-generated companion diagnostic sensor.

Single to_code() entry point for the device-bound platforms (the counterpart of
inject_companion_sensor_ids()), so adding a companion touches this module only:

- Device Name: disabled by default (clutter control).
- Active Issue: the one enabled-by-default companion — it is the headline diagnostic
  value that turns a silently-ignored command into a self-explained one (e.g. a
  wind/rain lockout), so users should see it without an opt-in step. Empty except while
  a CMD_ERROR_RESP reason is outstanding; see IOHomeActiveIssueTextSensor.
- RSSI / Last Contact / Exchange Failures: numeric link-health diagnostics, disabled by
  default (noise control). Last Contact publishes seconds since the last frame from the
  device (an age, not a Home Assistant timestamp) and keeps counting up between frames via
  its own heartbeat; see IOHomeLastContactSensor.
- Last Commanded By / Last Command Source: who/what last commanded the device, disabled by
  default (noise control). Free — decoded from bytes already present in every status reply,
  no extra radio traffic; see IOHomeLastCommandedByTextSensor.

Definition at line 299 of file platform_common.py.

Here is the call graph for this function:

◆ inject_companion_sensor_ids()

home_io_control.platform_common.inject_companion_sensor_ids ( config,
parent_id_key )
Declare every auto-generated companion sensor ID during schema validation.

Shared post-validator body for every device-bound platform, covering all entries in
_COMPANION_SENSOR_IDS. See companion_id_base() for why the IDs must be declared at
validation time rather than in to_code().

Definition at line 162 of file platform_common.py.

Here is the call graph for this function:

◆ platform_schema_extension()

home_io_control.platform_common.platform_schema_extension ( )
Return the shared schema keys every device-bound platform extends with.

Definition at line 198 of file platform_common.py.

◆ validate_entity_name()

home_io_control.platform_common.validate_entity_name ( value)
Validate a device-bound platform's `name:`, keeping it required but honoring ESPHome's
device-name idiom (`name: ""` or the YAML literal `name: None`/`none` — both mean "this
entity displays as just its sub-device's name", see companion_id_base()'s empty-name path).

ENTITY_BASE_SCHEMA's own Optional(CONF_NAME) validator (`esphome.config_validation
._validate_entity_name`) never runs for these platforms — platform_schema_extension()
overrides that key with a Required one — so its None -> "" conversion, its NAME_MAX_LENGTH
check, and its '/' handling all have to be reapplied here. Delegating rather than
reimplementing keeps `name: ""` / `name: None` behaving exactly as they do in every other
ESPHome component, including upstream's own asymmetry: `name: None` additionally requires
`esphome: friendly_name:` to be set (matching Home Assistant's own null-name convention),
while `name: ""` does not.

Definition at line 177 of file platform_common.py.

◆ wire_device_binding()

home_io_control.platform_common.wire_device_binding ( var,
parent,
config )
Emit the shared to_code() wiring that binds an entity to its hub device.

Covers set_parent / set_device_id, the optional device type / subtype / status
poll interval / low-power class, and the linked-remotes registration loop —
identical across all four device-bound platforms.

Definition at line 212 of file platform_common.py.

Variable Documentation

◆ _COMPANION_SENSOR_IDS

tuple home_io_control.platform_common._COMPANION_SENSOR_IDS
protected
Initial value:
1= (
2 (CONF_DEVICE_NAME_SENSOR_ID, "device_name_sensor", IOHomeDeviceNameTextSensor),
3 (CONF_ACTIVE_ISSUE_SENSOR_ID, "active_issue_sensor", IOHomeActiveIssueTextSensor),
4 (CONF_RSSI_SENSOR_ID, "rssi_sensor", IOHomeRssiSensor),
5 (CONF_LAST_CONTACT_SENSOR_ID, "last_contact_sensor", IOHomeLastContactSensor),
6 (CONF_EXCHANGE_FAILURES_SENSOR_ID, "exchange_failures_sensor", IOHomeExchangeFailuresSensor),
7 (CONF_LAST_COMMANDED_BY_SENSOR_ID, "last_commanded_by_sensor", IOHomeLastCommandedByTextSensor),
8 (CONF_LAST_COMMAND_SOURCE_SENSOR_ID, "last_command_source_sensor", IOHomeLastCommandSourceTextSensor),
9)

Definition at line 93 of file platform_common.py.

◆ CONF_ACTIVE_ISSUE_SENSOR_ID

str home_io_control.platform_common.CONF_ACTIVE_ISSUE_SENSOR_ID = "_active_issue_sensor_id"

Definition at line 62 of file platform_common.py.

◆ CONF_DEVICE_NAME_SENSOR_ID

str home_io_control.platform_common.CONF_DEVICE_NAME_SENSOR_ID = "_device_name_sensor_id"

Definition at line 60 of file platform_common.py.

◆ CONF_DEVICE_TYPE

str home_io_control.platform_common.CONF_DEVICE_TYPE = "io_device_type"

Definition at line 54 of file platform_common.py.

◆ CONF_EXCHANGE_FAILURES_SENSOR_ID

str home_io_control.platform_common.CONF_EXCHANGE_FAILURES_SENSOR_ID = "_exchange_failures_sensor_id"

Definition at line 66 of file platform_common.py.

◆ CONF_IO_DEVICE_ID

str home_io_control.platform_common.CONF_IO_DEVICE_ID = "io_device_id"

Definition at line 52 of file platform_common.py.

◆ CONF_LAST_COMMAND_SOURCE_SENSOR_ID

str home_io_control.platform_common.CONF_LAST_COMMAND_SOURCE_SENSOR_ID = "_last_command_source_sensor_id"

Definition at line 69 of file platform_common.py.

◆ CONF_LAST_COMMANDED_BY_SENSOR_ID

str home_io_control.platform_common.CONF_LAST_COMMANDED_BY_SENSOR_ID = "_last_commanded_by_sensor_id"

Definition at line 68 of file platform_common.py.

◆ CONF_LAST_CONTACT_SENSOR_ID

str home_io_control.platform_common.CONF_LAST_CONTACT_SENSOR_ID = "_last_contact_sensor_id"

Definition at line 65 of file platform_common.py.

◆ CONF_LINKED_REMOTES

str home_io_control.platform_common.CONF_LINKED_REMOTES = "linked_remotes"

Definition at line 53 of file platform_common.py.

◆ CONF_LOW_POWER

str home_io_control.platform_common.CONF_LOW_POWER = "low_power"

Definition at line 57 of file platform_common.py.

◆ CONF_RSSI_SENSOR_ID

str home_io_control.platform_common.CONF_RSSI_SENSOR_ID = "_rssi_sensor_id"

Definition at line 64 of file platform_common.py.

◆ CONF_STATUS_POLL_INTERVAL

str home_io_control.platform_common.CONF_STATUS_POLL_INTERVAL = "status_poll_interval"

Definition at line 56 of file platform_common.py.

◆ CONF_SUBTYPE

str home_io_control.platform_common.CONF_SUBTYPE = "io_subtype"

Definition at line 55 of file platform_common.py.

◆ IOHomeActiveIssueTextSensor

home_io_control.platform_common.IOHomeActiveIssueTextSensor
Initial value:
1= home_io_control_ns.class_(
2 "IOHomeActiveIssueTextSensor", text_sensor.TextSensor, cg.Component
3)

Definition at line 74 of file platform_common.py.

◆ IOHomeDeviceNameTextSensor

home_io_control.platform_common.IOHomeDeviceNameTextSensor
Initial value:
1= home_io_control_ns.class_(
2 "IOHomeDeviceNameTextSensor", text_sensor.TextSensor, cg.Component
3)

Definition at line 71 of file platform_common.py.

◆ IOHomeExchangeFailuresSensor

home_io_control.platform_common.IOHomeExchangeFailuresSensor
Initial value:
1= home_io_control_ns.class_(
2 "IOHomeExchangeFailuresSensor", sensor.Sensor, cg.Component
3)

Definition at line 81 of file platform_common.py.

◆ IOHomeLastCommandedByTextSensor

home_io_control.platform_common.IOHomeLastCommandedByTextSensor
Initial value:
1= home_io_control_ns.class_(
2 "IOHomeLastCommandedByTextSensor", text_sensor.TextSensor, cg.Component
3)

Definition at line 84 of file platform_common.py.

◆ IOHomeLastCommandSourceTextSensor

home_io_control.platform_common.IOHomeLastCommandSourceTextSensor
Initial value:
1= home_io_control_ns.class_(
2 "IOHomeLastCommandSourceTextSensor", text_sensor.TextSensor, cg.Component
3)

Definition at line 87 of file platform_common.py.

◆ IOHomeLastContactSensor

home_io_control.platform_common.IOHomeLastContactSensor
Initial value:
1= home_io_control_ns.class_(
2 "IOHomeLastContactSensor", sensor.Sensor, cg.Component
3)

Definition at line 78 of file platform_common.py.

◆ IOHomeRssiSensor

home_io_control.platform_common.IOHomeRssiSensor = home_io_control_ns.class_("IOHomeRssiSensor", sensor.Sensor, cg.Component)

Definition at line 77 of file platform_common.py.