MonitorTVConsoleSwitch

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



You can now download the smartapp at my store:

http://www.ecomatiqhomes.com/#!store/tc3yr




Summary

Monitor TV/Games console switches in the house during the day according to pre-defined schedules and weather conditions

Use Cases

  • You can easily limit the amount of TV/Game console time during the week to ensure that homeworks and studies get done.
  • For example, at my home, during the week, the TV linked to the console only turns on at 6h pm and shuts down at 7h30 pm. This ensures that all homeworks or chores are completed beforehand. Those schedule times were defined in consultation with the kids to avoid conflicts as much as possible.
  • Other access control parameters can be used such as weather conditions (raining/snowing, humidity index, min/max temperature thresholds).

Prerequisites

  • TV or Game Console hooked up to a ST-connected switch so that the smartapp can send the on/off commands to it.
  • ST WeatherStation such as this one (optional):

https://github.com/yracine/device-type.weatherstation2

Features

  • Flexible schedule definition: you can define up to 12 schedules for your home (weekdays, evenings, nights, weekends, etc.)
  • For each schedule, ST users can define the start & end times for the kids' TV or Game Console Access
  • You can set your schedules to run only for some ST hello modes (ex. 'Away', 'Home', 'Night', or your own customized hello modes)
  • For each schedule, you can define if the TV or Game Console Switch is also controlled by the weather conditions (ex. raining/snowing or minimum/maximum temperature or humidity thresholds may be additional criteria to turn on/off the TV/Game Console).
  • You can define a default behavior (ex. always on/off in general settings)
  • Multiple switches can be controlled at the same time!


Look & Feel

MonitorTVSwitchV2P1.jpg

MonitorTVSwitchV2P2.jpg

MonitorTVSwitchV2P3.jpg


Schedule Setup

MonitorTVSwitchScheduleSetup.jpg

MonitorTVSwitchScheduleDetailsP1.jpg

MonitorTVSwitchScheduleDetailsP2.jpg

MonitorTVSwitchScheduleDetailsP3.jpg

MonitorTVSwitchScheduleDetailsP4.jpg

MonitorTVSwitchScheduleDetailsP5.jpg




Troubleshooting

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

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


And, here are some basic explanations with screenshots.

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


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

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 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 mobile app, click on automations>smartapps in the bottom menu. The list of installed smartapps will then appear.


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

Issue #3: 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 new code into the IDE at:


https://graph.api.smartthings.com/ide/apps

Click on the smartapp that you want to update

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

And save & publish.


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

Issue #4: I've set up some schedules, but no schedule seems to be running or the smartapp does not seem to control my TV/Console Switches

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

a) On the last page (Notifications & Other Settings), set the following input parameter to true (at least at the beginning) to get detailed notifications on what the smartapp does.

You can change this setting later when it's no longer needed.

   section("Detailed Notifications") {
       input "detailedNotif", "Boolean", title: "Detailed Notifications?", metadata: [values: ["true", "false"]], required:false
   }

b) In Schedules setup, make sure to set the right day of the week and start & end times for each schedule.

            section("Schedule ${indiceSchedule}- Day & Time for the control settings on the selected TV/Console Switch(es)") {
               input (name:"dayOfWeek${indiceSchedule}", type: "enum",
               title: "Which day of the week to trigger the control settings?",
                   defaultValue:settings."dayOfWeek${indiceSchedule}",                 
                   multiple: false,
                       metadata: [
                           values: [
                               All Week',
                               'Monday to Friday',
                               'Saturday & Sunday',
                                'Monday',
                                'Tuesday',
                                'Wednesday',
                                'Thursday',
                                'Friday',
                                'Saturday',
                                'Sunday'
       input (name:"begintime${indiceSchedule}", type: "time", title: "Beginning time to trigger the zoned heating/cooling settings",
           defaultValue:settings."begintime${indiceSchedule}")
       input (name:"endtime${indiceSchedule}", type: "time", title: "End time",
           defaultValue:settings."endtime${indiceSchedule}")
   }

c) In the Schedules Setup, for each schedule, make sure that your ST hello mode is correctly associated to your schedule

You may not want to run your schedule for all routines, if so, make sure that the right ST hello mode is set.

   section("Schedule ${indiceSchedule}-Set for specific mode(s) [default=all]")  {
       input (name:"selectedMode${indiceSchedule}", type:"enum", title: "Choose Mode", options: enumModes,
   }


d) Use live logging in the IDE to do some live debugging

Go to https://graph.api.smartthings.com/ide/logs, and click on the smartapp at the top.

Look at the debugging trace to know why your schedule is not running or your vents are not adjusting, and correct the smartapp's parameters accordingly.


e) You may run the smartapp manually to test your schedules.

Click on the arrow icon on the smartapp in order to run it manually. You can check in the logs as indicated above to debug your scheduling issue.

You also can view all the detailed notifications sent to you in the IDE, by clicking on your location's notifications at:

https://graph.api.smartthings.com/location/list

By doing so, you will understand the smartapp's logic a little bit better and adjust your schedules' setup accordingly.

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

Issue #5: I've set up some schedules, but my schedules override each other and I don't have the right access control

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

In the smartapp, schedules can override each other, but you may want to define the generic ones (or default ones) first (schedules 1,2,3 to give access), and then, the specific ones after (ex. schedules 4,5,6 to restrict access) to set the right access controls.

Please follow the steps specified in 3) above in order to see the detailed logic followed by the smartapp.


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

Issue #6: I have the following error message in the IDE/live logging: 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