npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sonnen-battery-api

v1.0.2

Published

A Node.js package for interacting with Sonnen's Battery API v2

Downloads

18

Readme

Sonnen Battery API

The sonnen-battery-api package allows you to interact with Sonnen's Battery API v2 to control various configuration elements of your Sonnen battery system. This package simplifies communication with the Sonnen API and provides an easy-to-use Node.js interface.

Installation

To use this package in your Node.js project, you can install it via npm:

npm install sonnen-battery-api

Usage

const SonnenBatteryAPI = require('sonnen-battery-api');

// Initialize the SonnenBatteryAPI class with your server details and authentication token
const sonnenBattery = new SonnenBatteryAPI('your-server-ip', 'your-server-port', 'your-auth-token');

// Example: Set the operating mode
sonnenBattery.setOperatingMode('mode_value')
  .then(data => {
    console.log('Operating mode set:', data);
  })
  .catch(error => {
    console.error('Error:', error);
});

getOperatingMode()

  • Description: Fetches the current operating mode of the Sonnen battery system.
  • Usage:
    const mode = await sonnenBattery.getOperatingMode();
    console.log('Operating mode:', mode);

getBatteryInfo()

  • Description: Fetches battery information.
  • Usage:
    const batteryInfo = await sonnenBattery.getBatteryInfo();
    console.log('Battery information:', batteryInfo);

getBatteryStatus()

  • Description: Fetches battery status information.
  • Usage:
    const batteryStatus = await sonnenBattery.getBatteryStatus();
    console.log('Battery status:', batteryStatus);

getInverterInfo()

  • Description: Fetches inverter information.
  • Usage:
    const inverterInfo = await sonnenBattery.getInverterInfo();
    console.log('Inverter information:', inverterInfo);

getLatestData()

  • Description: Fetches the latest data from the Sonnen battery system.
  • Usage:
    const latestData = await sonnenBattery.getLatestData();
    console.log('Latest data:', latestData);

getConfigurations()

  • Description: Fetches the system configurations.
  • Usage:
    const configurations = await sonnenBattery.getConfigurations();
    console.log('Configurations:', configurations);

setOperatingMode(mode)

  • Description: Sets the operating mode of the Sonnen battery system.
  • Usage:
    await sonnenBattery.setOperatingMode('mode_value');

setPrognosisCharging(enabled)

  • Description: Sets the prognosis charging.
  • Usage:
    await sonnenBattery.setPrognosisCharging(true);

setMicrogridReEnable(enabled)

  • Description: Sets the microgrid re-enable.
  • Usage:
    await sonnenBattery.setMicrogridReEnable(true);

setTimeOfUseSchedule(schedule)

  • Description: Sets the time-of-use schedule.
  • Usage:
    await sonnenBattery.setTimeOfUseSchedule(schedule);

setUserInputTimeOne(time)

  • Description: Sets user input time one.
  • Usage:
    await sonnenBattery.setUserInputTimeOne(time);

setUserInputTimeTwo(time)

  • Description: Sets user input time two.
  • Usage:
    await sonnenBattery.setUserInputTimeTwo(time);

setUserInputTimeThree(time)

  • Description: Sets user input time three.
  • Usage:
    await sonnenBattery.setUserInputTimeThree(time);

setSOC(soc)

  • Description: Sets the state of charge.
  • Usage:
    await sonnenBattery.setSOC(soc);

setCHPMaxSOC(maxSOC)

  • Description: Sets maximum SOC for combined heat and power.
  • Usage:
    await sonnenBattery.setCHPMaxSOC(maxSOC);

setCHPMinSOC(minSOC)

  • Description: Sets minimum SOC for combined heat and power.
  • Usage:
    await sonnenBattery.setCHPMinSOC(minSOC);

setGeneratorType(generatorType)

  • Description: Sets generator type.
  • Usage:
    await sonnenBattery.setGeneratorType(generatorType);

setGeneratorPowerSetPoint(powerSetPoint)

  • Description: Sets generator power set point.
  • Usage:
    await sonnenBattery.setGeneratorPowerSetPoint(powerSetPoint);

setUSMicrogridReEnable(enabled)

  • Description: Sets the re-enable microgrid for the US system.
  • Usage:
    await sonnenBattery.setUSMicrogridReEnable(true);

setUSUserInputTimeOne(time)

  • Description: Sets user input time one for the US system.
  • Usage:
    await sonnenBattery.setUSUserInputTimeOne(time);

setUSUserInputTimeTwo(time)

  • Description: Sets user input time two for the US system.
  • Usage:
    await sonnenBattery.setUSUserInputTimeTwo(time);

setUSUserInputTimeThree(time)

  • Description: Sets user input time three for the US system.
  • Usage:
    await sonnenBattery.setUSUserInputTimeThree(time);

setFixedPowerFactor(factor)

  • Description: Sets fixed power factor.
  • Usage:
    await sonnenBattery.setFixedPowerFactor(factor);

setFixedPowerFactorActive(active)

  • Description: Sets the active state of fixed power factor.
  • Usage:
    await sonnenBattery.setFixedPowerFactorActive(true);

setFixedPowerFactorLagging(lagging)

  • Description: Sets the lagging state of fixed power factor.
  • Usage:
    await sonnenBattery.setFixedPowerFactorLagging(true);

setHeaterOperatingMode(mode)

  • Description: Sets heater operating mode.
  • Usage:
    
    
    await sonnenBattery.setHeaterOperatingMode(mode);

setHeaterTemperatureMax(temperature)

  • Description: Sets maximum heater temperature.
  • Usage:
    await sonnenBattery.setHeaterTemperatureMax(temperature);

setHeaterTemperatureMin(temperature)

  • Description: Sets minimum heater temperature.
  • Usage:
    await sonnenBattery.setHeaterTemperatureMin(temperature);

Battery Configuration Elements

Here are some of the available configuration elements that you can control using this package:

  • EM_OperatingMode: Set the operating mode.
  • EM_Prognosis_Charging: Set the prognosis charging.
  • EM_RE_ENABLE_MICROGRID: Set the microgrid re-enable.
  • EM_ToU_Schedule: Set the time-of-use schedule.
  • EM_USER_INPUT_TIME_ONE: Set user input time one.
  • EM_USER_INPUT_TIME_TWO: Set user input time two.
  • EM_USER_INPUT_TIME_THREE: Set user input time three.
  • EM_USOC: Set the state of charge.
  • EM_US_CHP_Max_SOC: Set maximum SOC for combined heat and power.
  • EM_US_CHP_Min_SOC: Set minimum SOC for combined heat and power.
  • EM_US_GENRATOR_TYPE: Set generator type.
  • EM_US_GEN_POWER_SET_POINT: Set generator power set point.
  • EM_US_RE_ENABLE_MICROGRID: Set the re-enable microgrid for the US system.
  • EM_US_USER_INPUT_TIME_ONE: Set user input time one for the US system.
  • EM_US_USER_INPUT_TIME_TWO: Set user input time two for the US system.
  • EM_US_USER_INPUT_TIME_THREE: Set user input time three for the US system.
  • NVM_PfcFixedCosPhi: Set fixed power factor.
  • NVM_PfcIsFixedCosPhiActive: Set the active state of fixed power factor.
  • NVM_PfcIsFixedCosPhiLagging: Set the lagging state of fixed power factor.
  • SH_HeaterOperatingMode: Set heater operating mode.
  • SH_HeaterTemperatureMax: Set maximum heater temperature.
  • SH_HeaterTemperatureMin: Set minimum heater temperature.

Please refer to the Sonnen Battery API documentation for more details on these configuration elements.

License

This package is open-source and available under the MIT License.