Power on/off lights based on TV state

Hi, below is the scenario i want to automate. I took a look around and found an app where I can switch off the lights when TV is turned on but couldn’t find any to turn the lights back on when TV is powered off.

TV is powered on i.e. Aeon Power Meter Switch detects power is drawn.
If a particular switch (Say - Switch A) is in ON state, turn it off.
TV is powered off i.e. Aeon Power Meter Switch detects 0W.
Turn on Switch A (this should only happen during a certain time period , say between Sunset and Sunrise).

Is there any app that already does this as I am not very good with coding apps yet.

Thanks for all the help!

Maybe this?

I haven’t used it but just by reading it’s description it may work.

Smart Lighting app will do that.

Select which lights to control (turn ON): Switch A
What do you want to do…select Turn ON
Select Trigger: Switch (if your Aeon Power Meter doesn’t turn off, then you can set a virtual switch that flips on with power consumption and off when 0W)
Which: your TV switch
Turn on lights when: Turned OFF

Thanks, I thought of this as well. I could find an app in Energy management that would turn off a virtual switch when power > 0W, but couldn’t find any that would turn that virtual switch back on when the power consumption is 0 again.

So basically, I could find a way to turn of the Switch A when TV is powered on but couldn’t find any way yet to turn them back on when TV is powere off ( consumption = 0W)

Thanks for the link! I believe this does the same thing as Energy Saver app i.e. turn off the switch when power consumption exceeds a threshold but couldn’t find any to turn the switch back on when it drops to 0W again.

Give it a try to the app that @mattjfrank mentioned, it does sound like it would do what you need. If that doesn’t work, I have other ideas :smile:

The app description does say it does what I need but when I installed the app it does the same as Energy Saver app i.e. turn off the switch when power consumption exceeds a threshold but there is no option to turn it back on when its 0W :frowning:

1 Like

Try this then (assuming you know how to install in IDE, if not, let me know and I’ll help you)…

Copy/paste the following in IDE


  • Energy Saver
  • Copyright 2014 SmartThings
  • Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except
  • in compliance with the License. You may obtain a copy of the License at:
  •  http://www.apache.org/licenses/LICENSE-2.0
  • Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
  • on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
  • for the specific language governing permissions and limitations under the License.

name: “Energy Saver”,
namespace: “smartthings”,
author: “SmartThings”,
description: “Turn things off if you’re using too much energy”,
category: “Green Living”,
iconUrl: “https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet.png”,
iconX2Url: “https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet@2x.png”,
iconX3Url: “https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet@2x.png

preferences {
section {
input(name: “meter”, type: “capability.powerMeter”, title: “When This Power Meter…”, required: true, multiple: false, description: null)
input(name: “threshold”, type: “number”, title: “Reports this…”, required: true, description: “in either watts or kw.”)
section {
input(name: “switches”, type: “capability.switch”, title: “Turn ON These Switches”, required: true, multiple: true, description: null)

def installed() {
log.debug "Installed with settings: ${settings}"

def updated() {
log.debug "Updated with settings: ${settings}"

def initialize() {
subscribe(meter, “power”, meterHandler)

def meterHandler(evt) {
def meterValue = evt.value as double
def thresholdValue = threshold as int
if (meterValue == thresholdValue) {
log.debug "${meter} reported energy consumption equals ${threshold}. Turning on switches."

Thanks will try it out. But on going over it isn’t it the same as Energy Saving app i.e. turn off on exceeding power consumption? I didn’t see turn on option when power consumption is low again. Or am I missing something here :frowning:

All you need to change is this : if (meterValue == thresholdValue). Now if you set the power consumption to “0”, then when your Aeon reaches 0 it turns off whatever you selected to “turn off”…and as I was writing this, is not that hard to turn it around and instead of “turning off” the selected switches you can make it turn them on (so you don’t have to use a virtual switch)

UPDATE: I just turned the code around…switches.on()…it should turn your lights on when Aeon reaches 0…

Yea my app will watch the power draw of a supported device and turn a switch on of off based on that.

thanks! let me try that out. Also could you tell me how to add time duration to the app? like do it only between sunrise/sunset? Sorry, but not good at writing apps yet :frowning: