My NextServiceMgr

The Unofficial SmartThings Blog
Jump to: navigation, search



Category: My Apps

Author:Yves Racine

ST Community handle: http://community.smartthings.com/users/yvesracine/activity

Company Link: http://www.ecomatiqhomes.com#!home/mainPage



If you like MyNextServiceMgr and related Next devices, please support the developer by clicking on the paypal link below:

https://paypal.me/ecomatiqhomes



Summary

MyNextServiceMgr: the smartapp is the Service Manager for all Next devices (Puck, Vent, HvacUnit, thermostat): it instantiates the Flair device(s) and polls them on a regular basis"

Supported Features

  • Multiple devices can be selected to be exposed to SmartThings.
  • Do a poll at regular intervals (input parameter)
  • Notify you if there is any issue with the ST/Flair connection (optional).
  • Can send summary reports via Ask Alexa and/or nofications about your Next devices' usage (weekly, daily).

Prerequisites

  • Nest devices fully operational and connected via wi-fi to Nest
  • SmartThings hub fully operational
  • Some ST basic skills to add custom DTH and smartapps (see troubleshooting section, item 1)
  • Use of the SmartThings classic mobile app for instantiation of the custom devices (only the basic attributes will display within the new Samsung Connect mobile app as ST is working on the required migration steps).

UI and integration setup workflow

MyNextManagerP1.pngMyNextManagerP2.png MyNextManagerP3.pngMyNextManagerP4.png MyNextManagerP4 (2).pngMyNextManagerP6.png MyNextManagerP7.pngMyNextManagerP8.png MyNextManagerP9.pngMyNextManagerP10.png MyNextManagerP11.pngMyNextManagerP12.png MyNextManagerP13.png

Code location: https://github.com/yracine/device-type-myNext/tree/master/smartapps

Instructions for installation (readme): https://github.com/yracine/device-type-myNext/blob/master/README.md

Troubleshooting

See troubleshooting section under the different Next devices


.................................................................................................................................

Issue #1: I don't know how to create a custom smartapp

.................................................................................................................................

See the explanations of a fellow community member here:

http://community.smartthings.com/t/faq-an-overview-of-using-custom-code-in-smartthings/16772 http://thingsthataresmart.wiki/index.php?title=Using_Custom_Code

And, here are some basic explanations with screenshots.

  • Point your browser to you SmartThings IDE for your country (i.e. http://ide.smartthings.com or whatever your shard is, refer to the prerequisites at the readme) and Log In.

Loginscreen.jpg

  • Once you are logged in, find the My SmartApps link on the top of the page. Clicking My SmartApps will allow you to produce a new SmartApp.

MySmartApps.png

  • Find the button on this page labeled +New SmartApp and click it.

+NewSmartApp.png

  • Since you already have the code in your computer’s clipboard, find the tab along the top section called From Code. In the area provided, paste (typically CTRL+V) the code you copied from GitHub. Click Create in the bottom left corner of the page.

NewSmartAppCreate.png

  • This will bring up another page, with the code now formatted within the IDE. If the code was copied correctly, there are no other steps except to save and publish the code. In the upper right corner of the page, find and click Save. Now, click Publish (For Me), and you should receive a confirmation that the code has been published successfully.

SavePublish.png

To enable OAuth, first find and click the App Settings button in the upper right corner of the page.

From here, find the OAuth section toward the bottom of the page.

OAuthBtn.png

Clicking the OAuth link will reveal a button labeled Enable OAuth in Smart App. Click this button. The screen will change, giving you a unique code for your Client ID and Client Secret. These are the foundations of the security of your app and should be kept secret. You do not need to memorize or write down these codes; nor do you need to add any other information to this page. OAuth simply needs to be enabled for

OAuth.jpg

.................................................................................................................................

Issue #2: I created the smartapp in the IDE, but I don't know where to execute it

.................................................................................................................................

For the initial setup, under the ST classic mobile app, click on the Marketspace item in the bottom menu, and then, on the smartapps link and finally, MyApps (last item in the list).

If you still do not see your smartapp, please make sure that you have published it in the IDE!


For any subsequent execution, under the ST classic mobile app, click on automations>smartapps in the bottom menu. The list of installed smartapps will then appear.


P.S. If you don't see your smartapp, it could be that you're not using the right shard for the installation. Refer to

https://community.smartthings.com/t/faq-how-to-find-out-what-shard-cloud-slice-ide-url-your-account-location-is-on/53923

Or the SmartThings documentation here:

http://docs.smartthings.com/en/latest/publishing/index.html#ensure-proper-location

.................................................................................................................................

Issue #3: java.lang.NullPointerException: Cannot get property 'X' on null object

.................................................................................................................................


Just update your smartapp by going through all the smartapp setup pages by pressing 'Next' till 'Done'.

The smartapp was recently modified to include some defensive code to ensure that the smartapp is rescheduled. This is intended to alleviate some of the ST scheduling issue as discussed in these threads:


http://community.smartthings.com/t/scheduler-and-polling-quits-after-some-minutes-hours-or-days/16997

http://community.smartthings.com/t/schedule-not-working/3895

http://community.smartthings.com/t/is-it-me-or-schedules-not-firing-this-evening/10176


.................................................................................................................................

Issue #4: java.util.concurrent.TimeoutException: Execution time exceeded 20 app execution seconds

.................................................................................................................................


ST has introduced some generic rate limiting rules for all smartapps and device handlers. For cloud-to-cloud integrations, these rate limiting constraints are sometimes too low, and this exception can be raised from time to time.

There are some threads about it in the ST community forum:

http://community.smartthings.com/t/rate-limiting-too-restrictive-max-execution-time-exceptions/17985

http://community.smartthings.com/t/execution-times-increasing/19979

http://community.smartthings.com/t/unschedule-api-execution-time-too-long/11232

.................................................................................................................................

Issue #5: I want to upgrade the code but I don't know how

.................................................................................................................................


Most of the time (unless specified otherwise), you just need to copy and paste the smartapp's code from the zip file.

Click on the smartapp that you want to update in the IDE.

Paste the code into the code window (and make sure to copy all the lines)

And save & publish.


.................................................................................................................................

Issue #6 - My new Ask Alexa's Message Queues are not showing up in the smartapp

.................................................................................................................................


You'd need to execute the MyNextServiceMgr smartapp under Automation/Smartapps in the ST mobile app by doing "Next" till "Done" to subscribe to the new AskAlexaMQHandler. The new handler will then be able to process any Queue refresh value from Ask Alexa.


You can then go to the AskAlexa smartapp, and make any queue changes... The updated queue values will be then sent to the smartapp.

................................................................................................................................

Issue #7: I want to be notified of any exceptions coming from ST and/or Nest

.................................................................................................................................

If you want to be notified of any serious ST/Nest exceptions, you can set the following flag to true in MyNextServiceMgr(in Other Settings -last page):


   section("Handle/Notify any exception proactively [default=false, you will not receive any exception notification]") {
      "Handle exceptions proactively?"
   }


The smartapp will then send you notifications when exceptions occur.


.............................................................................................................................

Issue #8: There is a groovyx.net.http.HttpResponseException: Too Many Requests exception in my logs

.............................................................................................................................

There are also variants of this message for devices: "(...) Nest Throtting in progress (...)" in the list of Events or the logs (IDE).

There could be different reasons why you have this exception thrown by Nest.

  • 1) Not using the caching in the smartapp

