Turn on device for 20mins + change color of a lamp


#1

Hello, im a new user to ST and webCore trying to make my first project. Hopefully someone can push me into the right direction since i dont know where to start! Thanks.

This is what i wish to accomplish:

Push either a physical button (hue switch controlled by a smartapp) or virtual button (on Action tiles) and it will turn on an electrical device which is plugged into a TKBhome pocketsocket. After 20 minutes auto turn the socket off.
Aditionally i want a lamp in the room to change color to orange for aslong the pocketsocket is reporting power usage.
So i dont want the light to turn orange simply when a button is pushed and to stop after 20mins. I want the lamp to react on the actual power usage which seems like a more reliable source of info.
When theres no more power usage i want the light to jump back into its previous state and not switch off just.
The light i want to turn orange is a Philips hue light strip. I control it with an app called hue B smart.

Edit: Now im reading what i just wrote and thinking perhaps to turn the light orange when power usage is being reported should be 1 piston. And the on/off for 20mins is another piston on its own?


#2

It may seem obvious but have you confirmed your outlet reports power? Watch the meter with the light off. Then turn the strip on, what does it go up too? Does it hold steady at the power level? After turning it off does it go back to 0?


#3

hi, yes to al. The power outlets work like they should.


#4

Set up a piston like this. Gonna have to be pseudo code because I am not at home.

If button gets pushed
Then
With outlet (set TCP to never)
turn on
Wait 20 minutes
Turn off
End if
If outlet power rises above xx
Then
With hue light
Turn on
Set color
End if
If outlet power drops to/below XX
Then
With hue light
Turn off
End if


#5

Thanks for that setup Arkbar, that should get me started on this!

Would it be possible to build in some extra rule to make sure the light will warn me if the socket is reporting power usage?
Lets say by some glitch the socket did not turn off, but either the app or someone in the house did turn off the light.
Now i wont notice the socket is still on and will stay on. Could this be managed without checking every minute of the day? Maybe send a push message or something when power usage is being reported for longer as 30mins?


#6

Add another if statement

If power stays above 0 for 30 minutes
Then
Send notification
End if


#7

The code i placed above is working but still needs some changes. I have 2 problems.

  1. The light now also waits 20mins to turn dark orange. This should happen straight away when power usage is being read.
  2. If i press the button on my dimmer the piston does start. However after it finishes and turns off i cannot start the piston again by pressing the button. It only works once, but it should keep working everytime the button gets clicked.

I tried to change the order myself, but it stops working at all. Any tips?


#8

Make the first if statement asynchronous. Select the with statement on line 20 and set the TCP to never cancel.

Force a subscription on the if statements on lines 28 and 38.

You can do all this by clicking on the if/with and click the cog icon in the bottom right. Then find the appropriate settings.

The asynchronous it should clear up the issue with the color not setting. I don’t know why it won’t fire again but we can look at that if we fix the waiting issue


#9

How do i do this? I dont see that option when clicking the cogwheel


#10

Also cannot figure out how to add the “for 30 minutes” part


#11

Look for the trigger stays


#12

Thanks. I got that “stays” option implemented now. How to add the subscription?


#13

Click the if. It will open a dialogue. Look for the cog/gear icon in the bottom right. Change subscription from automatic to always


#14

But where can i do that? I clicked the IF, then the cogwheel. But i see nothing about subscription:


#15

Ok i think i got it already. i was clicking the actual “if”. Now i see the device in the “if” group has a subscription option.

Now i have the following problems i need to fix:

  1. The piston doesnt always start when button is pushed. Most of the times it doesnt.

  2. The piston does not turn off

  3. Since i have to spam the button to get the piston started im not sure if the orange light works correct. Spamming the button also means cycling through hue scenes. I did notice when i turn all lights off the orange light jumps back on in a second.