From 33bc12d7796c092039ba132dbeec0ed818fb2a2f Mon Sep 17 00:00:00 2001 From: Philip Abbey Date: Tue, 14 Nov 2023 21:14:32 +0000 Subject: [PATCH] Update HomeAssistantMenuItem.mc Review comments. Vibrate on tap, visual confirmation on receipt of response. --- source/HomeAssistantMenuItem.mc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/source/HomeAssistantMenuItem.mc b/source/HomeAssistantMenuItem.mc index d72ada3..0212227 100644 --- a/source/HomeAssistantMenuItem.mc +++ b/source/HomeAssistantMenuItem.mc @@ -89,15 +89,7 @@ class HomeAssistantMenuItem extends WatchUi.MenuItem { } if (WatchUi has :showToast) { WatchUi.showToast(toast, null); - } - if (Attention has :vibrate) { - Attention.vibrate([ - new Attention.VibeProfile(50, 100), // On for 100ms - new Attention.VibeProfile( 0, 100), // Off for 100ms - new Attention.VibeProfile(50, 100) // On for 100ms - ]); - } - if (!(WatchUi has :showToast) && !(Attention has :vibrate)) { + } else { new Alert({ :timeout => Globals.scAlertTimeout, :font => Graphics.FONT_MEDIUM, @@ -128,7 +120,7 @@ class HomeAssistantMenuItem extends WatchUi.MenuItem { // ERROR: venu: Cannot find symbol ':substring' on type 'PolyType'. var id = mIdentifier as Lang.String; if (mService == null) { - var url = (Properties.getValue("api_url") as Lang.String) + "/services/" + id.substring(0, id.find(".")) + "/" + id.substring(id.find(".")+1, id.length()); + var url = (Properties.getValue("api_url") as Lang.String) + "/services/" + id.substring(0, id.find(".")) + "/" + id.substring(id.find(".")+1, null); if (Globals.scDebug) { System.println("HomeAssistantMenuItem execScript() URL=" + url); System.println("HomeAssistantMenuItem execScript() mIdentifier=" + mIdentifier); @@ -154,6 +146,13 @@ class HomeAssistantMenuItem extends WatchUi.MenuItem { method(:onReturnExecScript) ); } + if (Attention has :vibrate) { + Attention.vibrate([ + new Attention.VibeProfile(50, 100), // On for 100ms + new Attention.VibeProfile( 0, 100), // Off for 100ms + new Attention.VibeProfile(50, 100) // On for 100ms + ]); + } } else { if (Globals.scDebug) { System.println("HomeAssistantMenuItem execScript(): No Internet connection, skipping API call.");