From 95c861037dae175d93577516de9d76d3b6a6198c Mon Sep 17 00:00:00 2001 From: Dan Cunningham Date: Mon, 9 Sep 2024 14:51:26 -0700 Subject: [PATCH] [openhab-legacy] Make label optional in command items (#805) cherry-pick 46c361093ce622384f092a6f9fb53dd3068a3e29 Signed-off-by: Dan Cunningham --- .../Sources/OpenHABCore/Model/OpenHABCommandOptions.swift | 2 +- OpenHABCore/Sources/OpenHABCore/Model/OpenHABWidget.swift | 2 +- .../openHABWatch Extension/Model/ObservableOpenHABWidget.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenHABCore/Sources/OpenHABCore/Model/OpenHABCommandOptions.swift b/OpenHABCore/Sources/OpenHABCore/Model/OpenHABCommandOptions.swift index 5484d214..1e610277 100644 --- a/OpenHABCore/Sources/OpenHABCore/Model/OpenHABCommandOptions.swift +++ b/OpenHABCore/Sources/OpenHABCore/Model/OpenHABCommandOptions.swift @@ -13,5 +13,5 @@ import Foundation public class OpenHABCommandOptions: Decodable { public var command = "" - public var label = "" + public var label: String? = "" } diff --git a/OpenHABCore/Sources/OpenHABCore/Model/OpenHABWidget.swift b/OpenHABCore/Sources/OpenHABCore/Model/OpenHABWidget.swift index 74cc3f29..2a07cb60 100644 --- a/OpenHABCore/Sources/OpenHABCore/Model/OpenHABWidget.swift +++ b/OpenHABCore/Sources/OpenHABCore/Model/OpenHABWidget.swift @@ -121,7 +121,7 @@ public class OpenHABWidget: NSObject, MKAnnotation, Identifiable { public var mappingsOrItemOptions: [OpenHABWidgetMapping] { if mappings.isEmpty, let commandOptions = item?.commandDescription?.commandOptions { - commandOptions.map { OpenHABWidgetMapping(command: $0.command, label: $0.label) } + commandOptions.map { OpenHABWidgetMapping(command: $0.command, label: $0.label ?? "") } } else if mappings.isEmpty, let stateOptions = item?.stateDescription?.options { stateOptions.map { OpenHABWidgetMapping(command: $0.value, label: $0.label) } } else { diff --git a/openHABWatch Extension/openHABWatch Extension/Model/ObservableOpenHABWidget.swift b/openHABWatch Extension/openHABWatch Extension/Model/ObservableOpenHABWidget.swift index 348c1645..294c6518 100644 --- a/openHABWatch Extension/openHABWatch Extension/Model/ObservableOpenHABWidget.swift +++ b/openHABWatch Extension/openHABWatch Extension/Model/ObservableOpenHABWidget.swift @@ -98,7 +98,7 @@ class ObservableOpenHABWidget: NSObject, MKAnnotation, Identifiable, ObservableO var mappingsOrItemOptions: [OpenHABWidgetMapping] { if mappings.isEmpty, let commandOptions = item?.commandDescription?.commandOptions { - commandOptions.map { OpenHABWidgetMapping(command: $0.command, label: $0.label) } + commandOptions.map { OpenHABWidgetMapping(command: $0.command, label: $0.label ?? "") } } else if mappings.isEmpty, let stateOptions = item?.stateDescription?.options { stateOptions.map { OpenHABWidgetMapping(command: $0.value, label: $0.label) } } else {