Temperature and movement notification


#1

What is wrong with this piston? (is not working)
I want to be notified when temperature changes or a movement has occurred.

Thank you!


#2

Force the subscription to the variables, click the condition and then the cog icon, change the subscription from Auto to Always.


#3

Like this?

Thank you.


#4

How does a contact sensor or a motion sensor have the ability to send a push notification?


#5

Yes, then test :slight_smile:


#6

@allrak, Push notification is one of the default commands where the line of code can be in any block.
(I usually use location, but any device will work)


Here is how I would create the piston:

I added a few comments in green so you can verify the right devices are in the right section. The only other edit you will need to do is the highlighted section. It should be typed out the exact name of your Motion Sensor in place of SimTempSensor.


#7

Yeah, guess I’ve always just used “location” as it made more sense.


#8

it also cleans up 4 lines of code each time we use location as well. (less clutter)


#9

Thank you. I think it is working now.


#10

Hello again. Based on your scripts I’ve made a first script that it is working and another optimized script less lines that is not working. I want to understand why the second “Sensor notification 2” script bellow do not trigger.

This is the script that works:

And this is the script that do not trigger when the first condition is pleased:

Does anyone know why the second script do not trigger?

Thank you.


#11

An IF inside another IF can be tricky…
I like my top level (far left) IFs to be a precise moment in time… (the trigger)

The things that are true for hours at a time, (ie: Location is Away) I usually place inside (or below) the trigger, and treat as conditions.


#12

So the first script can not be optimize more than it is? :slight_smile: (this is what I tried with the second script…)


#13

Well, that is a loaded question, LOL

Even months after I create a piston, I often go back inside to tweak my code a bit… But it looks very streamlined in your top picture right now, yes.

(although I suspect you will quickly get tired of all the notifications)