# Advice on delays and processing

**URL:** <https://discourse.nodered.org/t/advice-on-delays-and-processing/23024>\
**Category:** General\
**Created:** [12 March 2020 10:25 UTC](https://discourse.nodered.org/t/advice-on-delays-and-processing/23024 "2020-03-12T10:25:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bigglesuk](https://avatars.discourse-cdn.com/v4/letter/b/90ced4/32.png) [@Bigglesuk](https://discourse.nodered.org/u/Bigglesuk)\
**Post date:** [12 March 2020 10:25 UTC](https://discourse.nodered.org/t/advice-on-delays-and-processing/23024/1 "2020-03-12T10:25:46Z")

</div>

hi. I've got node red running monitoring my TV power to an Influx database. thats working fine, but i wanted to take it a step further. My TV keeps being left on but turned off (as in skys off but tv still powered up). I want to check a value periodically and if its been below a certain threshold for 10 minutes then turn the power to the TV off.

{"TotalStartTime":"2018-11-10T23:29:04","Total":694.259,"Yesterday":0,"Today":0.896,"Period":12,"Power":112,"ApparentPower":154,"ReactivePower":106,"Factor":0.73,"Voltage":253,"Current":0.609}

Can you help recommend the best way for me to capture the Power value, and periodically check to make sure its below that? Should i be using a function or other type?

thanks

Andrew

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [12 March 2020 10:54 UTC](https://discourse.nodered.org/t/advice-on-delays-and-processing/23024/2 "2020-03-12T10:54:11Z")

</div>

> [@Bigglesuk](#):
>
> {"TotalStartTime":"2018-11-10T23:29:04","Total":694.259,"Yesterday":0,"Today":0.896,"Period":12,"Power":112,"ApparentPower":154,"ReactivePower":106,"Factor":0.73,"Voltage":253,"Current":0.609}

The first thing I'd suggest is use a change node to extract the power value from your JSON

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/1/d1849c16fdb316afdcf5d05d87310acbc9f1ba98.jpeg)

---

<div class="post-metadata">

**Author:** ![Bigglesuk](https://avatars.discourse-cdn.com/v4/letter/b/90ced4/32.png) [@Bigglesuk](https://discourse.nodered.org/u/Bigglesuk)\
**Post date:** [12 March 2020 11:05 UTC](https://discourse.nodered.org/t/advice-on-delays-and-processing/23024/3 "2020-03-12T11:05:46Z")

</div>

Ah yeah, i have that bit down. I just copied the line that outputs to influx DB but i intend to get the solo variable value. its the next bit 🙂

---

<div class="post-metadata">

**Author:** ![Bigglesuk](https://avatars.discourse-cdn.com/v4/letter/b/90ced4/32.png) [@Bigglesuk](https://discourse.nodered.org/u/Bigglesuk)\
**Post date:** [12 March 2020 14:16 UTC](https://discourse.nodered.org/t/advice-on-delays-and-processing/23024/4 "2020-03-12T14:16:26Z")

</div>

I've achieved what i wanted in a slightly different way. I queried the InfluxDB for the max power over the last 15 minutes and if it was less than my threshold to set a Payload to OFF and send it to my MQTT Broker.

```auto
msg.query="SELECT max(Power) AS MaxPower FROM PowerMonitoring.autogen.SonoffPOW1 WHERE time > now() - 15m";
return msg;

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [11 May 2020 14:16 UTC](https://discourse.nodered.org/t/advice-on-delays-and-processing/23024/5 "2020-05-11T14:16:29Z")

</div>

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