diff --git a/HomeAssistant.code-workspace b/HomeAssistant.code-workspace new file mode 100644 index 0000000..1b7e21b --- /dev/null +++ b/HomeAssistant.code-workspace @@ -0,0 +1,12 @@ +{ + "folders": [ + { + "path": "." + }, + { + "name": "abc", + "path": "../blah/abc" + } + ], + "settings": {} +} \ No newline at end of file diff --git a/iconResize.py b/iconResize.py index ca4d82f..fdbb378 100644 --- a/iconResize.py +++ b/iconResize.py @@ -48,14 +48,18 @@ original = (96, 48, 24) lookup = { # Doub Sing Half # 0 1 2 -# 416: (96, 48, 24), - 390: (90, 46, 23), - 360: (84, 42, 21), - 320: (74, 38, 19), - 280: (64, 32, 16), - 260: (60, 30, 15), - 240: (56, 28, 14), - 218: (50, 26, 13), + 454: (106, 53, 27), +# 416: ( 96, 48, 24), + 390: ( 90, 46, 23), + 360: ( 84, 42, 21), + 320: ( 74, 38, 19), + 280: ( 64, 32, 16), + 260: ( 60, 30, 15), + 240: ( 56, 28, 14), + 218: ( 50, 26, 13), + 208: ( 48, 24, 12), + 176: ( 42, 21, 11), + 156: ( 36, 18, 9) } # Delete all but the original 48x48 icon directories @@ -67,6 +71,8 @@ for entry in os.listdir("."): for screen_size, icon_sizes in lookup.items(): output_dir = output_dir_prefix + str(icon_sizes[Sing]) print("\nCreate directory:", output_dir) + if os.path.exists(output_dir) and os.path.isdir(output_dir): + shutil.rmtree(output_dir) os.makedirs(output_dir) for entry in os.listdir(input_dir): if entry.endswith(".svg"): diff --git a/manifest.xml b/manifest.xml index 643d0e3..53c1466 100644 --- a/manifest.xml +++ b/manifest.xml @@ -30,19 +30,100 @@ "Monkey C: Edit Products" - Lets you add or remove any product --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -50,6 +131,15 @@ + + + + + + + + + @@ -66,10 +156,16 @@ + + + + + + + + + + \ No newline at end of file diff --git a/resources-icons-18/error.svg b/resources-icons-18/error.svg new file mode 100644 index 0000000..5776799 --- /dev/null +++ b/resources-icons-18/error.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources-icons-21/drawables.xml b/resources-icons-21/drawables.xml new file mode 100644 index 0000000..320d05b --- /dev/null +++ b/resources-icons-21/drawables.xml @@ -0,0 +1,20 @@ + + + + + \ No newline at end of file diff --git a/resources-icons-21/error.svg b/resources-icons-21/error.svg new file mode 100644 index 0000000..48c2bf8 --- /dev/null +++ b/resources-icons-21/error.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources-icons-24/drawables.xml b/resources-icons-24/drawables.xml new file mode 100644 index 0000000..320d05b --- /dev/null +++ b/resources-icons-24/drawables.xml @@ -0,0 +1,20 @@ + + + + + \ No newline at end of file diff --git a/resources-icons-24/error.svg b/resources-icons-24/error.svg new file mode 100644 index 0000000..8ebdb16 --- /dev/null +++ b/resources-icons-24/error.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources-icons-53/drawables.xml b/resources-icons-53/drawables.xml new file mode 100644 index 0000000..320d05b --- /dev/null +++ b/resources-icons-53/drawables.xml @@ -0,0 +1,20 @@ + + + + + \ No newline at end of file diff --git a/resources-icons-53/error.svg b/resources-icons-53/error.svg new file mode 100644 index 0000000..eb83c50 --- /dev/null +++ b/resources-icons-53/error.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources-ind/strings/strings.xml b/resources-ind/strings/strings.xml index 03b8937..aa3ba2f 100644 --- a/resources-ind/strings/strings.xml +++ b/resources-ind/strings/strings.xml @@ -26,4 +26,7 @@ Menu Tidak ada koneksi internet Kesalahan Pengambilan Menu + Tidak ada kunci API di pengaturan aplikasi + Tidak ada URL API di pengaturan aplikasi + Tidak ada URL konfigurasi di pengaturan aplikasi \ No newline at end of file diff --git a/resources-ita/strings/strings.xml b/resources-ita/strings/strings.xml index 43bbc2a..17a9326 100644 --- a/resources-ita/strings/strings.xml +++ b/resources-ita/strings/strings.xml @@ -26,4 +26,7 @@ Menù Nessuna connessione internet Errore di recupero del menu + Nessuna chiave API nelle impostazioni dell'applicazione + Nessun URL API nelle impostazioni dell'applicazione + Nessun URL di configurazione nelle impostazioni dell'applicazione \ No newline at end of file diff --git a/resources-jpn/strings/strings.xml b/resources-jpn/strings/strings.xml index 0b1318d..cd4e7e7 100644 --- a/resources-jpn/strings/strings.xml +++ b/resources-jpn/strings/strings.xml @@ -26,4 +26,7 @@ メニュー インターネット接続なし メニューフェッチエラー + アプリケーション設定に API キーがありません + アプリケーション設定に API URL がありません + アプリケーション設定に構成 URL がありません \ No newline at end of file diff --git a/resources-kor/strings/strings.xml b/resources-kor/strings/strings.xml index cfcfbe3..a951a06 100644 --- a/resources-kor/strings/strings.xml +++ b/resources-kor/strings/strings.xml @@ -26,4 +26,7 @@ 메뉴 인터넷에 연결되지 않음 메뉴 가져오기 오류 + 애플리케이션 설정에 API 키가 없습니다. + 애플리케이션 설정에 API URL이 없습니다. + 애플리케이션 설정에 구성 URL이 없습니다. \ No newline at end of file diff --git a/resources-launcher-25-25 - DELETE/drawables.xml b/resources-launcher-25-25 - DELETE/drawables.xml new file mode 100644 index 0000000..d8b5369 --- /dev/null +++ b/resources-launcher-25-25 - DELETE/drawables.xml @@ -0,0 +1,17 @@ + + + + + diff --git a/resources-launcher-25-25 - DELETE/launcher.png b/resources-launcher-25-25 - DELETE/launcher.png new file mode 100644 index 0000000..7509b0b Binary files /dev/null and b/resources-launcher-25-25 - DELETE/launcher.png differ diff --git a/resources-launcher-54-54/drawables.xml b/resources-launcher-54-54/drawables.xml new file mode 100644 index 0000000..d8b5369 --- /dev/null +++ b/resources-launcher-54-54/drawables.xml @@ -0,0 +1,17 @@ + + + + + diff --git a/resources-launcher-54-54/launcher.png b/resources-launcher-54-54/launcher.png new file mode 100644 index 0000000..76bfe31 Binary files /dev/null and b/resources-launcher-54-54/launcher.png differ diff --git a/resources-launcher-62-62/drawables.xml b/resources-launcher-62-62/drawables.xml new file mode 100644 index 0000000..d8b5369 --- /dev/null +++ b/resources-launcher-62-62/drawables.xml @@ -0,0 +1,17 @@ + + + + + diff --git a/resources-launcher-62-62/launcher.png b/resources-launcher-62-62/launcher.png new file mode 100644 index 0000000..bfd1b08 Binary files /dev/null and b/resources-launcher-62-62/launcher.png differ diff --git a/resources-launcher-65-65/drawables.xml b/resources-launcher-65-65/drawables.xml new file mode 100644 index 0000000..d8b5369 --- /dev/null +++ b/resources-launcher-65-65/drawables.xml @@ -0,0 +1,17 @@ + + + + + diff --git a/resources-launcher-65-65/launcher.png b/resources-launcher-65-65/launcher.png new file mode 100644 index 0000000..16d697f Binary files /dev/null and b/resources-launcher-65-65/launcher.png differ diff --git a/resources-launcher-80-80/drawables.xml b/resources-launcher-80-80/drawables.xml new file mode 100644 index 0000000..d8b5369 --- /dev/null +++ b/resources-launcher-80-80/drawables.xml @@ -0,0 +1,17 @@ + + + + + diff --git a/resources-launcher-80-80/launcher.png b/resources-launcher-80-80/launcher.png new file mode 100644 index 0000000..3feefd1 Binary files /dev/null and b/resources-launcher-80-80/launcher.png differ diff --git a/resources-lav/strings/strings.xml b/resources-lav/strings/strings.xml index 75b66ca..9eaeeb1 100644 --- a/resources-lav/strings/strings.xml +++ b/resources-lav/strings/strings.xml @@ -26,4 +26,7 @@ Izvēlne Nav interneta savienojuma Izvēlnes ielādes kļūda + Lietojumprogrammas iestatījumos nav API atslēgas + Lietojumprogrammas iestatījumos nav API URL + Lietojumprogrammas iestatījumos nav konfigurācijas URL \ No newline at end of file diff --git a/resources-lit/strings/strings.xml b/resources-lit/strings/strings.xml index 88d1bb1..e599cbf 100644 --- a/resources-lit/strings/strings.xml +++ b/resources-lit/strings/strings.xml @@ -26,4 +26,7 @@ Meniu Nėra interneto ryšio Meniu gavimo klaida + Programos nustatymuose nėra API rakto + Programos nustatymuose nėra API URL + Programos nustatymuose nėra konfigūracijos URL \ No newline at end of file diff --git a/resources-nob/strings/strings.xml b/resources-nob/strings/strings.xml index cb80be2..edcddbf 100644 --- a/resources-nob/strings/strings.xml +++ b/resources-nob/strings/strings.xml @@ -26,4 +26,7 @@ Meny Ingen Internett-tilkobling Menyhentingsfeil + Ingen API-nøkkel i applikasjonsinnstillingene + Ingen API-URL i applikasjonsinnstillingene + Ingen konfigurasjons-URL i applikasjonsinnstillingene \ No newline at end of file diff --git a/resources-pol/strings/strings.xml b/resources-pol/strings/strings.xml index 236d5d5..5f7db9b 100644 --- a/resources-pol/strings/strings.xml +++ b/resources-pol/strings/strings.xml @@ -26,4 +26,7 @@ Menu Brak połączenia z internetem Błąd pobierania menu + Brak klucza API w ustawieniach aplikacji + Brak adresu API w ustawieniach aplikacji + Brak adresu URL konfiguracji w ustawieniach aplikacji \ No newline at end of file diff --git a/resources-por/strings/strings.xml b/resources-por/strings/strings.xml index 3f93633..4b98456 100644 --- a/resources-por/strings/strings.xml +++ b/resources-por/strings/strings.xml @@ -26,4 +26,7 @@ Cardápio Sem conexão com a Internet Erro ao buscar menu + Nenhuma chave de API nas configurações do aplicativo + Nenhum URL de API nas configurações do aplicativo + Nenhum URL de configuração nas configurações do aplicativo \ No newline at end of file diff --git a/resources-ron/strings/strings.xml b/resources-ron/strings/strings.xml index 2920cf6..430f2f4 100644 --- a/resources-ron/strings/strings.xml +++ b/resources-ron/strings/strings.xml @@ -26,4 +26,7 @@ Meniul Fără conexiune internet Eroare de preluare a meniului + Nicio cheie API în setările aplicației + Nicio adresă URL API în setările aplicației + Nicio adresă URL de configurare în setările aplicației \ No newline at end of file diff --git a/resources-slo/strings/strings.xml b/resources-slo/strings/strings.xml index ebe1983..70e5be8 100644 --- a/resources-slo/strings/strings.xml +++ b/resources-slo/strings/strings.xml @@ -26,4 +26,7 @@ Ponuka Žiadne internetové pripojenie Chyba načítania ponuky + V nastaveniach aplikácie nie je žiadny kľúč API + V nastaveniach aplikácie nie je žiadna adresa URL rozhrania API + V nastaveniach aplikácie nie je žiadna konfiguračná URL \ No newline at end of file diff --git a/resources-slv/strings/strings.xml b/resources-slv/strings/strings.xml index 258cfd2..77e7b24 100644 --- a/resources-slv/strings/strings.xml +++ b/resources-slv/strings/strings.xml @@ -26,4 +26,7 @@ meni Ni internetne povezave Napaka pri pridobivanju menija + V nastavitvah aplikacije ni ključa API + V nastavitvah aplikacije ni URL-ja API-ja + V nastavitvah aplikacije ni konfiguracijskega URL-ja \ No newline at end of file diff --git a/resources-spa/strings/strings.xml b/resources-spa/strings/strings.xml index fb8ef21..1cf43c5 100644 --- a/resources-spa/strings/strings.xml +++ b/resources-spa/strings/strings.xml @@ -26,4 +26,7 @@ Menú Sin conexión a Internet Error de recuperación del menú + Sin clave API en la configuración de la aplicación + No hay URL de API en la configuración de la aplicación + No hay URL de configuración en la configuración de la aplicación. \ No newline at end of file diff --git a/resources-swe/strings/strings.xml b/resources-swe/strings/strings.xml index bf32799..45f099d 100644 --- a/resources-swe/strings/strings.xml +++ b/resources-swe/strings/strings.xml @@ -26,4 +26,7 @@ Meny Ingen internetanslutning Menyhämtningsfel + Ingen API-nyckel i applikationsinställningarna + Ingen API-URL i applikationsinställningarna + Ingen konfigurations-URL i programinställningarna \ No newline at end of file diff --git a/resources-tha/strings/strings.xml b/resources-tha/strings/strings.xml index aa06e0f..ef40948 100644 --- a/resources-tha/strings/strings.xml +++ b/resources-tha/strings/strings.xml @@ -26,4 +26,7 @@ เมนู ไม่มีการเชื่อมต่ออินเทอร์เน็ต เมนูดึงข้อมูลผิดพลาด + ไม่มีคีย์ API ในการตั้งค่าแอปพลิเคชัน + ไม่มี URL API ในการตั้งค่าแอปพลิเคชัน + ไม่มี URL การกำหนดค่าในการตั้งค่าแอปพลิเคชัน \ No newline at end of file diff --git a/resources-tur/strings/strings.xml b/resources-tur/strings/strings.xml index d8574bf..e00cc00 100644 --- a/resources-tur/strings/strings.xml +++ b/resources-tur/strings/strings.xml @@ -26,4 +26,7 @@ Menü İnternet bağlantısı yok Menü Alma Hatası + Uygulama ayarlarında API anahtarı yok + Uygulama ayarlarında API URL'si yok + Uygulama ayarlarında yapılandırma URL'si yok \ No newline at end of file diff --git a/resources-ukr/strings/strings.xml b/resources-ukr/strings/strings.xml index aa0ecd7..75df959 100644 --- a/resources-ukr/strings/strings.xml +++ b/resources-ukr/strings/strings.xml @@ -15,7 +15,7 @@ @@ -26,4 +26,7 @@ Меню Немає підключення до Інтернету Помилка вибірки меню + У налаштуваннях програми немає ключа API + У налаштуваннях програми немає URL-адреси API + У налаштуваннях програми немає URL-адреси конфігурації \ No newline at end of file diff --git a/resources-vie/strings/strings.xml b/resources-vie/strings/strings.xml index 0386be7..c2a6afe 100644 --- a/resources-vie/strings/strings.xml +++ b/resources-vie/strings/strings.xml @@ -26,4 +26,7 @@ Thực đơn Không có kết nối Internet Lỗi tìm nạp menu + Không có khóa API trong cài đặt ứng dụng + Không có URL API trong cài đặt ứng dụng + Không có URL cấu hình trong cài đặt ứng dụng \ No newline at end of file diff --git a/resources-zhs/strings/strings.xml b/resources-zhs/strings/strings.xml index 42f14d9..f0a37d0 100644 --- a/resources-zhs/strings/strings.xml +++ b/resources-zhs/strings/strings.xml @@ -26,4 +26,7 @@ 菜单 没有网络连接 菜单获取错误 + 应用程序设置中没有 API 密钥 + 应用程序设置中没有 API URL + 应用程序设置中没有配置 URL \ No newline at end of file diff --git a/resources-zht/strings/strings.xml b/resources-zht/strings/strings.xml index 308aaf4..905c12e 100644 --- a/resources-zht/strings/strings.xml +++ b/resources-zht/strings/strings.xml @@ -26,4 +26,7 @@ 選單 沒有網路連線 選單取得錯誤 + 應用程式設定中沒有 API 金鑰 + 應用程式設定中沒有 API URL + 應用程式設定中沒有配置 URL \ No newline at end of file diff --git a/resources-zsm/strings/strings.xml b/resources-zsm/strings/strings.xml index 96a62b4..bc1a38b 100644 --- a/resources-zsm/strings/strings.xml +++ b/resources-zsm/strings/strings.xml @@ -26,4 +26,7 @@ Menu Tiada sambungan internet Ralat Pengambilan Menu + Tiada kunci API dalam tetapan aplikasi + Tiada URL API dalam tetapan aplikasi + Tiada URL konfigurasi dalam tetapan aplikasi \ No newline at end of file diff --git a/resources/strings/strings.xml b/resources/strings/strings.xml index 5296ac1..87c85f3 100644 --- a/resources/strings/strings.xml +++ b/resources/strings/strings.xml @@ -20,4 +20,7 @@ Menu No Internet connection Menu Fetch Error + No API key in the application settings + No API URL in the application settings + No configuration URL in the application settings diff --git a/source/Globals.mc b/source/Globals.mc index 10c699a..6420097 100644 --- a/source/Globals.mc +++ b/source/Globals.mc @@ -23,7 +23,7 @@ using Toybox.Lang; class Globals { // Enable printing of messages to the debug console (don't make this a Property // as the messages can't be read from a watch!) - static const debug = false; + static const debug = true; static const updateInterval = 5; // seconds static const alertTimeout = 2000; // ms static const tapTimeout = 1000; // ms diff --git a/source/HomeAssistantApp.mc b/source/HomeAssistantApp.mc index bfc4ffd..071d023 100644 --- a/source/HomeAssistantApp.mc +++ b/source/HomeAssistantApp.mc @@ -26,20 +26,25 @@ using Toybox.Timer; class HomeAssistantApp extends Application.AppBase { hidden var haMenu; - hidden var strNoInternet as Lang.String; - hidden var strNoMenu as Lang.String; - hidden var timer as Timer.Timer; + hidden var strNoApiKey as Lang.String; + hidden var strNoApiUrl as Lang.String; + hidden var strNoConfigUrl as Lang.String; + hidden var strNoInternet as Lang.String; + hidden var strNoMenu as Lang.String; + hidden var timer as Timer.Timer; function initialize() { AppBase.initialize(); - strNoInternet = WatchUi.loadResource($.Rez.Strings.NoInternet); - strNoMenu = WatchUi.loadResource($.Rez.Strings.NoMenu); - timer = new Timer.Timer(); + strNoApiKey = WatchUi.loadResource($.Rez.Strings.NoAPIKey); + strNoApiUrl = WatchUi.loadResource($.Rez.Strings.NoApiUrl); + strNoConfigUrl = WatchUi.loadResource($.Rez.Strings.NoConfigUrl); + strNoInternet = WatchUi.loadResource($.Rez.Strings.NoInternet); + strNoMenu = WatchUi.loadResource($.Rez.Strings.NoMenu); + timer = new Timer.Timer(); } // onStart() is called on application start up function onStart(state as Lang.Dictionary?) as Void { - fetchMenuConfig(); } // onStop() is called when your application is exiting @@ -51,7 +56,30 @@ class HomeAssistantApp extends Application.AppBase { // Return the initial view of your application here function getInitialView() as Lang.Array? { - return [new WatchUi.View(), new WatchUi.BehaviorDelegate()] as Lang.Array; + if ((Properties.getValue("api_key") as Lang.String).length() == 0) { + if (Globals.debug) { + System.println("HomeAssistantMenuItem Note - execScript(): No API key in the application settings."); + } + return [new ErrorView(strNoApiKey + "."), new ErrorDelegate()] as Lang.Array; + } else if ((Properties.getValue("api_url") as Lang.String).length() == 0) { + if (Globals.debug) { + System.println("HomeAssistantMenuItem Note - execScript(): No API URL in the application settings."); + } + return [new ErrorView(strNoApiUrl + "."), new ErrorDelegate()] as Lang.Array; + } else if ((Properties.getValue("config_url") as Lang.String).length() == 0) { + if (Globals.debug) { + System.println("HomeAssistantMenuItem Note - execScript(): No configuration URL in the application settings."); + } + return [new ErrorView(strNoConfigUrl + "."), new ErrorDelegate()] as Lang.Array; + } else if (System.getDeviceSettings().phoneConnected && System.getDeviceSettings().connectionAvailable) { + fetchMenuConfig(); + return [new WatchUi.View(), new WatchUi.BehaviorDelegate()] as Lang.Array; + } else { + if (Globals.debug) { + System.println("HomeAssistantApp Note - fetchMenuConfig(): No Internet connection, skipping API call."); + } + return [new ErrorView(strNoInternet + "."), new ErrorDelegate()] as Lang.Array; + } } // Callback function after completing the GET request to fetch the configuration menu. @@ -87,25 +115,12 @@ class HomeAssistantApp extends Application.AppBase { :method => Communications.HTTP_REQUEST_METHOD_GET, :responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON }; - if (System.getDeviceSettings().phoneConnected && System.getDeviceSettings().connectionAvailable) { - Communications.makeWebRequest( - Properties.getValue("config_url"), - null, - options, - method(:onReturnFetchMenuConfig) - ); - } else { - if (Globals.debug) { - System.println("HomeAssistantApp Note - fetchMenuConfig(): No Internet connection, skipping API call."); - } - new Alert({ - :timeout => Globals.alertTimeout, - :font => Graphics.FONT_SYSTEM_TINY, - :text => strNoInternet, - :fgcolor => Graphics.COLOR_RED, - :bgcolor => Graphics.COLOR_BLACK - }).pushView(WatchUi.SLIDE_IMMEDIATE); - } + Communications.makeWebRequest( + Properties.getValue("config_url"), + null, + options, + method(:onReturnFetchMenuConfig) + ); } } diff --git a/source/HomeAssistantMenuItem.mc b/source/HomeAssistantMenuItem.mc index 26c6f5b..0371c04 100644 --- a/source/HomeAssistantMenuItem.mc +++ b/source/HomeAssistantMenuItem.mc @@ -37,6 +37,7 @@ class HomeAssistantMenuItem extends WatchUi.MenuItem { } or Null ) { strNoInternet = WatchUi.loadResource($.Rez.Strings.NoInternet); + WatchUi.MenuItem.initialize( label, subLabel, @@ -59,10 +60,28 @@ class HomeAssistantMenuItem extends WatchUi.MenuItem { if (Globals.debug) { System.println("HomeAssistantMenuItem Note - onReturnExecScript(): Correct script executed."); } - WatchUi.showToast( - (d[i].get("attributes") as Lang.Dictionary).get("friendly_name") as Lang.String, - null - ); + if (WatchUi has :showToast) { + WatchUi.showToast( + (d[i].get("attributes") as Lang.Dictionary).get("friendly_name") as Lang.String, + 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)) { + new Alert({ + :timeout => Globals.alertTimeout, + :font => Graphics.FONT_MEDIUM, + :text => (d[i].get("attributes") as Lang.Dictionary).get("friendly_name") as Lang.String, + :fgcolor => Graphics.COLOR_WHITE, + :bgcolor => Graphics.COLOR_BLACK + }).pushView(WatchUi.SLIDE_IMMEDIATE); + } } } } @@ -77,10 +96,13 @@ class HomeAssistantMenuItem extends WatchUi.MenuItem { :responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON }; if (System.getDeviceSettings().phoneConnected && System.getDeviceSettings().connectionAvailable) { - var url = Properties.getValue("api_url") + "/services/" + mIdentifier.substring(0, mIdentifier.find(".")) + "/" + mIdentifier.substring(mIdentifier.find(".")+1, null); + // Updated SDK and got a new error + // ERROR: venu: Cannot find symbol ':substring' on type 'PolyType'. + var id = mIdentifier as Lang.String; + var url = (Properties.getValue("api_url") as Lang.String) + "/services/" + id.substring(0, id.find(".")) + "/" + id.substring(id.find(".")+1, id.length()); if (Globals.debug) { - System.println("URL=" + url); - System.println("mIdentifier=" + mIdentifier); + System.println("HomeAssistantMenuItem execScript() URL=" + url); + System.println("HomeAssistantMenuItem execScript() mIdentifier=" + mIdentifier); } Communications.makeWebRequest( url, @@ -90,15 +112,9 @@ class HomeAssistantMenuItem extends WatchUi.MenuItem { ); } else { if (Globals.debug) { - System.println("HomeAssistantMenuItem Note - executeScript(): No Internet connection, skipping API call."); + System.println("HomeAssistantMenuItem Note - execScript(): No Internet connection, skipping API call."); } - new Alert({ - :timeout => Globals.alertTimeout, - :font => Graphics.FONT_SYSTEM_TINY, - :text => strNoInternet, - :fgcolor => Graphics.COLOR_RED, - :bgcolor => Graphics.COLOR_BLACK - }).pushView(WatchUi.SLIDE_IMMEDIATE); + WatchUi.pushView(new ErrorView(strNoInternet + "."), new ErrorDelegate(), WatchUi.SLIDE_UP); } } diff --git a/source/HomeAssistantToggleMenuItem.mc b/source/HomeAssistantToggleMenuItem.mc index 82474de..8abef5c 100644 --- a/source/HomeAssistantToggleMenuItem.mc +++ b/source/HomeAssistantToggleMenuItem.mc @@ -87,7 +87,7 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem { if (System.getDeviceSettings().phoneConnected && System.getDeviceSettings().connectionAvailable) { var url = Properties.getValue("api_url") + "/states/" + mIdentifier; if (Globals.debug) { - System.println("URL=" + url); + System.println("HomeAssistantToggleMenuItem getState() URL=" + url); } Communications.makeWebRequest( url, @@ -99,13 +99,7 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem { if (Globals.debug) { System.println("HomeAssistantToggleMenuItem Note - getState(): No Internet connection, skipping API call."); } - new Alert({ - :timeout => Globals.alertTimeout, - :font => Graphics.FONT_SYSTEM_TINY, - :text => strNoInternet, - :fgcolor => Graphics.COLOR_RED, - :bgcolor => Graphics.COLOR_BLACK - }).pushView(WatchUi.SLIDE_IMMEDIATE); + WatchUi.pushView(new ErrorView(strNoInternet + "."), new ErrorDelegate(), WatchUi.SLIDE_UP); } } @@ -141,15 +135,18 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem { :responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON }; if (System.getDeviceSettings().phoneConnected && System.getDeviceSettings().connectionAvailable) { + // Updated SDK and got a new error + // ERROR: venu: Cannot find symbol ':substring' on type 'PolyType'. + var id = mIdentifier as Lang.String; var url; if (s) { - url = Properties.getValue("api_url") + "/services/" + mIdentifier.substring(0, mIdentifier.find(".")) + "/turn_on"; + url = Properties.getValue("api_url") + "/services/" + id.substring(0, id.find(".")) + "/turn_on"; } else { - url = Properties.getValue("api_url") + "/services/" + mIdentifier.substring(0, mIdentifier.find(".")) + "/turn_off"; + url = Properties.getValue("api_url") + "/services/" + id.substring(0, id.find(".")) + "/turn_off"; } if (Globals.debug) { - System.println("URL=" + url); - System.println("mIdentifier=" + mIdentifier); + System.println("HomeAssistantToggleMenuItem setState() URL=" + url); + System.println("HomeAssistantToggleMenuItem setState() mIdentifier=" + mIdentifier); } Communications.makeWebRequest( url, @@ -163,13 +160,7 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem { if (Globals.debug) { System.println("HomeAssistantToggleMenuItem Note - setState(): No Internet connection, skipping API call."); } - new Alert({ - :timeout => Globals.alertTimeout, - :font => Graphics.FONT_SYSTEM_TINY, - :text => strNoInternet, - :fgcolor => Graphics.COLOR_RED, - :bgcolor => Graphics.COLOR_BLACK - }).pushView(WatchUi.SLIDE_IMMEDIATE); + WatchUi.pushView(new ErrorView(strNoInternet + "."), new ErrorDelegate(), WatchUi.SLIDE_UP); } }