Giter VIP home page Giter VIP logo

ha-sma's Introduction

HA-sma

SMA Sunny Webbox integration for Home Assistant

webbox

Note: Tested against:

  • Sunny WebBox-20 (FW 01.05.08.R) using a Bluetooth connection with the inverter.
  • Sunny WebBox-G1 (FW 01.52), G2 (FW 01.53) and K1 (FW 01.53) all using RS-485 connection with the inverter.

Highlights of what it does offer

  • Poll Sunny Webbox using rpc API v1.4
  • Create HA sensors for all reported channels and sources, e.g.:
    • WebBox-20
      • Webbox summary ('My Plant') - 5 sensors
      • Inverter - 9 sensors
    • WebBox-G1
      • Webbox summary ('My Plant') - 5 sensors
      • Inverter - 18 sensors
      • Weather - 6 sensors
  • Config Flow support (UI configuration) in addition to legacy configuration.yaml.

Installation

Using HACS

  1. Add https://github.com/jpcornil-git/HA-sma to your custom repositories

Update custom_components folder

  1. Clone or download all files from this repository
  2. Move custom_components/sma_webbox to your <ha_configuration_folder>, e.g. /home/homeassistant/.homeassistant/custom_components/sma_webbox
  3. Restart HA and clear browser cache (or restart a browser); latter is required for new config_flow to show up
  4. Add sma_webbox component using either:
    • config flow (Configuration->Integrations->Add integration, search for sma)
    • configuration.yaml see configuration example below.
  5. Created entities will be visible in the Integrations tab and aggregated per device in the Devices tab.
  6. Enable desired sensor entities via the Devices (structured view) or Entities tab (flat view).

Example entry for configuration.yaml:

# Example configuration.yaml
sma_webbox:
  ip_address: 192.168.1.109
  port: 34268
  scan_interval: 30

Note: Typically, only ip_address will be mentionned as illustrated below; I suppose that all devices are using UDP port default (34268) and a scan interval under 30s is probably meaningless as the webbox is not updating faster.

# Example configuration.yaml
sma_webbox:
  ip_address: 192.168.1.109

sma_webbox.py

This script implements the main object used by HomeAssistant but can also be used as an independent script to:

  • test interoperability with a given webbox before addition to homeassistant
  • display data fetched from webbox in a terminal
  • extend capabilities/debug issues outside of HomeAssistant

Note: Tested with/developped for python3.9 (mandated by HomeAssistant from 2022.1)

python3 custom_components/sma_webbox/sma_webbox.py <webbox ip_address>

ha-sma's People

Contributors

jellewie avatar jpcornil-git avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ha-sma's Issues

Data only displayed for one string

Firstly, many thanks for this integration.

I have noticed that the integration only seems to show data for the first string. My inverter (SB 4000TL) has two strings of PV attached.
Would it be possible for this integration to be updated to show the data from both strings?

image

image

integration not loading since HA 2023.5.x

I upgraded this weekend from 2023.4.6 to 2023.5.2 and noticed this integration gives "Failed to set up"
In the logs I see the following:

This error originated from a custom integration.

Logger: homeassistant.config_entries
Source: custom_components/sma/__init__.py:137
Integration: SMA Webbox (documentation, issues)
First occurred: 11:09:06 (1 occurrences)
Last logged: 11:09:06

Error setting up entry 172.23.6.50 for sma
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/config/custom_components/sma/__init__.py", line 137, in async_setup_entry
    hass.config_entries.async_setup_platforms(entry, [Platform.SENSOR])
AttributeError: 'ConfigEntries' object has no attribute 'async_setup_platforms'

Feedbck

HA-sma also compatible with WEBBOX-K1

Webbox Plant: 5 sensors
sma_webbox_0_griegytdy
sma_webbox_0_griegytot
sma_webbox_0_gripwr
sma_webbox_0_msg
sma_webbox_0_OpStt

Generators: 17 sensors Attention! Some sensors are localized into local language!
sma_webbox_1_pac
e.g. sma_webbox_1_seriennummer

Error occurred loading flow

I cannot get HA-sma working. I've tried both editing configuration.yml and adding in the GUI. Same results either way. The error log consists of the following:

2024-01-22 12:02:16.647 ERROR (MainThread) [homeassistant.config_entries] Error occurred loading flow for integration sma_webbox: cannot import name 'WEBBOX_PORT' from 'custom_components.sma_webbox.sma_webbox' (/config/custom_components/sma_webbox/sma_webbox/init.py)

If adding SMA Webbox from the GUI the popup displays (before entering any data):

error

My version of Home Assistant is 2024.1.4 and it is running in Docker, on Linux.

Thank you

ERROR - RPC request time out (no "°C" unit support?)

We have a 'Sunny WebBox' version 'G1' and it seems to not be able to run this integration. I have not found out what the issue it yet. It seems that the data is in the wrong format or something.

SMA info:
Versie Firmware 1.52
Versie apparaatprofielen 1.21
Versie taalgegevens 1.06
Versie Hardware WEBBOX-G1-150002608

image
Some log items: (Sorry for Dutch, the HA is setup that way)

Logger: homeassistant.config_entries
Source: config_entries.py:424
First occurred: 10:13:45 (1 occurrences)
Last logged: 10:13:45

Config entry '192.168.1.245' for sma_webbox integration not ready yet: RPC request timed out; Retrying in background
Deze fout is ontstaan door een aangepaste integratie.

Logger: homeassistant
Source: custom_components/sma_webbox/sma_webbox.py:140
Integration: SMA Webbox (documentation, issues)
First occurred: 10:13:40 (14 occurrences)
Last logged: 10:26:21

Error doing job: Exception in callback _SelectorDatagramTransport._read_ready()
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 1027, in _read_ready
    self._protocol.datagram_received(data, addr)
  File "/config/custom_components/sma_webbox/sma_webbox.py", line 140, in datagram_received
    data = json.loads(data.decode().replace("\0", ""))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 574: invalid start byte
Deze fout is ontstaan door een aangepaste integratie.

Logger: custom_components.sma_webbox.sma_webbox
Source: custom_components/sma_webbox/sma_webbox.py:333
Integration: SMA Webbox (documentation, issues)
First occurred: 10:13:45 (14 occurrences)
Last logged: 10:26:26

RPC request timed out
Traceback (most recent call last):
File "/usr/local/lib/python3.10/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 1027, in _read_ready
self._protocol.datagram_received(data, addr)
File "/config/custom_components/sma_webbox/sma_webbox.py", line 140, in datagram_received
data = json.loads(data.decode().replace("\0", ""))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 574: invalid start byte
2023-02-22 10:30:54.007 WARNING (MainThread) [custom_components.sma_webbox.sma_webbox] RPC request timed out
2023-02-22 10:30:54.010 WARNING (MainThread) [homeassistant.config_entries] Config entry '192.168.1.yyy' for sma_webbox integration not ready yet: RPC request timed out; Retrying in background
2023-02-22 10:31:08.233 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback _SelectorDatagramTransport._read_ready()
Traceback (most recent call last):
File "/usr/local/lib/python3.10/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 1027, in _read_ready
self._protocol.datagram_received(data, addr)
File "/config/custom_components/sma_webbox/sma_webbox.py", line 140, in datagram_received
data = json.loads(data.decode().replace("\0", ""))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 574: invalid start byte
2023-02-22 10:31:13.154 WARNING (MainThread) [custom_components.sma_webbox.sma_webbox] RPC request timed out
2023-02-22 10:31:32.340 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback _SelectorDatagramTransport._read_ready()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.