# Inverter control ahoyDTU

**URL:** <https://discourse.nodered.org/t/inverter-control-ahoydtu/75122>\
**Category:** General\
**Created:** [13 February 2023 15:57 UTC](https://discourse.nodered.org/t/inverter-control-ahoydtu/75122 "2023-02-13T15:57:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dima2241](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@dima2241](https://discourse.nodered.org/u/dima2241)\
**Post date:** [13 February 2023 15:57 UTC](https://discourse.nodered.org/t/inverter-control-ahoydtu/75122/1 "2023-02-13T15:57:49Z")

</div>

Hello everyone, I have been trying to create a control system with node red for a few days, which is also my first experience with it.  
I would like to use ahoyDTU (communicates with an inverter via mqtt) to create a control that should calculate the following:

- If power consumption \> 0 then the inverter should take the value of the power consumption and add 10 to it.
- If feed-in \> 0, the inverter should reduce the value of the feed-in until it is 10.

Would someone please help me and point me in the right direction?

var calcLimit = flow.get("limit") + Number(msg.verbrauch) + 10;

var limit = Math.min(calcLimit, 1500);

flow.set("limit", limit);

msg.payload = limit;

return msg;

However, the value is increased continuously up to 1500.

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

---

<div class="post-metadata">

**Author:** ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)\
**Post date:** [13 February 2023 19:58 UTC](https://discourse.nodered.org/t/inverter-control-ahoydtu/75122/2 "2023-02-13T19:58:43Z")

</div>

Hi @dima2241  
& welcome to this forum.

With the data you provided, people trying to support you have to guess a lot. It's always better to post the json of the flow - rather than just a sniplet of code.

What I think I see: There's no functionality (in the data given) that reduces numbers; either you missed that when pasting the code here - or you don't have it implemented.

```auto
Additional tip:
You should format your code as "Preformatted text" by the </> button in the toolbar...
That makes it easier readable...

```

---

<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:** [14 April 2023 19:58 UTC](https://discourse.nodered.org/t/inverter-control-ahoydtu/75122/3 "2023-04-14T19:58:48Z")

</div>

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