Skip to content

Commit

Permalink
Fix haptics on scripts widget (#2928)
Browse files Browse the repository at this point in the history
<!-- Thank you for submitting a Pull Request and helping to improve Home
Assistant. Please complete the following sections to help the processing
and review of your changes. Please do not delete anything from this
template. -->

## Summary
<!-- Provide a brief summary of the changes you have made and most
importantly what they aim to achieve -->

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->

## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a
corresponding pull request in the Companion App Documentation repository
(https://github.com/home-assistant/companion.home-assistant). Please add
the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
<!-- If there is any other information of note, like if this Pull
Request is part of a bigger change, please include it here. -->
  • Loading branch information
bgoncal authored Aug 20, 2024
1 parent dfb4398 commit 9352824
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
4 changes: 2 additions & 2 deletions HomeAssistant.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5322,7 +5322,7 @@
);
mainGroup = B657A8DD1CA646EB00121384;
packageReferences = (
427692E12B98B82500F24321 /* XCLocalSwiftPackageReference "Sources/PushServer/SharedPush" */,
427692E12B98B82500F24321 /* XCLocalSwiftPackageReference "SharedPush" */,
);
productRefGroup = B657A8E71CA646EB00121384 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -8650,7 +8650,7 @@
/* End XCConfigurationList section */

/* Begin XCLocalSwiftPackageReference section */
427692E12B98B82500F24321 /* XCLocalSwiftPackageReference "Sources/PushServer/SharedPush" */ = {
427692E12B98B82500F24321 /* XCLocalSwiftPackageReference "SharedPush" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = Sources/PushServer/SharedPush;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<EnvironmentVariables>
<EnvironmentVariable
key = "_XCWidgetKind"
value = "WidgetActions"
value = "WidgetScripts"
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
Expand Down
3 changes: 2 additions & 1 deletion Sources/App/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"app_intents.scripts.script.title" = "Run Script";
"app_intents.scripts.show_confirmation_dialog.description" = "Shows confirmation notification after executed";
"app_intents.scripts.show_confirmation_dialog.title" = "Confirmation notification";
"app_intents.scripts.haptic_confirmation.title" = "Haptic confirmation";
"app_intents.scripts.success_message.content" = "Script \"%@\" executed.";
"app_intents.widget_action.actions_parameter_configuration" = "Which actions?";
"assist.error.pipelines_response" = "Failed to obtain Assist pipelines, please check your pipelines configuration.";
Expand Down Expand Up @@ -912,4 +913,4 @@ Home Assistant is free and open source home automation software with a focus on
"widgets.scripts.description" = "Run Scripts";
"widgets.scripts.not_configured" = "No Scripts Configured";
"widgets.scripts.title" = "Scripts";
"yes_label" = "Yes";
"yes_label" = "Yes";
10 changes: 8 additions & 2 deletions Sources/Extensions/AppIntents/Script/ScriptAppIntent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ final class ScriptAppIntent: AppIntent {
)
var showConfirmationNotification: Bool

/// Only used when calling the intent from widget
var hapticConfirmation = false
@Parameter(
title: LocalizedStringResource(
"app_intents.scripts.haptic_confirmation.title",
defaultValue: "Haptic confirmation"
),
default: false
)
var hapticConfirmation: Bool

func perform() async throws -> some IntentResult & ReturnsValue<Bool> {
if requiresConfirmationBeforeRun {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Shared/Environment/MatterWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public class MatterWrapper {

#if os(iOS)
public var threadClientService: ThreadClientProtocol = ThreadClientService()
#endif

public var lastCommissionServerIdentifier: Identifier<Server>? {
get { Current.settingsStore.prefs.string(forKey: "lastCommissionServerID").flatMap { .init(rawValue: $0) } }
Expand Down Expand Up @@ -75,4 +74,5 @@ public class MatterWrapper {
return .value(())
#endif
}
#endif
}
4 changes: 4 additions & 0 deletions Sources/Shared/Resources/Swiftgen/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ public enum L10n {
return L10n.tr("Localizable", "app_intents.scripts.failure_message.content", String(describing: p1))
}
}
public enum HapticConfirmation {
/// Haptic confirmation
public static var title: String { return L10n.tr("Localizable", "app_intents.scripts.haptic_confirmation.title") }
}
public enum RequiresConfirmationBeforeRun {
/// Requires manual confirmation before running the script.
public static var description: String { return L10n.tr("Localizable", "app_intents.scripts.requires_confirmation_before_run.description") }
Expand Down

0 comments on commit 9352824

Please sign in to comment.