diff --git a/manifest.xml b/manifest.xml index 53c1466..1c5790f 100644 --- a/manifest.xml +++ b/manifest.xml @@ -63,6 +63,7 @@ + diff --git a/source/Globals.mc b/source/Globals.mc index 6420097..1769b2b 100644 --- a/source/Globals.mc +++ b/source/Globals.mc @@ -23,8 +23,8 @@ 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 = true; - static const updateInterval = 5; // seconds + static const debug = false; + static const updateInterval = 10; // seconds static const alertTimeout = 2000; // ms static const tapTimeout = 1000; // ms } diff --git a/source/HomeAssistantMenuItem.mc b/source/HomeAssistantMenuItem.mc index 42e1d99..6691ba3 100644 --- a/source/HomeAssistantMenuItem.mc +++ b/source/HomeAssistantMenuItem.mc @@ -93,6 +93,7 @@ class HomeAssistantMenuItem extends WatchUi.MenuItem { var options = { :method => Communications.HTTP_REQUEST_METHOD_POST, :headers => { + "Content-Type" => Communications.REQUEST_CONTENT_TYPE_JSON, "Authorization" => "Bearer " + api_key }, :responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON @@ -114,10 +115,10 @@ class HomeAssistantMenuItem extends WatchUi.MenuItem { method(:onReturnExecScript) ); } else { - var url = Properties.getValue("api_url") + "/services/" + mService.substring(0, mService.find(".")) + "/" + mService.substring(mService.find(".")+1, null); + var url = (Properties.getValue("api_url") as Lang.String) + "/services/" + mService.substring(0, mService.find(".")) + "/" + mService.substring(mService.find(".")+1, null); 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, @@ -125,7 +126,7 @@ class HomeAssistantMenuItem extends WatchUi.MenuItem { "entity_id" => id }, options, - method(:onReturnSetState) + method(:onReturnExecScript) ); } } else {