Specific time for bulb to turn on and dim when dog needs to be fed, otherwise normal on/off with motion


#1

1) Give a description of the problem
Pantry smart light, normal motion on/off behavior. Be a specific dim level/color between specific times to show if the dog needs to be fed based on dog food container being opened. Turn off after dog container has been opened.

2) What is the expected behaviour?
Have a smart bulb in my pantry that turns on and off with motion. I want it to dim to 30% and turn on (ordered a color bulb so I can use colors instead) when my virtual switch “Toby Fed” is off between 6:30 and 10:00 (am and pm), and while this specific action is on, disable the motion on/off until the dog food container has been opened which turns on "Toby Fed’ virtual switch. Upon food container being opened, resume normal on/off motion operation.

3) What is happening/not happening?
While I have the light dimmed to show the dog needs to bed, the on/off motion core is still being activated which then doesn’t leave the light on to show dog needs to be fed.

**4) Post a Green Snapshot of the piston![image|45x37]

Any help would be appreciated! I got this to work where I can ask google home “has toby been fed?” and it’ll tell me if the virtual switch is on/off, but I’d rather have an easy light showing so the kids know to feed the dog.


#2

Here is a great thread for feeding fish that is very similar…
(might give some inspiration)

Note: The variable over there is similar to your “Toby Fed virtual switch” over here…


#3

Thank you! Will check that thread out :slight_smile: Appreciate the response!


#4

So think I got the portion working where I’ll have the light dim to specific level (change color when I get new bulb).

Now I’m wondering is… how to disable the motion on/off of the Pantry Light while the specific dim/color is activated while TobyFed (Switch 9) is off. That way it’ll stay a specific color/dim level until the dog is fed. And then after the dog is fed, go back to normal motion control.


#5

Where do you control this part? is it a webcore piston or something else?


#6

It’s in the same piston pasted above. The first 2 IF statements are the on/off motion control for the pantry light.

And then the next IF/THEN/ELSE is where I have the dog fed control


#7

ohh ok ok since you used IS instead of CHANGES to, I thought it might be some where else.

my two cents would be using a PHASE system - which I started using after my friend @WCmore cmore here showed me. (We call it PHASE system, so it’s a made up name))

Basically if a couple devices must BEHAVE differently under different situations, how the behavior will change is determined by globalvariables.

I have to get off the computer now but I can post a couple pistons to show you in an hour.


#8

*bites his tongue*


#9

That’d be great! I actually did change it to “changes to” in the 3rd post in this thread after seeing the fish food example. Will edit my main post with my updated code.


#10

in your case you can use the motion detector as the main trigger.
and in your second piston you can use the lid (the virtual switch) as a trigger
if you need to add more scenarios in the future you might want to go to global variable route because with your virtual switch you have only ON / OFF option.

Can you do all in a single piston, I guess you can but in my experience it’s better to have seperate and simple pistons rather then fitting everything in a single piston.

Piston #1

IF motion sensor changes to active (This is a one big IF block)
       Then
       IF virtual switch toby fed is OFF (that means regular lights on/off activity - this is a nested IF block)
           Then 
           With lights turn on 
           do this do that
       IF virtual switch toby fed is ON (that means toby needs to be fed)
           Then 
           With lights turn on 
           do this do that (Stay on etc)

 IF motion sensor changes to INACTIVE (motion stoped)
             Then
             IF virtual switch toby fed is OFF
             Do this do that
             IF virtual switch toby fed is ON
             Do this do that

Now second piston that controls the virtual switch.

IF the lid changes to OPEN
then 
With virtual switch Toby Fed
Do turn OFF

Everyday at XYZ time 
With virtual switch Toby Fed
Do turn ON

#11

Okay so I do actually have the 2nd piston that controls TobyFed like yours, that was my fault for not mentioning that!

But that 1st piston does look like it will work! I just didn’t know how to word it correctly like that for some reason. Will implement these in my piston and see how it works!

Thank you!


#12

As I’m going through and making this piston, does the 2nd nested IF in the motion sensor active mean when Toby needs to be fed, that the light will only turn on and for example, be red, when it detects motion and then stays on? I was trying to have the light turn on regardless of motion when dog needs to be fed.

Ooooo actually I just thought of something, can I instead of nesting whether the Toby Fed is Off/On in the IF motion sensor is active… nest the motion sensor active/inactive inside IF Toby Fed is Off/On. So something like:

IF TobyFed is Off
Then
IF motion sensor changes to active
Then Pantry Light Turn On

IF TobyFed is Off
Then
IF motion sensor changes to inactive
Then Pantry Light Turn Off

IF TobyFed changes to On
Then
Turn Pantry Light to Red

IF TobyFed changes to Off
Then
Turn Pantry Light Off

And just leave it at those 4 IF statements? So,

  1. First IF would be normal motion pantry light turn on because Toby doesn’t need to be fed
  2. Second IF would be normal motion pantry turn off because Toby doesn’t need to be fed.
  3. Second IF would turn the pantry light on Red when Toby needs to be fed (based on time I set on the other automatic TobyFed piston)

Does that make sense? Updated code below.


#13

to get the best results from webcore, FIRST TRIGGER and then CONDITION(S)

in your piston (I’m not a coder but) using condition as a trigger will cause tons of load on your piston.
I’d say read the following instructions.


#14

Hmm okay, I think after reading that I made it more based on triggers than condition. How does this look?


#15

looks good
here is another question I have though,
is this switch 9 the lid of the feeding container?
IF so, when someone is moving in the room the piston will be executed and the switch turning ON/OFF will be all mixed up.

Test this one, if you run into problems, don’t be afraid of creating another piston…

edit : As I mentioned before, I’m not one of the pros here. I am a very very advanced user but that’s all. So i wouldn’'t want to steer you to a wrong direction.
If anyone wants to correct my assumptions please feel free to do so.


#16

Switch 9 is actually TobyFed virtual switch. I have the dog food container switch turn on/off the virtual switch that way i can have the virtual switch turn on/off independently also based on when the dog needs to be fed.


#17

so far everything is working good with this new piston. the only issue I’ve come across now is when the light is Red (that dog needs to be fed) and someone feeds the dog and the TobyFed virtual switch is turned off, it takes maybe 3-5 min before the motion on works again. Not sure why the delay is happening between after feeding the dog and then going back to normal operation.


#18

I’m not good at understanding delays, maybe you should post your logs here so one of the pros can take a look at it.
But my money is still on the “single piston is dealing with 2 devices as a trigger”