Controlling an output from Temperature with Notification

Hi All,

I'm a bit stuck with my first flow ever, I'm trying to switch an output based on temperature being above a setpoint and this all works as expected.

With the following debug output.

11/17/2021, 8:46:34 AM[node: 0dcd1af1fd2a15cf](http://10.1.1.50:8123/api/hassio_ingress/5XMITp0dfOkegIxKxmG2FaTmqN9H3-pfZdwxue67hUw/#)sensor.ewelink_th01_8858b423_temperature : msg.payload : string[4]

"26.1"

11/17/2021, 8:46:35 AM[node: 2394e5e1d13041d2](http://10.1.1.50:8123/api/hassio_ingress/5XMITp0dfOkegIxKxmG2FaTmqN9H3-pfZdwxue67hUw/#)sensor.ewelink_th01_8858b423_temperature : msg.payload : string[3]

"OFF"

As I now want to integrate some SMS alerting, which I also have sorted, I need to filter (perhaps using the filter component) to ensure that only one message for a particular state is sent rather than an ON or an OFF every 30 seconds. I only want to receive the one SMS.

Cheers,
Paul

Indeed the filter node is probably what you want

Maybe using a function block will help you

[{"id":"10d237f5abaeef12","type":"inject","z":"c991dbcde03824f2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"21","payloadType":"num","x":1074,"y":486,"wires":[["e086b16f5f5b1e3d"]]},{"id":"b36a7b4a0c534feb","type":"inject","z":"c991dbcde03824f2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"22","payloadType":"num","x":1076,"y":522,"wires":[["e086b16f5f5b1e3d"]]},{"id":"ed5785eff42dfac5","type":"inject","z":"c991dbcde03824f2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"23","payloadType":"num","x":1076,"y":558,"wires":[["e086b16f5f5b1e3d"]]},{"id":"bc69c06df7e46843","type":"inject","z":"c991dbcde03824f2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"24","payloadType":"num","x":1076,"y":594,"wires":[["e086b16f5f5b1e3d"]]},{"id":"da0e065ba252cac4","type":"inject","z":"c991dbcde03824f2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"25","payloadType":"num","x":1076,"y":666,"wires":[["e086b16f5f5b1e3d"]]},{"id":"eafc1f7be0fe2ba2","type":"inject","z":"c991dbcde03824f2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"26","payloadType":"num","x":1076,"y":702,"wires":[["e086b16f5f5b1e3d"]]},{"id":"7052d3e1ded26a82","type":"inject","z":"c991dbcde03824f2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"27","payloadType":"num","x":1076,"y":738,"wires":[["e086b16f5f5b1e3d"]]},{"id":"e086b16f5f5b1e3d","type":"function","z":"c991dbcde03824f2","name":"","func":"const t = flow.get('temperature') ?? {\n    'alarm': 25, //set temperature alarm here\n    'sms': false\n}\n\nlet alarm = {}\n\nif (msg.payload >= t.alarm && !t.sms){\n    alarm.payload = `send sms alarm ${msg.payload}`\n    t.sms = true\n    flow.set('temperature', t)\n    return [ msg, alarm ]\n}\n\nif (msg.payload < t.alarm && t.sms){\n    alarm.payload = `send sms no alarm, t stable ${msg.payload}`\n    t.sms = false\n    flow.set('temperature', t)\n    return [ msg, alarm ]\n}\n\nreturn [ msg, null]","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1260,"y":594,"wires":[["1ac7d78807bcc019"],["3686b9dbf1eff01b"]]},{"id":"1ac7d78807bcc019","type":"debug","z":"c991dbcde03824f2","name":"t","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1412,"y":576,"wires":[]},{"id":"3686b9dbf1eff01b","type":"debug","z":"c991dbcde03824f2","name":"alarm","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1412,"y":612,"wires":[]}]

to remove the set value

OK, I'll have a look at that one, thanks. Just need to work out how to import that function code, I'm sure there's a way just haven't had to do it yet :slight_smile:

Blockquote
Indeed the filter node is probably what you want

Yep, but I've looked at doing that and couldn't get it to work, likely because there are two streams coming in from the input, a true condition value and a false.

Where in your flow are you adding the node(s) to send the SMS?
How long does the requirement:

last? Forever?

What should happen if the state changed before the time limit ends?

Hi,

I'm looking at putting the SMS notification after I detect that the temperature has gone above the setpoint. Ideally, the temp would be above the setpoint for maybe 10 minutes before firing off an SMS message. There would be no further SMS while the temp remains over the setpoint. Once the temp drops below the setpoint, all would be reset and and over temp would result in another SMS being sent.

Cheers,
Paul

So let's say the set point is 50 and the temps come in as 30, 40, 50, 55 at this point you want an SMS messsage sent and nothing else for ten minutes, right?

But what happens if after 5 minutes, the temp drops to 30 (there are extreme changes I know) or rises to 100? As I read your description, no SMS message would be sent.

The best thing to do is draw up a flow chart laying out your requirements. Then you can get into the How to do it part.

Hi, extreme change in a short period of time wasn't a consideration because it simply won't happen that quickly.

So can it go over the set point and within 10 minutes drop bellow it?
What happens if it then goes back over the set point?

If it drops below the setpoint, things will reset and start over. Much like the post with the function block above shows.

So if the temp hovered around the set point you could get a message more than once in 10 minutes…right?

Can this not be handled simply with a Trigger node set to Send Nothing then after 10 minutes send the SMS, but use the below threshold detection to reset the trigger so nothing will be sent if it drops below the threshold?

1 Like

This case I may as well continue to use the function. I'm not worrying too much ab out the after 10 minutes requirement, it currently seems to work fine as is.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.