mirror of
https://github.com/alexhopeoconnor/arduino-home-assistant.git
synced 2026-10-04 02:48:13 +10:00
Align ArduinoHA with current Home Assistant MQTT discovery expectations by adding default entity IDs, device discovery support, safer runtime discovery refresh behavior, expanded entity category coverage, and the tests/docs needed to support the migration away from legacy object_id payloads.
8.7 KiB
8.7 KiB
Changelog
Unreleased
New features:
- Added support for the
default_entity_id(def_ent_id) discovery property across device types. New code should prefersetDefaultEntityId()oversetObjectId(). - Added opt-in MQTT device discovery payload support through
HAMqtt::enableDeviceDiscovery(), while keeping single-component discovery as the default behavior. - Added
HABaseDeviceType::removeFromDiscovery()andHABaseDeviceType::republishDiscovery()helpers for explicit discovery lifecycle management. - Added support for the
entity_categoryproperty across the exposed MQTT device types.
Fixes:
- Fixed discovery refresh behavior for runtime config updates so device discovery mode clears stale retained per-entity configs before republishing device payloads.
- Fixed
HANumber::updateMinMaxStep()so discovery updates follow the active discovery mode instead of always writing a retained per-entity config. - Ignore empty
unit_of_measurementvalues in discovery payloads. - Allow
HANumberconfigurations whereminis equal tomax.
Migration notes:
- Home Assistant deprecated MQTT
object_idin favor ofdefault_entity_id, and newer Home Assistant versions may warn on or removeobject_idhandling in discovery payloads. - Existing code using
setObjectId()remains supported as a legacy fallback, but new projects should migrate tosetDefaultEntityId(). - If you enable device discovery mode, avoid publishing per-entity discovery topics manually. Use
republishDiscovery()when a runtime config change needs to refresh discovery state.
2.1.0
New features:
- Added support for setting MQTT's keep alive #153 by @allenb2800
- Added support for the
state_classproperty in theHASensor#179 - 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
- Added support for the
configuration_urlproperty in theHADevice#182 - Added
getCurrentOptionmethod to theHASelectdevice type #163 - Added support for publishing the
Nonestate in theHASelectdevice type #146 - Added support for publishing the
Nonestate in theHASensordevice type #175 - Added support for the
expire_afterproperty in theHASensor#171 - Added support for the
expire_afterproperty in theHABinarySensor#159 - Added support for the JSON attributes in the
HASensor - Added support for the
object_idproperty in all device types - Added
setBufferSizemethod to theHAMqttclass #202 - Added
getStatemethod to theHAMqttclass - Added
onDisconnectedcallback method to theHAMqttclass - Added
onStateChangedcallback method to theHAMqttclass - Added support for Arduino Due #137
Fixes:
- Fixed a bug with the maximum number of device types #190 by @martaisty
- Fixed compiler warning:
class 'HANumeric' is implicitly friends with itself#197 by @shedokan - The default limit for device types has been raised to 24 on processors other than ATMega328/ATMega168. The previous default limit of 6 led to confusion for many users.
2.0.0
New features:
- Added support for the
iconproperty in theHABinarySensor(you can set the icon usingHABinarySensor::setIcon("iconName")) - Added support for changing the current state of the
HABinarySensorusingHABinarySensor::setCurrentStatemethod - Added support for forcing
setStateinHABinarySensorusing a second argument as followsHABinarySensor::setState(true, true) - Added support for the
device_classproperty in theHACover(you can set the class usingHACover::setDeviceClass("className") - Added support for the
iconproperty in theHACover(you can set the icon usingHACover::setIcon("iconName")) - Added pointer of the sender to the
HACovercallback function - Added support for
optimisticproperty in theHACover(you can change the mode usingHACover::setOptimistic(true)) - Added support for forcing
setPositioninHACoverusing a second argument as followsHACover::setPosition(100, true) - Added support for the
device_classproperty in theHASwitch(you can set the class usingHASwitch::setDeviceClass("className") - Added support for the
optimisticproperty in theHASwitch(you can change the mode usingHASwitch::setOptimistic(true)) - Added support for the
force_updateproperty in theHASensor(you can set the mode usingHASensor::setForceUpdate(true)) - Added support for the
HAButtondevice type - Added support for the
HADeviceTrackerdevice type - Added support for the
HACameradevice type - Added support for the
HALockdevice type - Added support for the
HASelectdevice type - Added support for the
HANumberdevice type - Added support for the
HAScenedevice type - Added support for the
HALightdevice type
Fixes:
- Last Will Message is now retained (#70)
- Compilation error on SAMD family (#82)
New examples:
- Button - adding simple buttons to the Home Assistant panel.
Breaking changes:
- Changed structure of all MQTT topics used in the library.
- Changed constructor of the
HABinarySensorclass (removeddeviceClassandinitialStatearguments) - Renamed
HABinarySensor::getState()method toHABinarySensor::getCurrentState() - Replaced
HATriggerswithHADeviceTrigger- the new implementation is not backward compatible. Please check the updated example of themulti-state-button. - Renamed
HADevice::isOnline()method toHADevice::isAvailable() - Renamed
HASwitch::onStateChangedmethod toHASwitch::onCommand. - Renamed
HAFan::onStateChangedmethod toHAFan::onStateCommand. - Renamed
HAFan::onSpeedChangedmethod toHAFan::onSpeedCommand. - Changed logic of the
HASwitchcallback. Please check theled-switchexample. - Refactored
HASensorlogic. It's now divided into two different classes:HASensorandHASensorNumber. - Removed all legacy constructors with
HAMqttargument - Removed
onConnectionFailedcallback from theHAMqttclass - The position in the
HACoveris now available as configurable feature. It's disabled by default. - Refactored
HAHVACclass to support more features of the MQTT discovery. Please check the update example.
1.3.0
New features:
- Added
onMessage()method to HAMqtt class - Added support for HA Covers
- Added support for setting different prefix for non-discovery topics (see Advanced MQTT example)
- Added
setNamemethod to HASensor - Added
setNamemethod to HASwitch - Added
onBeforeStateChangedcallback to HASwitch
Improvements:
- Removed legacy properties from HAFan (Home Assistant 2021.4.4). Deprecated methods will be removed after a quarter (2021.7)
- Separated
uniqueIDfield fromnamein all devices types
1.2.0
Breaking changes:
- Refactored HASensor implementation. Please take a look at updated example
New features:
- Added support for HVAC
- Added support for excluding devices types from the compilation using defines (see src/ArduinoHADefines.h)
- Added support for setting icon in HASwitch and HASensor
- Added support for setting retain flag in HASwitch
- Added support for text (const char*) payload in HASensor
- Added support for fans (HAFan)
- Added support for connecting to the MQTT broker using hostname
- Added
onConnected()method in the HAMqtt - Added
onConnectionFailed()method in the HAMqtt - Added support for MQTT LWT (see Advanced Availability example)
Improvements:
- Optimized codebase and logic in all devices types
- Updated all examples
- Fixed compilation warnings in all classes