# Repeat last value if no value submited

**URL:** https://discourse.nodered.org/t/repeat-last-value-if-no-value-submited/76895
**Category:** General
**Created:** [24 March 2023 09:31 UTC](https://discourse.nodered.org/t/repeat-last-value-if-no-value-submited/76895 "2023-03-24T09:31:47Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![bgdev2015](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bgdev2015/32/67525_2.png) [@bgdev2015](https://discourse.nodered.org/u/bgdev2015)
#### Post date: [24 March 2023 09:31 UTC](https://discourse.nodered.org/t/repeat-last-value-if-no-value-submited/76895/1 "2023-03-24T09:31:47Z")

</div>

Hey @ll,

atm iam trying to readout my values from my Inverter. The Inverter shuts down if there isnt enought input from the Solar panls. At this point i want to send the last value that was readed since the inverter ist back online.

This is may actual Node:

 ![solar_wr](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/b/db6c9be3fb83c0f60e379216e23d59926c40e4e4.png)

To lookup for the Inverter iam pinging it and if there isnt any response i want to repeat the last value that was stored to influx-db.

If the Inverter is offline there should be stored a "0" in the Database for actpower, but it wont be stored. any suggestions what iam doing wrong? Or will InfluxDB delete the "0" for performance?

I'll hope someone can help me out^^

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [24 March 2023 09:41 UTC](https://discourse.nodered.org/t/repeat-last-value-if-no-value-submited/76895/2 "2023-03-24T09:41:33Z")

</div>

How do you determine if the inverter is off line?  
You should be able to use that to trigger a flow setting the data you want and sending it on.

---

<div class="post-metadata">

### Author: ![bgdev2015](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bgdev2015/32/67525_2.png) [@bgdev2015](https://discourse.nodered.org/u/bgdev2015)
#### Post date: [24 March 2023 09:44 UTC](https://discourse.nodered.org/t/repeat-last-value-if-no-value-submited/76895/3 "2023-03-24T09:44:59Z")

</div>

![ping](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/b/abb78323cfc63a070630fc3ca09758bc6bb74e91.png)

this way

i think that there could be a problem with the msg that should be send. Ill take a deeper look if the Inverter is offline.

But how can i repeat the last value if the Inverter ist offline? For maybe total\_produce.

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [24 March 2023 09:50 UTC](https://discourse.nodered.org/t/repeat-last-value-if-no-value-submited/76895/4 "2023-03-24T09:50:02Z")

</div>

So you know if it is offline so connect a `change` node to create the data you want in a msg and then connect it's output to the flow where it would send the data to the influx-db.

---

<div class="post-metadata">

### Author: ![bgdev2015](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bgdev2015/32/67525_2.png) [@bgdev2015](https://discourse.nodered.org/u/bgdev2015)
#### Post date: [24 March 2023 09:52 UTC](https://discourse.nodered.org/t/repeat-last-value-if-no-value-submited/76895/5 "2023-03-24T09:52:45Z")

</div>

It is if you look at the first Picture from my first post^^

Ill think it could be a problem with the format, for the datas that iam storing if the Inverter is online iam using this to convert it to numbers: $number(payload)

If iam selecting converting it to number directly it wont work

In the offline-method iam injecting a number directly maybe this can be the problem.

But the most common problem ist to repeat the value total\_produce since the inverter is back online

//EDIT

Easy explaination:

If the response of the ping is false i want to repeat the last sended value of total\_produced. This should be done since the Inverter is back online

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [24 March 2023 10:13 UTC](https://discourse.nodered.org/t/repeat-last-value-if-no-value-submited/76895/6 "2023-03-24T10:13:25Z")

</div>

> [@bgdev2015](#):
>
> If the response of the ping is false i want to repeat the last sended value of total\_produced.

How are you pinging the device and what result do you get if it is offline? You will need to store the data each time a reading occurs (look into flow context), then when you determine it os offline, retrieve the data you stored and send it thru.

not sure what you mean by

> [@bgdev2015](#):
>
> This should be done since the Inverter is back online

---

<div class="post-metadata">

### Author: ![bgdev2015](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bgdev2015/32/67525_2.png) [@bgdev2015](https://discourse.nodered.org/u/bgdev2015)
#### Post date: [24 March 2023 10:17 UTC](https://discourse.nodered.org/t/repeat-last-value-if-no-value-submited/76895/7 "2023-03-24T10:17:12Z")

</div>

Iam using the ping-node to send a ping to the Inverter, i dont know what should i explain about this.

If the inverter is online iam getting the ms as result, if its offline iam getting the boolean false.

If its online iam getting the status.html of my Inverter an reading out the needed informations.

If its off iam wanted to use the last sended value of total\_produce to repeat it since the inverter is back online.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [24 March 2023 10:19 UTC](https://discourse.nodered.org/t/repeat-last-value-if-no-value-submited/76895/8 "2023-03-24T10:19:16Z")

</div>

> [@bgdev2015](#):
>
> repeat it since the inverter is back online.

I think you mean -\> repeat it UNTIL the inverter is back online.

---

<div class="post-metadata">

### Author: ![bgdev2015](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bgdev2015/32/67525_2.png) [@bgdev2015](https://discourse.nodered.org/u/bgdev2015)
#### Post date: [24 March 2023 10:21 UTC](https://discourse.nodered.org/t/repeat-last-value-if-no-value-submited/76895/9 "2023-03-24T10:21:26Z")

</div>

yes my fail^^

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [24 March 2023 10:22 UTC](https://discourse.nodered.org/t/repeat-last-value-if-no-value-submited/76895/10 "2023-03-24T10:22:10Z")

</div>

Ok so you can test the result to see if if it is online or offline. So when it is online, you need to start the current reading in a context variable (see [Working with context : Node-RED](https://nodered.org/docs/user-guide/context)).  
Then when you find it is offline, you will retrieve the context data and send that to the database.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [24 March 2023 10:27 UTC](https://discourse.nodered.org/t/repeat-last-value-if-no-value-submited/76895/11 "2023-03-24T10:27:44Z")

</div>

/start/store/

---

<div class="post-metadata">

### Author: ![bgdev2015](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bgdev2015/32/67525_2.png) [@bgdev2015](https://discourse.nodered.org/u/bgdev2015)
#### Post date: [24 March 2023 10:30 UTC](https://discourse.nodered.org/t/repeat-last-value-if-no-value-submited/76895/12 "2023-03-24T10:30:08Z")

</div>

Ok, but without any good explaination that isnt 100% theoretical like the explaination on the site you linked i wouldnt understand how it works^^

Sry iam from Germany and my English isnt perfect, so such explainations like on the linked Site i dont understand to 100%

@dceejay  
your explaination isnt enought to understant anything sry

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [24 March 2023 10:32 UTC](https://discourse.nodered.org/t/repeat-last-value-if-no-value-submited/76895/13 "2023-03-24T10:32:46Z")

</div>

Perhaps all you need to do is use a Trigger node configured as below at the appropriate point in your flow.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/8/9846690806ecfd7c428699df377f0e0acfac9d2a.png)

That sends on the message each time one comes in, but if there is no input for 1 minute then it will resend the last one every minute. Adjust the timeout as appropriate obviously.

---

<div class="post-metadata">

### Author: ![bgdev2015](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bgdev2015/32/67525_2.png) [@bgdev2015](https://discourse.nodered.org/u/bgdev2015)
#### Post date: [24 March 2023 10:43 UTC](https://discourse.nodered.org/t/repeat-last-value-if-no-value-submited/76895/14 "2023-03-24T10:43:29Z")

</div>

ok i think this should be the answer, thanks for help.  
I'll mark it as solution if it works

---

<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: [7 April 2023 10:43 UTC](https://discourse.nodered.org/t/repeat-last-value-if-no-value-submited/76895/15 "2023-04-07T10:43:39Z")

</div>

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