Need help with Overriding Piston


#1

1) Give a description of the problem
I created this piston for my living room lights to work off of motion. The issue I have is, on occasion, I like to dim the lights or turn them off while watching Tv. My current issue is,I use either the smart dimmer or the Smartthings App to dim or turn off the lights and they come right back on when motion is sensed.

2) What is the expected behaviour?
See above

3) What is happening/not happening?
Lights dimmed or turned off at smart dimmer or Smartthings app, come right back on when motion is sensed.

4) Post a Green Snapshot of the piston![image|45x37](upload://xK8WwMCzoD

kDrcB1Jf27yjtZ9bq.png)


#2

Here is the thread you seek.

The 1st piston there works with dumb switch / smart bulb combo
The 2nd piston there works with smart switch / dumb bulb combo


#3

I saw that thread and tried to make sense of it and I could not understand it at all. I also cant figure out how to import or export.

I created this code. Will this work? My goal with this is: when the physical switch is turn on or off, the switch will turn on or off and then pause the piston for 120minutes. then the piston will resume.


#4

This code rarely works:

temp

because most Device Handlers do not distinguish between physical and programmatic.


Honestly, I would re-read the first few posts from that link.
You can import by going to your Dashboard, then:

+ New piston
temp


Make sure you import the correct version:

  • The 1st piston there works with dumb switch / smart bulb combo
  • The 2nd piston there works with smart switch / dumb bulb combo

#5

I have tried doing the restore piston and it wont let me create the piston


#6

My concerns with the mentioned code is that it will only work to turn the light on indefinitely and wont revert back to the original motion sensing code and it wont turn the light off.

Also I dont understand the proggramatic statement in that code. Im a completely new to coding. I think I have an idea of how the variable works. And I might be able to use that to code witht he variables to pause the piston from my above code. But the proggramatic statement throws me for a loop.


#7

Correct. You are creating an “override” switch. It is manually turned on, and stays on until manually turned off. (although nothing is stopping you from creating a timer to automatically turn it back off) Once it is off, then the motion sensor resumes normal functions.


I avoid it, and always use “ANY interaction” like this:

temp

This is because, even though webCoRE is smart enough to handle it, very few devices report any difference between programmatic vs physical interaction.

The programmatic VARIABLE on that thread is @bangali’s creative workaround


#8

I am so confused by this now. This seems like it should be a very simple code that anyone with a smart switch and motion sensor would want. Yet it seems impossible to actually code. I honestly have no idea how to make this work and this is a basic function that I want all my switches to be able to do.


#9

Does this work? Basically if the motion sensor has the lights on, it sets the variable to true. If i then interact with the switch it will pause the piston set the lights how i want them, then resume the piston after 120 minutes.


#10

This did not work. I’m at a loss on this.


#11

Sorry, I am tied up with clients at the moment…

My advice would be to import one of the pistons from the first post on this thread.
(making sure you import the right version. Smart switch/dumb bulb, or visa versa)

It should be easy to tweak or customize later, but it helps to test it “as is” first.


#12

I tried the code from your first post. It didn’t work as it was supposed to. It didn’t lock any state in when the switch was toggled. It just continued to turn off if there was no motion. I got a code that’s semi working. It’s pausing the Piston but then the next code is to wait 60 seconds (testing) and then resume Piston. The piston freezes until I manually unpause it in the app.


#13

I have not posted any code on this. Instead, I referred you to an excellent thread written by @bangali.

I apologize, I do not have time at the moment to re-invent the wheel. I think you may get more exposure if you post in that thread. Dozens (if not hundreds) of people are currently using his pistons.


For what it’s worth, the reason your piston is failing is because once a piston is paused, it is 100% dumb. It cannot do anything. At all. Ever again. Until someone (or something) unpauses it.

This is why I never recommend pausing a piston to solve a problem.
There is always a better way.


#14

I tried posting for assistance on the forum thread you recommended. I had no luck. Is there anyway to hire someone to create pistons for me to make this work? Can I hire someone to be my smart home adviser and help me with this?


#15

I actually program SmartHomes for a living… If you can give me a day or two to get caught up with my current clients, I will gladly take a closer look. :sunglasses:


#16

I had a look at the other forum thread, limiting myself to the first post and your posts at the end. It is possible that there was something relevant to you in the couple of hundred posts in between, but I don’t think the pistons in the first post would do what you want.

As I understand it, what you would really like is for the motion sensing to butt out if you used the dimmer switch to turn them down, and ideally if you used the dimmer switch at all.

Although the two pistons in the other thread are supposed to cater for slightly different scenarios I am struggling to see what the extra code is actually achieving. I guess I am missing something. The bottom line is that if the light is off the piston can turn it on when motion is detected. If the light is on the piston can only turn it off if it turned it on. In other words if something other than the piston turned the light on it is going to stay on until something other than the piston turns it off. While it works and I can see why it is done that way, I personally prefer the idea of keeping the motion control as simple as possible and dealing with the twiddly bits elsewhere. It also doesn’t sound like it meets your requirements and I don’t think it is a good starting point.

My own requirement is to allow motion controlled lights to be forced on. I do that by using the real motion sensors in tandem with simulated motion sensors which I can set to active when I want the lights to stay on. It means I can keep my motion control automations nice and simple. The task of activating the simulated motion sensor is dealt with in other automations.

That isn’t directly useful to you but you might find an approach using virtual/simulated switches might suit, especially if you have a voice assistant around. Say you created a virtual switch named ‘Dimmer 1 Motion’. Your basic motion control piston can then use ‘if Dimmer 1 Motion switch is on’ as a restriction. You would then have motion control that could only do anything if that (virtual) switch is on.

It then becomes a matter of turning that switch on or off to enable or disable motion control. You can do that by the SmartThings app, ActionTiles, voice assistants, switches, buttons or you can come up with another piston or automation to set it. That piston might detect manual control as in your original requirements or perhaps there are ways of detecting the TV is on. Whatever you do, I’d keep it separate from your motion control piston.


#17

What I am looking to do is have the physical switch override any code for x amount of time. This is my fail safe for the instances that i want to override the automation code. Mainly its so my wife, inlaws, baby sitters, and anyone else visiting can operate the lights if they arent working as needed. Also it would be nice to override the lights when watching a movie or at night if I need to turn the brightness up with out having to open the app go into webcore and pause the pistons. Basically I want the light switches to work like light switches and the automation to fill in when the light switches arent being used. I know it seems crazy to want a light switch to work like … you know… a light switch, but that is my goal.


#18

Take your time.


#19

I wonder if setting the switches to trigger a scene would do what I want. … I might have to try this.