Skip to content

Commit 928a392

Browse files
authored
Merge pull request #597 from BrentIO/fix/596
Move commit hash to autodiscovery sw_version, revert installed_version
2 parents b90841f + 92b1461 commit 928a392

2 files changed

Lines changed: 50 additions & 20 deletions

File tree

Controller/Controller.ino

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -934,9 +934,7 @@ void loop() {
934934
mqttClient.publish(availability_topic, "online", true);
935935

936936
JsonDocument mqttDoc;
937-
char installedVersion[32];
938-
snprintf(installedVersion, sizeof(installedVersion), "%s (%s)", VERSION, COMMIT_HASH);
939-
mqttDoc["installed_version"] = installedVersion;
937+
mqttDoc["installed_version"] = VERSION;
940938
mqttDoc["latest_version"] = VERSION;
941939
char topic[MQTT_TOPIC_UPDATE_STATE_PATTERN_LENGTH+1];
942940
snprintf(topic, sizeof(topic), MQTT_TOPIC_UPDATE_STATE_PATTERN, deviceIdentity.data.uuid);
@@ -3621,9 +3619,7 @@ void setup_OtaFirmware(){
36213619
eventLog.createEvent("OTA update available");
36223620

36233621
JsonDocument mqttDoc;
3624-
char installedVersion[32];
3625-
snprintf(installedVersion, sizeof(installedVersion), "%s (%s)", VERSION, COMMIT_HASH);
3626-
mqttDoc["installed_version"] = installedVersion;
3622+
mqttDoc["installed_version"] = VERSION;
36273623
mqttDoc["latest_version"] = version;
36283624
if(releaseUrl && strlen(releaseUrl) > 0){
36293625
mqttDoc["release_url"] = releaseUrl;
@@ -3726,9 +3722,7 @@ void otaFirmware_checkPending(){
37263722
eventLog.createEvent("OTA update available");
37273723
if(deviceIdentity.enabled && mqttClient.connected()){
37283724
JsonDocument mqttDoc;
3729-
char installedVersion[32];
3730-
snprintf(installedVersion, sizeof(installedVersion), "%s (%s)", VERSION, COMMIT_HASH);
3731-
mqttDoc["installed_version"] = installedVersion;
3725+
mqttDoc["installed_version"] = VERSION;
37323726
const char* targetVersion = _otaPendingDoc["version"] | VERSION;
37333727
mqttDoc["latest_version"] = targetVersion;
37343728
const char* releaseUrl = _otaPendingDoc["release_url"] | "";
@@ -4388,7 +4382,7 @@ void mqtt_autoDiscovery_temperature(){
43884382
device["model"] = APPLICATION_NAME;
43894383
device["model_id"] = deviceIdentity.data.product_id;
43904384
device["serial_number"] = deviceIdentity.data.uuid;
4391-
device["sw_version"] = VERSION;
4385+
device["sw_version"] = VERSION " (" COMMIT_HASH ")";
43924386
device["configuration_url"] = ("http://" + ETH.localIP().toString()).c_str();
43934387

43944388
if(strlen(mqttClient.autoDiscovery.suggestedArea) > 0){
@@ -4960,7 +4954,7 @@ void mqtt_autoDiscovery_inputControllers(){
49604954
device["model"] = APPLICATION_NAME;
49614955
device["model_id"] = deviceIdentity.data.product_id;
49624956
device["serial_number"] = deviceIdentity.data.uuid;
4963-
device["sw_version"] = VERSION;
4957+
device["sw_version"] = VERSION " (" COMMIT_HASH ")";
49644958
device["configuration_url"] = ("http://" + ETH.localIP().toString()).c_str();
49654959

49664960
if(strlen(mqttClient.autoDiscovery.suggestedArea) > 0){
@@ -5034,7 +5028,7 @@ void mqtt_autoDiscovery_outputControllers(){
50345028
device["model"] = APPLICATION_NAME;
50355029
device["model_id"] = deviceIdentity.data.product_id;
50365030
device["serial_number"] = deviceIdentity.data.uuid;
5037-
device["sw_version"] = VERSION;
5031+
device["sw_version"] = VERSION " (" COMMIT_HASH ")";
50385032
device["configuration_url"] = ("http://" + ETH.localIP().toString()).c_str();
50395033

50405034
if(strlen(mqttClient.autoDiscovery.suggestedArea) > 0){
@@ -5093,7 +5087,7 @@ void mqtt_autoDiscovery_start_time(){
50935087
device["model"] = APPLICATION_NAME;
50945088
device["model_id"] = deviceIdentity.data.product_id;
50955089
device["serial_number"] = deviceIdentity.data.uuid;
5096-
device["sw_version"] = VERSION;
5090+
device["sw_version"] = VERSION " (" COMMIT_HASH ")";
50975091
device["configuration_url"] = ("http://" + ETH.localIP().toString()).c_str();
50985092

50995093
if(strlen(mqttClient.autoDiscovery.suggestedArea) > 0){
@@ -5177,7 +5171,7 @@ void mqtt_autoDiscovery_mac_address(){
51775171
device["model"] = APPLICATION_NAME;
51785172
device["model_id"] = deviceIdentity.data.product_id;
51795173
device["serial_number"] = deviceIdentity.data.uuid;
5180-
device["sw_version"] = VERSION;
5174+
device["sw_version"] = VERSION " (" COMMIT_HASH ")";
51815175
device["configuration_url"] = ("http://" + ETH.localIP().toString()).c_str();
51825176

51835177
if(strlen(mqttClient.autoDiscovery.suggestedArea) > 0){
@@ -5257,7 +5251,7 @@ void mqtt_autoDiscovery_ip_address(){
52575251
device["model"] = APPLICATION_NAME;
52585252
device["model_id"] = deviceIdentity.data.product_id;
52595253
device["serial_number"] = deviceIdentity.data.uuid;
5260-
device["sw_version"] = VERSION;
5254+
device["sw_version"] = VERSION " (" COMMIT_HASH ")";
52615255
device["configuration_url"] = ("http://" + ETH.localIP().toString()).c_str();
52625256

52635257
if(strlen(mqttClient.autoDiscovery.suggestedArea) > 0){
@@ -5340,7 +5334,7 @@ void mqtt_autoDiscovery_count_errors(){
53405334
device["model"] = APPLICATION_NAME;
53415335
device["model_id"] = deviceIdentity.data.product_id;
53425336
device["serial_number"] = deviceIdentity.data.uuid;
5343-
device["sw_version"] = VERSION;
5337+
device["sw_version"] = VERSION " (" COMMIT_HASH ")";
53445338
device["configuration_url"] = ("http://" + ETH.localIP().toString()).c_str();
53455339

53465340
if(strlen(mqttClient.autoDiscovery.suggestedArea) > 0){
@@ -5427,7 +5421,7 @@ void mqtt_autoDiscovery_update(){
54275421
device["model"] = APPLICATION_NAME;
54285422
device["model_id"] = deviceIdentity.data.product_id;
54295423
device["serial_number"] = deviceIdentity.data.uuid;
5430-
device["sw_version"] = VERSION;
5424+
device["sw_version"] = VERSION " (" COMMIT_HASH ")";
54315425
device["configuration_url"] = ("http://" + ETH.localIP().toString()).c_str();
54325426

54335427
if(strlen(mqttClient.autoDiscovery.suggestedArea) > 0){
@@ -5494,7 +5488,7 @@ void mqtt_autoDiscovery_http_server(){
54945488
device["model"] = APPLICATION_NAME;
54955489
device["model_id"] = deviceIdentity.data.product_id;
54965490
device["serial_number"] = deviceIdentity.data.uuid;
5497-
device["sw_version"] = VERSION;
5491+
device["sw_version"] = VERSION " (" COMMIT_HASH ")";
54985492
device["configuration_url"] = ("http://" + ETH.localIP().toString()).c_str();
54995493

55005494
if(strlen(mqttClient.autoDiscovery.suggestedArea) > 0){
@@ -5588,7 +5582,7 @@ void mqtt_autoDiscovery_heapFree(){
55885582
device["model"] = APPLICATION_NAME;
55895583
device["model_id"] = deviceIdentity.data.product_id;
55905584
device["serial_number"] = deviceIdentity.data.uuid;
5591-
device["sw_version"] = VERSION;
5585+
device["sw_version"] = VERSION " (" COMMIT_HASH ")";
55925586
device["configuration_url"] = ("http://" + ETH.localIP().toString()).c_str();
55935587

55945588
if(strlen(mqttClient.autoDiscovery.suggestedArea) > 0){
@@ -5671,7 +5665,7 @@ void mqtt_autoDiscovery_heapLargestFreeBlock(){
56715665
device["model"] = APPLICATION_NAME;
56725666
device["model_id"] = deviceIdentity.data.product_id;
56735667
device["serial_number"] = deviceIdentity.data.uuid;
5674-
device["sw_version"] = VERSION;
5668+
device["sw_version"] = VERSION " (" COMMIT_HASH ")";
56755669
device["configuration_url"] = ("http://" + ETH.localIP().toString()).c_str();
56765670

56775671
if(strlen(mqttClient.autoDiscovery.suggestedArea) > 0){

Controller/asyncapi.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,6 +1551,42 @@ components:
15511551
device:
15521552
type: object
15531553
description: Device grouping information
1554+
properties:
1555+
identifiers:
1556+
type: array
1557+
description: List of unique device identifiers
1558+
items:
1559+
type: string
1560+
name:
1561+
type: string
1562+
description: Device display name
1563+
manufacturer:
1564+
type: string
1565+
description: Device manufacturer name
1566+
model:
1567+
type: string
1568+
description: Device model name
1569+
model_id:
1570+
type: string
1571+
description: Device model identifier
1572+
serial_number:
1573+
type: string
1574+
description: Device serial number (UUID)
1575+
sw_version:
1576+
type: string
1577+
description: >
1578+
Installed firmware version concatenated with the short commit hash in the
1579+
format "VERSION (COMMIT_HASH)", e.g. "2026.06.05 (1a2b3c4d)".
1580+
examples:
1581+
- "2026.06.05 (1a2b3c4d)"
1582+
configuration_url:
1583+
type: string
1584+
description: URL of the device's local web UI
1585+
examples:
1586+
- "http://192.168.1.100"
1587+
suggested_area:
1588+
type: string
1589+
description: Suggested Home Assistant area; omitted when not configured
15541590

15551591
clientCertStatePayload:
15561592
type: object

0 commit comments

Comments
 (0)