If you disable the following option in the smartapp:

   section("To refresh your current structures, don't use the cache [default=cache is used for better performances") {	
       "use of cached structures including devices?"
   }        

This means that every request to Nest will be sent without using any caching. This could be an issue as indicated in 2).

  • 2) Polling interval is too agressive for your use cases

If your polling interval is 1-5 minutes, you may encounter this exception as Nest can throttle your requests when too many are sent in a given timeframe. Nest APIs have 1 call per minute and 10 PUTs per hour limitations.

You may then need to increase the polling interval to 5-10 minutes, especially if you have many Nest devices under your account.



.............................................................................................................................

Issue #9: I'd like to uninstall My Next devices

.................................................................................................................................

a) Like any SmartThings device, first you'd need to unselect My Next device(s) from all smartapps and/or routines (ex. Amazon echo).

To know which smartapps are using My Next devices, go to

https://graph.api.smartthings.com/device/list (or whathever your shard is)

or click on the smartapps tab on the device itself under the ST mobile app.

b) Click on each of My Next devices instantied under your ST account

And note all smartapps under the list "In Use By".

c) Then, you'd need to unselect the device(s) from the smartapps or routines using the ST mobile app.

d) Finally, you can remove the MyNextServiceMgr smartapp by pressing on the corresponding 'button' inside it.


If you have any delete issues, you can also delete the devices directly from the ST or Samsung mobile by clicking on the device, pressing the 'gear button (upper right), and then remove at the bottom.


.............................................................................................................................


Issue #10: I want detailed Logging/Notifications or I want to enable Ask Alexa Notifications

......................................................................................................................................

In order to have detailed Logging/Notifications, you'd need to do the following:

  • a) Notifications & Other Settings Setup> On the last setup page, set the following flag to true
   "Detailed Logging & Notifications?"
  • b) Set the filtering level (ERROR, WARNING, DEBUG, TRACE): the TRACE level is the more detailed tracing you can get.
   "log filtering [Level 1=ERROR only,2=<Level 1+WARNING>,3=<2+INFO>,4=<3+DEBUG>,5=<4+TRACE>]?",required:false, metadata: [values: [1,2,3,4,5]]


  • c) To receive push notifications, answer 'Yes' to the following input parameter
   "Send a push notification?", metadata: [values: ["Yes", "No"]]


  • d) To receive the notifications configured above through Ask Alexa, set the following flag to true


   "Ask Alexa verbal Notifications?"


This way, you will get the same level of notifications (ERROR, WARNING, DEBUG,TRACE) verbally via the Ask Alexa smartapp.



...............................................................................................................................

Issue #11: I cannot create any objects under the new Samsung app

.................................................................................................................................


No custom DTHs can be created under the new Samsung mobile app for the moment as indicated in the prerequisites. You'd need to use the ST classic app to execute MyNextManager in order to create the Next devices. After creating the devices, follow the steps indicated in the installation pdf file included in the zip to force a refresh of the cache in order to make them appear correctly in the new Samsung app.


...............................................................................................................................

Issue #13: Some of my devices under the new Samsung app are disconnected

.................................................................................................................................


If some of your Next devices are disconnected under the new Samsung app, you may have created many of the same devices by executing MyNextManager many times... Under the new Samsung mobile app, you then need to clean them up by pressing the "edit" button next to your location and removing them.