From 6cf4f11580175b83ea90cea8d9a21e3c1ea59cca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Chyrzy=C5=84ski?= Date: Mon, 5 Feb 2024 20:44:29 +0100 Subject: [PATCH] HASelect improvements (#221) * added getCurrentOption method to the HASelect * final fixes, tests * added support for publishing None state in the HASelect * update select.ino * update docs --- CHANGELOG.md | 2 ++ .../documents/api/device-types/ha-select.html | 8 +++++- .../api/utils/ha-serializer-array.html | 6 +++++ docs/genindex.html | 8 ++++-- docs/objects.inv | Bin 32163 -> 32244 bytes docs/searchindex.js | 2 +- examples/select/select.ino | 25 ++++++++++++------ src/device-types/HASelect.cpp | 11 +++++++- src/device-types/HASelect.h | 9 ++++++- src/utils/HASerializerArray.cpp | 9 +++++++ src/utils/HASerializerArray.h | 8 +++++- tests/SelectTest/SelectTest.ino | 21 ++++++++++++--- tests/SensorTest/SensorTest.ino | 1 - .../SerializerArrayTest.ino | 12 +++++++++ 14 files changed, 103 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7741cf2..547edba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ * Added support for the `state_class` property in the `HASensor` ([#179](https://github.com/dawidchyrzynski/arduino-home-assistant/pull/179) by [@https://github.com/Starzu]) * Implemented extended unique ID support for all device types. This allows you to prefix each device type's unique ID with the device ID, ensuring smooth deployment of identical code on multiple devices without encountering unique ID conflicts [#212](https://github.com/dawidchyrzynski/arduino-home-assistant/issues/212#issuecomment-1919832684) * Added support for the `configuration_url` parameter in the `HADevice` [#182](https://github.com/dawidchyrzynski/arduino-home-assistant/issues/182) +* Added `getCurrentOption` method to the `HASelect` device type [#163](https://github.com/dawidchyrzynski/arduino-home-assistant/issues/163) +* Added support for publishing `None` state in the `HASelect` device type [#146](https://github.com/dawidchyrzynski/arduino-home-assistant/issues/146) **Fixes:** * Fixed a bug with the maximum number of device types ([#190](https://github.com/dawidchyrzynski/arduino-home-assistant/issues/190) by [@martaisty](https://github.com/martaisty)) diff --git a/docs/documents/api/device-types/ha-select.html b/docs/documents/api/device-types/ha-select.html index 86d8bbe..5e8a85d 100644 --- a/docs/documents/api/device-types/ha-select.html +++ b/docs/documents/api/device-types/ha-select.html @@ -198,7 +198,7 @@
Parameters
    -
  • state – New state of the select.

  • +
  • state – New state of the select. You can set -1 to reset the select.

  • force – Forces to update state without comparing it to previous known state.

@@ -208,6 +208,12 @@
+
+
+const char *getCurrentOption() const
+

Returns the selected option based on the most recent state of the select. You can utilize this method to get the string representation of the option (e.g. for printing). If no option is selected, null is returned.

+
+
inline void setCurrentState(const int8_t state)
diff --git a/docs/documents/api/utils/ha-serializer-array.html b/docs/documents/api/utils/ha-serializer-array.html index 3fbc96b..652680b 100644 --- a/docs/documents/api/utils/ha-serializer-array.html +++ b/docs/documents/api/utils/ha-serializer-array.html @@ -210,6 +210,12 @@
+
+
+const char *getItem(const uint8_t index) const
+

Returns a pointer to the item at the given index. If the element doesn’t exist, null is returned.

+
+
uint16_t calculateSize() const
diff --git a/docs/genindex.html b/docs/genindex.html index d7314ac..8851072 100644 --- a/docs/genindex.html +++ b/docs/genindex.html @@ -867,10 +867,10 @@
  • HAHVAC::TemperatureUnit::DefaultUnit (C++ enumerator)
  • - - +