Per-entity availability, deferred discovery publish, suggested precision

- Add HAAvailabilityConfig for per-entity availability_topic and payloads
- Defer discovery until MQTT connected; publish availability after discovery
- HASensor/HANumber: optional suggested_display_precision in discovery
- HASerializer/HADictionary: extend for new keys; update device types and mocks
- Docs and examples reflect availability and precision usage
- Tests updated for discovery and availability behavior
- Ignore .cursor/ in repo root
This commit is contained in:
2026-05-05 17:47:55 +10:00
parent 8ba5482892
commit b9f4fd7f4b
62 changed files with 2705 additions and 283 deletions
@@ -676,3 +676,14 @@ void test_SensorNumberTest_publish_precision_mismatch(void) {
TEST_ASSERT_EQUAL(mock->getFlushedMessagesNb(), 0);
}
void test_SensorNumberTest_disconnected_value_updates_local_shadow(void) {
initMqttTest(testDeviceId)
HASensorNumber sensor(testUniqueId, HASensorNumber::PrecisionP1);
TEST_ASSERT_FALSE(sensor.setValue(27.5f));
TEST_ASSERT_TRUE(sensor.getCurrentValue().isSet());
AHA_ASSERT_NEAR_FLOAT(27.5f, sensor.getCurrentValue().toFloat(), 0.1f);
TEST_ASSERT_EQUAL(0, mock->getFlushedMessagesNb());
}