Global variables to track the status of smartplugs


#1

1) Give a description of the problem

I am really just looking for some advice, I am really new to WebCore via Samsung smart Smartthings for around 2 weeks now and the learning curve has been pretty steep as I have never done any coding before but I do know my way around a windows PC and can write very basic batch scripts but I am in no way near being close to a coder by I am really eager to learn as it is interesting, Asides from those facts I have managed to accomplish most of the basic tasks that I wanted too.

A bit of back ground is that I have some smart plugs and hue bulbs with my hub and 2 of them are in my daughter’s bedroom, one is on her TV and one is on her PC Monitor, This is where I have the problem mostly but there is more to my set up, I am trying to automate night mode\home mode using pistons which I will show here:

The logic above assumes if any of the devices are on then then someone is at home as these are screens, I have an Alexa in my sitting room which I use to control powering on\off the living room devices at night time usually after 11PM

Now the problem comes as my daughter uses her remote it switch her TV off and usually just the standby button on her PC screen, the smart plugs drop to below 0W so I was using a piston to power these off when below 1W for 5 minutes, now the problem came here is if she didn’t use the TV or monitor the monitor went into standby if the screen saver came on the plug would be powered off every 5 minutes, due to this it means she needs to switch them back on but she does not have an Alexa nor does she have access to the easy plug itself as they are hidden so I tried to wrap some rules around it

The problem with above seems to be that if she goes to bed and the devices are off before the time is met there is no further events from the plug so the piston never runs.

I have been reading the wiki and what I would maybe like to try and achieve is to create a couple of global variables, {SmartPlugsOn} & {SmartPlugsOff} to keep track of what plugs are on and off in the hope that I could maybe build a piston to turn off any that are in the smart plugs off state, I am not sure if possible but I wanted each global variable to only list the device if the condition that is met is true, this seems like quite a complex thing to me to build as my knowledge is low hence why I am reaching out for a little support.

I would like to know if possible or if you guys think there is a better way of doing this?

Also happy to be pointed in the direction of reading material that would help me understand how to do above if possible.*

2) What is the expected behaviour?
AS there is no events from the plugs due to them being off before the time restriction is met no events are sent meaning the rule never runs for the plug, I am a novice at WebCore but it looks like it is waiting for an event to happen from a device before

3) What is happening/not happening?
The SmartPlugs dont power off as the power usage is at 0W before the piston can run

**4) Post a Green Snapshot of the piston![image|45x37] 1) Give a description of the problem
Picture is above with Description

5) Attach logs after turning logging level to Full
I dont have logs but can see there is never any events sent from the plugs when the devices that are plugged into them are in standby mode.

Sorry for such the long post but trying to give as much detailed information as possible.
(Edited the Post as copied in same paragraph twice)


#2

After having a little think over this I think the solution is to add to the Home & night modes to monitor the power usage rather than for the switch being on or off.

Have changed it to the following:

Will run some tests later but would still be good to know about the variable question above.
If I have a custom variable like {SmartPlugsOn} & {SmartPlugsOff) if I can have a device added\remove when the switch state changes from on to off


#3

Didn’t go thru the whole post - sorry - but in your second version, you have 2 triggers.
Can you post the green snapshot of the second one, because in this screen capture I can’t see the lightning bolts.

I believe those 2 triggers are the main problem.

EDIT : Sorry, you used OR between the IFs, my bad I didn’t see that.


#4

Hi Ike,

Originally I did not have those 2 triggers I only added them today, I noticed that it should be or rather than and too so changed that, have re-attached them both.

Home ModeActivation from Night Mode

The Night Mode Activation


#5

Hi Derek

If you don’t mind writing down what you want to accomplish (in real life) STEP by STEP
me or someone else would be happy to write you a draft here.


#6

Hi Ike,

