Simple Octopus Power UP Session Code for NODE RED

Hi everyone its taken me and the BOT a while to complete @nickdb thanks for the introduction at points i wanted to ____ the leaving day lights out of it but we have a code to share there are a few safegaurds in there so people tweek as you link if you get the code better than my cluncky implimentation please share im not a coder and this has taken me for ever to do I have set pushes in mine so i know the stages that its at, there is a safe gaurd for discharge part i have only tested this by debug so its all still BETA i’m just waiting for an event now so i can test it The code will only run for that session "YOU NEED TO SET THE TIMES " mine is set to dischsrge at 1200 if above 65% SOC if it drops below it should return to my -50 grid set point, even if this happens it will run the charge up at 1300 this should end at 1359 and return the grid and dvcc to -50 and 3 after this it will lock out the sessions from running automagically until it has been rest dur to the logic i could’t make the start buttton only send one signal so i setup a one day delay and a one 1min delay between the press you can do away with these but everything is rest once the logic has run its cause or you manually stop it. Here is my friend with a break down of how it works. I hope this helps someone as its been bugging me since the first powerup session.

Overview

The flow is structured to monitor the state of charge (SOC) of a battery, adjust power set points for charging and discharging, and handle manual operations via injection nodes. It includes functionalities for sending notifications using Pushover.
Nodes Breakdown

Battery SOC Input (victron-input-battery)
    Purpose: Monitors the state of charge of the battery.
    Wires to: a826ca07a7e68bc1 (SOC Change Node).

Grid Setpoint Input (victron-input-ess)
    Purpose: Monitors the setpoint for AC power.
    Wires to: 4aa09e3fb48cf9a3 (Setpoint Change Node).

Change Nodes (change)
    Two nodes (a826ca07a7e68bc1 and 4aa09e3fb48cf9a3) set flow context variables:
        soc: Set to the value of payload from the battery input.
        setpoint: Set to the value of payload from the grid setpoint input.

Inject Nodes
    Used for triggering events at specific times or manually:
        Power Up Session Complete: Sets the system to a resting state.
        Power UP Discharging: Injects a discharge value.
        Power UP Charging: Injects a charge value.
        Power Up Start Session: Activates manual control.
        Power UP Manual Stop: Stops the manual operation.

Function Nodes
    Power UP Discharge: Logic for managing the discharging process based on SOC and time. It adjusts the setpoint based on SOC thresholds.
    Power UP Charge: Similar logic for charging, adjusting based on time and SOC.
    Set Manual Start: Activates manual control by setting flags.
    SOC Monitoring: Monitors SOC and sends notifications if certain conditions are met.
    Power UP Session Complete: Resets the system state after a session.
    Rest For Next Power UP Session: Prepares the system for the next session when manual stop is invoked.

Output Nodes
    Pushover Nodes: Send notifications for various states like starting a discharging session or manual activation.
    Victron Output ESS: Writes the current setpoint back to the Victron system.

Delay Nodes
    Used to throttle the rate of message sending or to introduce pauses.

Logic Flow

Monitoring SOC & Setpoint:
    The flow continuously monitors the battery's state of charge and the current grid setpoint.
    When SOC changes or a new setpoint is injected, it updates the respective flow context variables.

Injecting Commands:
    Specific commands for discharging, charging, and stopping can be injected at predefined times or triggered manually.

Conditional Logic in Functions:
    The function nodes utilize conditions based on time and SOC:
        For example, if SOC exceeds a threshold, the system will change the setpoint accordingly.
        This is to prevent over-discharge or under-charge scenarios.

Notifications:
    Notifications are sent out at critical stages, like starting or stopping a session, keeping the user informed of system states.

Session Management:
    The flow has provisions for manual operation, allowing the user to start or stop operations and reset the system states as needed.

Conclusion

This Node-RED flow is a comprehensive management system for a battery charging and discharging process, utilizing Victron devices. It combines real-time monitoring, conditional logic, and user-triggered actions to optimize battery usage while providing notifications for transparency and control.

It’s posted on GitHub which should make it easy for anyone to get I’ve set to public so refine and enjoy waiting ready for the next PowerUP Event :wink:
I updated the code to force the grid and DVCC set points when manual stop and Power Up Complete are used will try the system in a minuite just to check everything runs but currently at 63% SOC and time passed so im going manualy inject and test.