# Manually write data to InfluxDB from UI

**URL:** <https://discourse.nodered.org/t/manually-write-data-to-influxdb-from-ui/33570>\
**Category:** General\
**Created:** [30 September 2020 13:43 UTC](https://discourse.nodered.org/t/manually-write-data-to-influxdb-from-ui/33570 "2020-09-30T13:43:50Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mckenzi](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Mckenzi](https://discourse.nodered.org/u/Mckenzi)\
**Post date:** [30 September 2020 13:43 UTC](https://discourse.nodered.org/t/manually-write-data-to-influxdb-from-ui/33570/1 "2020-09-30T13:43:50Z")

</div>

Hi, Looking for a way to write data to Influx from UI.

1. Enter value
2. Choose the date
3. Click button to write thae data.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/d/3dbf8400e045d259249988690153aad540ba4871.png)

Thx for any suggestion.

---

<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:** [30 September 2020 14:29 UTC](https://discourse.nodered.org/t/manually-write-data-to-influxdb-from-ui/33570/2 "2020-09-30T14:29:34Z")

</div>

What part don't you know how to do?  
For writing to influx there are influxdb nodes, search the node red flows web site.

---

<div class="post-metadata">

**Author:** ![Mckenzi](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Mckenzi](https://discourse.nodered.org/u/Mckenzi)\
**Post date:** [30 September 2020 14:34 UTC](https://discourse.nodered.org/t/manually-write-data-to-influxdb-from-ui/33570/3 "2020-09-30T14:34:41Z")

</div>

I know how to write to influx but i do not know how to join payloads from two nodes : "date picker" & "numeric" into one payload . Date from "Date Picker" should be my timestamp.

---

<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:** [30 September 2020 16:11 UTC](https://discourse.nodered.org/t/manually-write-data-to-influxdb-from-ui/33570/4 "2020-09-30T16:11:52Z")

</div>

Can you use the ui\_form with a submit button?

If not then you can use the Join node in Manual mode set to key/value pairs, after 3 message parts and Every Subsequent Message. Feed the two values and the write button into it, making sure they each have different topics. Look at the result in a debug node and you will see all the values in one message. The topic in that message tells you which input just changed, so add a Switch node set to only pass the button topic and you will get what you need each time the button is pressed.

---

<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:** [30 September 2020 17:04 UTC](https://discourse.nodered.org/t/manually-write-data-to-influxdb-from-ui/33570/5 "2020-09-30T17:04:16Z")

</div>

It would be safer to let the button to create a msg.complete message and use than to complete the join. That way you can change the other fields multiple times but only send when complete.

---

<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:** [30 September 2020 18:04 UTC](https://discourse.nodered.org/t/manually-write-data-to-influxdb-from-ui/33570/6 "2020-09-30T18:04:59Z")

</div>

That depends on the requirement, if the values are both to be entered each time then I agree, and this may well be what is required here. On the other hand, if it would be useful if the fields kept their values so that, for example, just the timestamp could be changed and the value left as is, then I think the solution I posted is better. The reason is that msg.complete empties the Join node's memory.

---

<div class="post-metadata">

**Author:** ![Mckenzi](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Mckenzi](https://discourse.nodered.org/u/Mckenzi)\
**Post date:** [2 October 2020 13:37 UTC](https://discourse.nodered.org/t/manually-write-data-to-influxdb-from-ui/33570/7 "2020-10-02T13:37:02Z")

</div>

Hi Colin,

I was trying to use ui\_form but faced a problem with date.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/6/769f1ef3817328f678c3f3478237658d7cb3c9f6.png)

When choose 06.10.2020 i've got an error about expected numeric value.In addition date showed  
in debug indow is wrong (-2h).

it there any way to fix it?

---

<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:** [2 October 2020 16:28 UTC](https://discourse.nodered.org/t/manually-write-data-to-influxdb-from-ui/33570/8 "2020-10-02T16:28:43Z")

</div>

How have you configured the form node? Also which node is generating the error? Click on the node I'd above the error and it should highlight the node.

---

<div class="post-metadata">

**Author:** ![Mckenzi](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Mckenzi](https://discourse.nodered.org/u/Mckenzi)\
**Post date:** [5 October 2020 06:19 UTC](https://discourse.nodered.org/t/manually-write-data-to-influxdb-from-ui/33570/9 "2020-10-05T06:19:12Z")

</div>

Hi Colin,

Flow looks like below:  
ui-form node has 2 fields (water, time). After inputing these two values and clicking submit button it generates payload (date is not correct, -2h offset).  
Error is generated by MQTT out node. Was trying different "Time Precision" but nothing was changed.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/0/903106fb6f1ab3c9199ded1478b918233aaca0aa.png)

---

<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:** [5 October 2020 08:44 UTC](https://discourse.nodered.org/t/manually-write-data-to-influxdb-from-ui/33570/10 "2020-10-05T08:44:32Z")

</div>

What timezone are you in?  
What timestamp do you want to put in the database? Is it the start of the day in the local timezone or the start of the day UTC or something else?

The reason for the error is that you are passing the influx node a string whereas it needs a timestamp in milliseconds (or whatever you have configured the precision to be). There are numerous ways to convert it, but one of those is to use a function node containing

```auto
msg.payload.date = new Date(msg.payload.date).getTime()
return msg;

```

That creates a javascript Date object by parsing the string and then converts it to its msec equivalent.

---

<div class="post-metadata">

**Author:** ![Mckenzi](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Mckenzi](https://discourse.nodered.org/u/Mckenzi)\
**Post date:** [7 October 2020 06:09 UTC](https://discourse.nodered.org/t/manually-write-data-to-influxdb-from-ui/33570/11 "2020-10-07T06:09:20Z")

</div>

Hi Colin,

Thnak you for your suggestion. Now everything works as expected. Adding funkction node with the following code fixed the timestamp problem. All data are stored correctlly in InfluxDB.

```auto
data = msg.payload.time;
time = new Date(data).getTime();
msg.payload = {
    "water": Number(msg.payload.water),
    "time": time,
}
return msg;

```

---

<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:** [7 October 2020 07:51 UTC](https://discourse.nodered.org/t/manually-write-data-to-influxdb-from-ui/33570/12 "2020-10-07T07:51:18Z")

</div>

For strictly correct javascript the variables should be properly declared

```auto
const data = ...
const time = ...

```

---

<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:** [21 October 2020 07:51 UTC](https://discourse.nodered.org/t/manually-write-data-to-influxdb-from-ui/33570/13 "2020-10-21T07:51:25Z")

</div>

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