question

daza avatar image
daza asked

Octopus Saving Session

Can anyone tell me how to crate something that would automatically log me into the saver session, Ive looked on line and found one and imported it into Node-RED but it says there are a few values that it does not know what they are one of which is the 30min interval in the flow.

What i want t do is setup a discharge in the session interval with a proviso that it leave 30% of the battery if it starts @ 1700 -1800 or 1730 - 1830 if it starts at 1600 - 1700 it should leave 40%

This is more than I've ever done and very far out of my comfort zone. Is there anyone that is on the advance level or any level that can help?, As I'm not even on a level lol




ess dischargingoctopus
3 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

matt1309 avatar image matt1309 commented ·

Hi @Daza


I've not messed with Victron's Dynamic ESS nodes so not sure if this functionality is already built in.


However you can write something like the below in javascript (node red function node).

How i would do it is get SoC node and pass that into a function node. Then use code something like the below. (I've not tested this so please double check it).




//setting up variables
var currentTime = new Date();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
var soc = msg.payload //This will get data from the SoC node input. 



if(hours == 17){ //if time is between 5pm (ie hour is 17)

    if( soc > 30 ){ //if state of charge is greater than 30%

         //some code to set grid set point to negative/discharge 

    }else if(soc <30){

     //code to set grid setpoint back to 0 or whatever default setting is
    }

} //then if you wanted other times you could add more else statements here. 


At the moment the only input into the function node is SoC. You could however add multiple input data and make the if statements more complex. Or even have node red do other checks like only sell if energy provider rate is above $x. However I imagine dynamic ess already has more functionality built out for stuff like that.

But happy to help with the JS if needed (I'm far from good at it but can get by with the help from a chatgpt/similar tools).



1 Like 1 ·
daza avatar image daza matt1309 commented ·
Mate that is awesome thank you, but I’m pulling breaks up here I think node red is beyond me. But Dynamic ESS works for me just to sell when I want to and then turn it off. But thanks mate truly the victron community is truly awesome!!
0 Likes 0 ·
Show more comments
6 Answers
daza avatar image
daza answered ·

Victron have kind-of done it in the beta VRM (Dynamic ESS) all I have to do is set an alarm to sell now so complicated NodeRED not needed for what I want to do.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

daza avatar image
daza answered ·

@matt1309 not the same but had a little tinker so I can see my whole install from one view I’ve been playing with home assistant and put the Victron inside that, no real controls but IMO a good looking UI and everything viewable,

img-4473.jpeg



img-4473.jpeg (651.7 KiB)
1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

matt1309 avatar image matt1309 commented ·
Looks awesome! Very clean.


0 Likes 0 ·
daza avatar image
daza answered ·

Man i really didn't want to come back to trying nodeRed its just too advance for me. But talking to @Guy Stewart (Victron Community Manager) this seems to be the only way that i can do like a solar switch so the battery isn't charged from solar maybe via DVCC limiting and then reverts to standard charging current at a set time. So i thought i would try and do this Octopus thing. i have installed the other missing stuff that node red needed, i have no idea if it works yet but i wanted a way to say that if battery X percent ie What i want t do is setup a discharge in the session interval with a proviso that it leave 30% of the battery if it starts @ 1700 -1800 or 1730 - 1830 if it starts at 1600 - 1700 it should leave 40%. @matt1309 or Any one that knows node red that can help with the below then i can look at seeing if it can be built out further?


So ive copied this https://flows.nodered.org/flow/83a2ff80d99599599def737197829b7e#:~:text=This%20flow%20finds%20and%20automatically,ends%2C%20via%20the%20switch%20node.

Ive inputed the API key and account number are in the GraphQL section but have two errors and no idea how or where they are as the creator just says to put it into the flow GraphQL but i have errors here

  • [Octopus Energy GraphQL] obtainKrakenToken (graphql)
  • [Octopus Energy GraphQL] Run GraphQL (graphql)



2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

matt1309 avatar image
matt1309 answered ·

Hi @Daza


I cant comment on the octopus node. It looks like it's a way of getting the pricing data from octopus. GraphQL. I'm not familiar with graphql. Guessing you've already installed the node for it?


I can help with the rest of the code but not so much the octopus specific bit.. If you've got a curl command example of how to get octopus data I dont mind pulling something together using http node if that's easier. ie translating the curl command into http node.


The rest of the code: I'd do something like this (this is untested code just for examples)


For really simple single input if statements i prefer to use a switch node. ie time input into switch node. Then as property set msg.payload

> setTime where setTime is the defined time criteria you have. If time > setTime the data is passed through the switch node.


For more complex criteria, like if statements based on multiple criteria ie time and SoC or even more inputs. I would use a function node. And write the javascript yourself. (I'll attach snip for below, it's not tested so will need to be debugged, but should be a decent jumping off point/give you an idea of what to tweak/how.

If need need another variable on top of the below it gets a bit more complicated (you can use global vars), but I can share an example of that if you want another input into the function as well.

I've added comments to the code to hopefully explain and I've assumed msg.payload = 1 is the message that needs to be passed out of the function to turn on octopus charging session. Alterantively if you're managing that side of things yourself you'd edit dvcc/grid set point in the block where I've set msg.payload = 1 to turn on discharing and msg.payload = 0 to stop charging.

You can combine the if's to make the code shorter but I felt the below layout made it easier to wrap your head around


var currentTime = new Date(); //gets current time 
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();


 var soc = msg.payload; // this assumes SoC is being passed into function node. 



if((hours >= 17) && (hours <= 20 && minutes <=30)){ //if time is between 5 and 6.30pm
    
    if( soc > 30){ //if state of charge is above 40%
       //code under here will be what you need to pass into the octopus node, I've assumed you just need to pass in payload = 1 but that might not be right. You'd just tweak that behaviour in this block though
        msg.payload = 1; 
        return msg; 

    
    }else if(soc <= 30) {
        //again this might need tweaked to send whatever the "off" criteria is more the ocotpus nodes. 
     msg.payload = 0;
return msg;
    
    
    
        
    }


}else if((hours >= 16) && (hours <= 17)){
    
   if( soc > 30){ //if state of charge is above 40%
       //code under here will be what you need to pass into the octopus node, I've assumed you just need to pass in payload = 1 but that might not be right. You'd just tweak that behaviour in this block though
        msg.payload = 1; 
        return msg; 

    
    }else if(soc <= 30) {
        //again this might need tweaked to send whatever the "off" criteria is more the ocotpus nodes. 
     msg.payload = 0;
return msg;
    
    
    
        
    }
    
    
}





2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

daza avatar image
daza answered ·

Thanks @matt1309 but to me that looks like an alien language lol, so yeah I’ve done the graphql and put my account and api key in, I have also done the pushover account that @Craig Chamberlain mentioned which I didn’t do but for some reason no error showed up?


Yeah the node is for like a saver session node so it tracks when they want you to try and save energy. So it’s more of a discharge battery at saver session time

but I’m currently getting errors with the deployment of it I’ve messaged @Craig Chamberlain who seems to have implemented the Octopus API would like to try to expand to get it to discharge for a saver session but need to get to the bottom of why it’s not working

so these are the errors I get


img-4518.jpeg


img-4518.jpeg (6.5 MiB)
2 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

matt1309 avatar image matt1309 commented ·

Tbf the comments make it hard to read delete everything after a // and you'll be able to guess what the codes doing:


var currentTime = new Date(); //gets current time 
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
 
 
 var soc = msg.payload; 
 
 
if((hours >= 17) && (hours <= 18 && minutes <=30)){ //if time is between 5 and 6.30pm
    
    if( soc > 30){ 

        msg.payload = 1; 
        return msg; 

    }else if(soc <= 30) {
       
        msg.payload = 0;
        return msg;

        
    }
 
 
}else if((hours >= 16) && (hours <= 17)){
    
   if( soc > 30){ //if state of charge is above 40%

        msg.payload = 1; 
        return msg; 
 
    }else if(soc <= 30) {
 
        msg.payload = 0;
        return msg
        
  } 
}



I've never used graphql, I think it's supposed to help with handling api requests. Sounds like you need a token/key entered somewhere in the settings to get it working. Sorry I'm not familiar/unsure where you find that settings.

1 Like 1 ·
Craig Chamberlain avatar image Craig Chamberlain commented ·
FYI, I've replied in the other thread.
1 Like 1 ·
daza avatar image
daza answered ·

Thank you both lots and I’m sorry it won’t be the last time I pester you both @Craig Chamberlain @matt1309 turns out that it’s safarI that’s causing the issues facepalm!

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Related Resources

Additional resources still need to be added for this topic