qsb36 v0.1.1 QSB36 View Source

Query SunnyBoy 3.6 inverter for current output in watts, total yield and other information via the inverter's internal web interface.

Note:

  • the inverter only supports http, not https
  • the inverter limits the number of active sessions, so it is a good idea to log out when your program terminates
  • the inverter may close your session after a period of inactivity
  • in your application, you probably want to poll the current ouput every n seconds, where n is small
  • you probably want to poll the other values much less frequently
  • be careful not to put too much pressure on the inverter's web server by excessive querying of historical yields
  • you will have to interpret the data yourself and calculate your own deltas
  • there is currently next to no input value verification; use carefully
  • this module has so far only been tested on one specific actual device; there is no guarantee that this module is fit for your purpose / inverter; use at your own risk

Example

iex> {:ok, session} = QSB36.user_login("192.168.1.90", "password_for_user_group")
{:ok, %QSB36.Session{host: "192.168.1.90", sid: "mOi0Eg_N4kaNhg_R"}}

iex> QSB36.device_info(session)
{:ok, {"SB3.6-1AV-40 231", 1234567890}}

iex> QSB36.health_status(session)                      
{:ok, {307, :ok}}

iex> QSB36.current_time(session)
{:ok, {1584382357, 0}}

iex> QSB36.current_watts(session)
{:ok, 262}

iex> QSB36.total_yield(session)
{:ok, 3388801}

iex> QSB36.yield_daily(session, 1584309600, 1584410400) 
{:ok, [{1584316800, 3356183}, {1584403200, 3370444}]}

iex> QSB36.yield_5min(session, 1584316800, 1584403200)  
{:ok,                    
  [                       
    {1584316800, 3356183},
    ...
    {1584403200, 3370444}
  ]
}

iex> QSB36.logout(session)
:ok

Link to this section Summary

Functions

Asks the inverter for its current time (unix seconds) and offset (hours). Returns {:ok, {time, offset}} or {:error, reason}.

Asks the inverter for the current output in watts. Returns {:ok, watts} or {:error, reason}.

Asks the inverter for its device name and serial number. Returns {:ok, {device_name, serial_number}} or {:error, reason}.

Asks the inverter for its operational health status. Returns {:ok, {tag, description}} or {:error, reason}.

Closes the session. Returns :ok or {:error, reason}.

Asks the inverter for its total yield in watts to date. Returns {:ok, watts} or {:error, reason}.

Log in on host with password pass; the user group is "user" (as opposed to "installer"). Returns {:ok, session} or {:error, reason}.

Asks the inverter for the 5-minute yield intervals in watts between start_time and end_time, which are given in unix seconds. The inverter returns a list of {time_stamp, total_yield_in_watts}-tuples that fall between start_time and end_time. Returns {:ok, [{time_stamp, watts}, ...]} or {:error, reason}.

Asks the inverter for the daily yield in watts between start_time and end_time, which are given in unix seconds. The inverter returns a list of {time_stamp, total_yield_in_watts}-tuples that fall between start_time and end_time. Returns {:ok, [{time_stamp, watts}, ...]} or {:error, reason}.

Link to this section Functions

Asks the inverter for its current time (unix seconds) and offset (hours). Returns {:ok, {time, offset}} or {:error, reason}.

Example

iex> {:ok, {time, offset}} = QSB36.current_time(session)
{:ok, {1584382357, 0}}

Asks the inverter for the current output in watts. Returns {:ok, watts} or {:error, reason}.

Example

iex> QSB36.current_watts(session)
{:ok, 262} # another rainy day

Asks the inverter for its device name and serial number. Returns {:ok, {device_name, serial_number}} or {:error, reason}.

Example

iex> QSB36.device_info(session)
{:ok, {"SB3.6-1AV-40 231", 1234567890}}

Asks the inverter for its operational health status. Returns {:ok, {tag, description}} or {:error, reason}.

Descriptive atoms are known for the following tags:

  • 35 => :alm
  • 303 => :off
  • 307 => :ok
  • 455 => :wrn
  • 1719 => :com_nok
  • 1725 => :not_conn
  • 2130 => :conn_sett
  • 3325 => :conn_fail
  • 3426 => :wps_is_act

Example

iex> QSB36.health_status(session)                      
{:ok, {307, :ok}}

Closes the session. Returns :ok or {:error, reason}.

Example

iex> QSB36.logout(session)
:ok

Asks the inverter for its total yield in watts to date. Returns {:ok, watts} or {:error, reason}.

Example

iex> QSB36.total_yield(session)
{:ok, 3388801}

Log in on host with password pass; the user group is "user" (as opposed to "installer"). Returns {:ok, session} or {:error, reason}.

Link to this function

yield_5min(session, start_time, end_time)

View Source

Asks the inverter for the 5-minute yield intervals in watts between start_time and end_time, which are given in unix seconds. The inverter returns a list of {time_stamp, total_yield_in_watts}-tuples that fall between start_time and end_time. Returns {:ok, [{time_stamp, watts}, ...]} or {:error, reason}.

## Example

 iex> {:ok, series} = QSB36.yield_5min(session, 1584316800, 1584403200)  
 {:ok,                    
   [                       
     {1584316800, 3356183},
     {1584317100, 3356183},
     {1584317400, 3356183},
     ...
     {1584345600, 3356316},
     {1584345900, 3356330},
     {1584346200, 3356345},
     {1584346500, 3356361},
     {1584346800, 3356382},
     ...
     {1584402600, 3370444}, 
     {1584402900, 3370444}, 
     {1584403200, 3370444}
   ]
 }
Link to this function

yield_daily(session, start_time, end_time)

View Source

Asks the inverter for the daily yield in watts between start_time and end_time, which are given in unix seconds. The inverter returns a list of {time_stamp, total_yield_in_watts}-tuples that fall between start_time and end_time. Returns {:ok, [{time_stamp, watts}, ...]} or {:error, reason}.

## Example

 iex> QSB36.yield_daily(session, 1584309600, 1584410400) 
 {:ok, [{1584316800, 3356183}, {1584403200, 3370444}]}

 iex> mar16watts = 3370444 - 3356183
 14261