With above examples I am trying to automate home and night mode. In home mode I have different lighting scheduled than I do in night mode, I have a some motion sensors too, so for instance if the 2 motion sensors in my hall are activated in night mode one followed by the other then it the living room lights will power on @ 1% brightness where as in home mode they will power on at 30% brightness. its for if someone gets up in the middle of the night.

So I am trying to automate going into night mode,

If everything in the device lists is either powered off (SmartPlug State off) or in a low power state (SmartPlug Consuming Less than 1W) and the time is after 23:00 and location is set to home mode then night mode will be activated

Home mode activate will happen after 6am and should be opposite of above, if any of the switches are powered on then activate home mode.

So the rules in my head are night mode will only be activated between 23:00 and 05:00 or 06:00 not quite decided yet.

I have quite a few plans as I start to add to my smart home equipment but really just trying to set the fundamentals in place.

Edit:I should add witrh above I have a couple of different models of plugs, some are basic WiFi one off that I am controlling via IFTTT via a virtual swtich some some need to be just on and off rules as they dont have power monitoring via smart things.


#7

An observation before you get too far underway:

Normally, “Night mode” will change the bulbs… You are trying to do the opposite by using the bulbs to change the mode. (and of course, the mode will also affect the bulbs)

I generally advise to avoid this type of looping.

IE: Whatever is used to determine the mode should not be affected by the mode later.


#8

What Mechanism would you recommend for triggering night mode?


#9

There are a few options… Everyone sets it up differently, so I should ask first:

In your house, does Night mode represent that everyone is sleeping, or does it mean that the sun is down and lights should act differently, etc…?


#10

In my house it would represent everyone is sleeping.

this is why I was trying use a rule to say if all of the lights and sockets are off then change to night mode.


#11

In my house, the sleeping times can be very different every day.
(which makes this one a bit tricky to catch reliably)

For spontaneous events like this, I like to use a dedicated method… but I realize that is entirely dependent on the available devices & the user’s habits.

(For unpredictable events, my recommendation is to use voice commands, such as “Alexa, Goodnight”, or “OK Google, Goodnight”)

I know you said that she does not have Alexa, but a dedicated button (less that $10) also works well for this. One press and all her lights can go into night mode.

Another option is to put a button on her phone that does the same thing.

If you have an extra $30, then ActionTiles may be what you are seeking…


Alternatively, if you study her habits, we can usually use a current device to determine if it is bed time.

Here is a little example:

If I know that bedtime is always between 10pm and midnight, and brushing my teeth is always one of the last things I do before bed, then I can make a piston like this:

IF MedicineCabinet changes to open
Then
    IF Time is between 10pm and 11:59pm
    Then
        Set Location Mode to Night
    END IF
END IF

Pro Tip:

Honestly, I think everyone should take the time to create a personalized “Good Night” piston…

For example, one command can execute the following sequence:

  • Lights can be gradually turned off (as you make your way to bed)…
  • Overnight weather can be read outloud (if you wish)…
  • Door locks can be checked and confirmed…
  • Windows can be checked to make sure they are closed (if bad weather is approaching)…
  • Thermostat can change into Night mode…
  • and so much more!

#12

I guess, another way of looking at this:

Instead of manually turning off 9 devices to trigger Night mode…
I recommend one method (command) programmed to change mode, turn off all 9 devices, and perform other “clean-up” logic.


#13

I do use a bedtime Piston, but it does not touch any of her devices as I cannot always predict she wont be watching her TV with it on sleep or something

Good shout on the button but this is the sort of thing she will forget to press or if she fall asleep while her TV is on say 60 minutes sleep mode and she fall asleep, again it would be missed, part of the reason I am trying to automate it, I am sure it will be possible just need to keep working at it I think.

I was hoping there was a way to refresh the Socket without toggling the power on\off but ran through all the options in Webcore last night and the toggle option is the only one that would refresh the event.

Currently only have lights, sockets and motion sensors, plan to add more to it as I go, I am only 2 around weeks in at the moment.