Files
Oliver Walter c49fff9faf Add ESPHome example configurations
The README carried a fragment, which is enough to show the shape but not
enough to flash. These are complete configs:

  wiredsensor.yaml      one node, every measurement and diagnostic register
  wiredsensor-node.yaml one node as a reusable package, parameterised by address
  bus-of-nodes.yaml     three nodes on one segment, via that package

All three validate against ESPHome 2026.7, and the expanded config was
checked register by register rather than only for schema validity — a
wrong address or value_type validates perfectly and then reports a
plausible but wrong temperature, which is the failure mode worth
guarding against.

Two things the fragment in the README was missing and a real config
cannot be:

flow_control_pin on the modbus component. Without it the ESP32 never
asserts DE, so nothing reaches the segment and the node looks dead. The
generated fragment now carries it too.

The read/holding split for diagnostics. ESPHome merges adjacent registers
of one register_type into a single command, and a read overlapping
0x0000..0x0004 is refused when the sensor has never produced a reading —
so diagnostics merged into the measurement command go unavailable exactly
when they are needed. Asking for them as `holding` puts them in their own
command.

Serials are text_sensors with raw_encode: HEXBYTES rather than numeric
sensors, because Home Assistant stores states as float32 and 24 bits of
mantissa cannot hold a 32-bit serial. Uptime has the same limit and is
left numeric with a note; quantising past 194 days does not matter for
spotting a reboot.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-29 17:28:08 +02:00

62 lines
2.0 KiB
YAML

# One wiredsensor node, as a reusable ESPHome package.
#
# Not flashable on its own — it defines no board, no wifi and no bus. It expects
# a parent config to supply a `modbus:` component with id `rs485_bus`, and to
# include this file once per node with `vars`. See bus-of-nodes.yaml.
#
# Required vars:
# node_id — a unique slug, used for the modbus_controller id
# node_addr — the node's RS485 unit address, matching its UNIT_ADDRESS
# node_name — human-readable prefix for the entity names
#
# Only the two measurement entities are exposed here. Per-node copies of every
# diagnostic counter multiply fast on a segment of a dozen nodes, so
# wiredsensor.yaml keeps the full set for the single-node case and this package
# stays deliberately lean. Add what you need — the register map is identical.
modbus_controller:
- id: ${node_id}
address: ${node_addr}
modbus_id: rs485_bus
update_interval: 30s
sensor:
- platform: modbus_controller
modbus_controller_id: ${node_id}
name: "${node_name} temperature"
register_type: read
address: 0x0000
value_type: S_DWORD
unit_of_measurement: "°C"
device_class: temperature
state_class: measurement
accuracy_decimals: 2
filters:
- multiply: 0.001
- platform: modbus_controller
modbus_controller_id: ${node_id}
name: "${node_name} humidity"
register_type: read
address: 0x0002
value_type: S_DWORD
unit_of_measurement: "%"
device_class: humidity
state_class: measurement
accuracy_decimals: 2
filters:
- multiply: 0.001
binary_sensor:
# On `holding` (0x03) rather than `read` (0x04) so a node whose sensor has
# never produced a reading still reports *why* — see wiredsensor.yaml for the
# full explanation.
- platform: modbus_controller
modbus_controller_id: ${node_id}
name: "${node_name} sensor fault"
register_type: holding
address: 0x0005
bitmask: 0x04
device_class: problem
entity_category: diagnostic