# Pv Overload with batterystorage ( if then else)

**URL:** <https://discourse.nodered.org/t/pv-overload-with-batterystorage-if-then-else/48572>\
**Category:** General\
**Created:** [19 July 2021 10:21 UTC](https://discourse.nodered.org/t/pv-overload-with-batterystorage-if-then-else/48572 "2021-07-19T10:21:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dosepower](https://avatars.discourse-cdn.com/v4/letter/d/73ab20/32.png) [@Dosepower](https://discourse.nodered.org/u/Dosepower)\
**Post date:** [19 July 2021 10:21 UTC](https://discourse.nodered.org/t/pv-overload-with-batterystorage-if-then-else/48572/1 "2021-07-19T10:21:54Z")

</div>

Hey im new to node red and have some questions about if then. i only coded some scripts in auto it v3.  
can maybe someone correct my function.

```auto
if msg.carpluged = 1 & msg.socvartabattery > 75% & msg.PVoverload = 1 then
if msg.Netzpower => 500 then
msg.load = msg.currentAmps + 500
msg.payload = {"current": msg.load}
else
if msg.Netzpower => -500 & msg.currentAmps > 6500 then
msg.load = msg.currentAmps - 500
msg.payload = {"current": msg.load}
endif
endif
else
msg.payload = {"current":6000}
endif

```

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [19 July 2021 10:40 UTC](https://discourse.nodered.org/t/pv-overload-with-batterystorage-if-then-else/48572/2 "2021-07-19T10:40:27Z")

</div>

Node-RED is a "low code" programming tool. Most or all of your script can be done with the basic switch, change, trigger etc nodes.  
Or you could translate it into Javascript and use a function node.

---

<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:** [19 July 2021 10:56 UTC](https://discourse.nodered.org/t/pv-overload-with-batterystorage-if-then-else/48572/3 "2021-07-19T10:56:31Z")

</div>

I recommend watching this playlist: [Node-RED Essentials](https://www.youtube.com/playlist?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6). The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [19 July 2021 11:06 UTC](https://discourse.nodered.org/t/pv-overload-with-batterystorage-if-then-else/48572/4 "2021-07-19T11:06:38Z")

</div>

> [@Dosepower](#):
>
> ```auto
> if msg.carpluged = 1 & msg.socvartabattery > 75% & msg.PVoverload = 1 then
> if msg.Netzpower => 500 then
> msg.load = msg.currentAmps + 500
> msg.payload = {"current": msg.load}
> else
> if msg.Netzpower => -500 & msg.currentAmps > 6500 then
> msg.load = msg.currentAmps - 500
> msg.payload = {"current": msg.load}
> endif
> endif
> else
> msg.payload = {"current":6000}
> endif
> 
> ```

something like below

```auto
if (msg.carpluged === 1 && msg.socvartabattery > 75 && msg.PVoverload === 1){
   if (msg.Netzpower >= 500){
       msg.load = msg.currentAmps + 500
       msg.payload = {"current": msg.load}
   }else if (msg.Netzpower >= -500 && msg.currentAmps > 6500){ // this may want to be <=
       msg.load = msg.currentAmps - 500
        msg.payload = {"current": msg.load}
   }else{
       msg.payload = {"current":6000}
   }
}
return msg;

```

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [19 July 2021 21:51 UTC](https://discourse.nodered.org/t/pv-overload-with-batterystorage-if-then-else/48572/5 "2021-07-19T21:51:23Z")

</div>

Maybe tell us what you are trying to achieve here ?

I hope to god you are no really playing around with 6500 amps and really mean milliamps i.e. 6.5 amps ?

Craig

---

<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:** [17 September 2021 21:52 UTC](https://discourse.nodered.org/t/pv-overload-with-batterystorage-if-then-else/48572/6 "2021-09-17T21:52:00Z")

</div>

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