From ae16d017348315a41facd94612ddb679a9c19cc5 Mon Sep 17 00:00:00 2001 From: Proddy Date: Sun, 3 Apr 2022 13:41:38 +0200 Subject: [PATCH] add comment about has_cmd --- src/mqtt.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mqtt.cpp b/src/mqtt.cpp index 3733e3a93..abc0af963 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -919,6 +919,10 @@ void Mqtt::publish_ha_sensor_config(DeviceValue & dv, const std::string & model, int16_t dv_set_min, dv_set_max; (void)dv.get_min_max(dv_set_min, dv_set_max); + // determine if we're creating the command topics which we use special HA configs + // unless the entity has been marked as read-only and so it'll default to using the sensor/ type + bool has_cmd = dv.has_cmd && !dv.has_state(DeviceValueState::DV_READONLY); + publish_ha_sensor_config(dv.type, dv.tag, dv.full_name, @@ -926,7 +930,7 @@ void Mqtt::publish_ha_sensor_config(DeviceValue & dv, const std::string & model, dv.short_name, dv.uom, remove, - dv.has_cmd && !dv.has_state(DeviceValueState::DV_READONLY), + has_cmd, dv.options, dv.options_size, dv_set_min,