Domoticz SMA Inverter error

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

User avatar
Bospieper
Posts: 166
Joined: Thursday 07 November 2019 10:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: NL
Contact:

Domoticz SMA Inverter error

Post by Bospieper »

]Hi,
I've installed the Domoticz-SMA-inverter plugin and installed the files pymodbus en pymodbusTCP.
Unfortunately I'am getting the follow errors:
Schermafbeelding 2024-08-04 150025.png
Schermafbeelding 2024-08-04 150025.png (7.81 KiB) Viewed 1905 times
and
Schermafbeelding 2024-08-04 150846.png
Schermafbeelding 2024-08-04 150846.png (2.99 KiB) Viewed 1905 times
pymodbus 3.7.0
pymodbusTCP 0.2.2
Domoticz 2024.7

Who can tell me more about these errors and a possible solution?
Grz. Piet
User avatar
mvveelen
Posts: 687
Joined: Friday 31 October 2014 10:22
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Hoorn, The Netherlands
Contact:

Re: Domoticz SMA Inverter error

Post by mvveelen »

What plugin exactly are you using? There are several...
RPi3b+/RFXCOM rfxtrx433E/Shelly/Xiaomi Gateway/Philips HUE Lights/Atag Zone One/2 SunnyBoy inverters/AirconWithMe/P1 smartmeter/Domoticz latest Beta
User avatar
Bospieper
Posts: 166
Joined: Thursday 07 November 2019 10:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: NL
Contact:

Re: Domoticz SMA Inverter error

Post by Bospieper »

This one: SMA Solar Inverter (modbus TCP/IP)
User avatar
mvveelen
Posts: 687
Joined: Friday 31 October 2014 10:22
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Hoorn, The Netherlands
Contact:

Re: Domoticz SMA Inverter error

Post by mvveelen »

OK, well I use an external (modified) plugin for the 2 SMA inverters I have:
sma.png
sma.png (6.4 KiB) Viewed 1855 times
In the plugin folder, I have a subfolder "Domoticz-SMA-SunnyBoy"

with below plugin.py script.

Code: Select all

# SMA Sunny Boy Python Plugin for Domoticz
#
# Authors: merlot, rklomp
#
# Based on https://github.com/merlot-dev/Domoticz-SMA-SunnyBoy

"""
<plugin key="SMASunnyBoy" name="SMA Sunny Boy Solar Inverter" author="rklomp" version="1.0.6">
    <description>
        <h2>SMA Sunny Boy Solar Inverter Plugin</h2><br/>
        <h3>Features</h3>
        <ul style="list-style-type:square">
            <li>Register instant power and daily generated energy</li>
        </ul>
    </description>
    <params>
        <param field="Address" label="IP Address" width="200px" required="true"/>
        <param field="Password" label="User group password" width="200px" required="true" password="true"/>
        <param field="Mode1" label="Protocol" width="75px">
            <options>
                <option label="HTTPS" value="https"/>
                <option label="HTTP" value="http"  default="true" />
            </options>
        </param>
        <param field="Mode3" label="Query interval" width="75px" required="true">
            <options>
                <option label="5 sec" value="1"/>
                <option label="15 sec" value="3"/>
                <option label="30 sec" value="6"/>
                <option label="1 min" value="12" default="true"/>
                <option label="3 min" value="36"/>
                <option label="5 min" value="60"/>
                <option label="10 min" value="120"/>
            </options>
        </param>
        <param field="Mode6" label="Debug" width="75px">
            <options>
                <option label="True" value="Debug"/>
                <option label="False" value="Normal" default="true"/>
            </options>
        </param>
    </params>
</plugin>
"""

import requests
import Domoticz


class BasePlugin:
    enabled = False
    lastPolled = 0
    loginSid = None
    baseUrl = None
    headers = {'Content-Type': 'application/json', 'Accept-Charset': 'UTF-8'}
    maxAttempts = 3
    httpTimeout = 1

    def __init__(self):
        return

    def login(self, force=False):
        if not force and self.loginSid is not None:
            return self.loginSid

        try:
            url = "%s/login.json" % self.baseUrl
            payload = '{"pass" : "%s", "right" : "usr"}' % Parameters["Password"]
            r = requests.post(url, data=payload, headers=self.headers, verify=False, timeout=self.httpTimeout)
        except Exception as e:
            Domoticz.Log("Error accessing SMA inverter on %s; %s" % (Parameters["Address"], e))
        else:
            j = r.json()
            try:
                sid = j['result']['sid']
                if sid is None:
                    Domoticz.Error("Unable to login to SMA inverter on %s using supplied password" % Parameters["Address"])
                self.loginSid = sid
                Domoticz.Status("Successfully logged in to SMA inverter on %s" % Parameters["Address"])
                Domoticz.Debug("Received SID: %s" % sid)
                return self.loginSid
            except:
                Domoticz.Log("No valid response from SMA inverter on %s; %s" % (Parameters["Address"], j))

    def logout(self):
        Domoticz.Status("Closing session to SMA inverter on %s" % Parameters["Address"])

        url = "%s/logout.json?sid=%s" % (self.baseUrl, self.loginSid)
        r = requests.post(url, data="{}", headers=self.headers, verify=False, timeout=self.httpTimeout)
        Domoticz.Debug(r.text)

    def onStart(self):
        Domoticz.Debug("onStart called")
        if Parameters["Mode6"] == "Debug":
            Domoticz.Debugging(1)
        else:
            Domoticz.Debugging(0)

        if len(Devices) == 0:
            Domoticz.Device(Name="PV Generation", Unit=1, Type=243, Subtype=29, Switchtype=4).Create()
            Domoticz.Device(Name="kWh total", Unit=2, TypeName="Custom", Options={"Custom": "1;kWh"}).Create()
            Domoticz.Device(Name="AC Voltage", Unit=3, TypeName="Voltage").Create()
            Domoticz.Device(Name="AC Current", Unit=4, TypeName="Current (Single)").Create()

        if len(Devices) == 2:
            Domoticz.Device(Name="AC Voltage", Unit=3, TypeName="Voltage").Create()
            Domoticz.Device(Name="AC Current", Unit=4, TypeName="Current (Single)").Create()

        DumpConfigToLog()

        self.baseUrl = "%s://%s/dyn" % (Parameters["Mode1"], Parameters["Address"])
        Domoticz.Debug("Base URL is set to %s" % self.baseUrl)
        self.login()

        Domoticz.Heartbeat(5)

    def onStop(self):
        Domoticz.Debug("onStop called")
        self.logout()

    def onHeartbeat(self):
        Domoticz.Debug("onHeartbeat called %d" % self.lastPolled)
        if self.lastPolled == 0:
            attempt = 1
            relogin = False

            while True:
                if attempt <= self.maxAttempts:
                    if attempt > 1:
                        Domoticz.Debug("Previous attempt failed, trying new login...")
                        relogin = True
                else:
                    Domoticz.Error("Failed to retrieve data from %s, cancelling..." % Parameters["Address"])
                    break
                attempt += 1

                sid = self.login(relogin)
                url = "%s/getValues.json?sid=%s" % (self.baseUrl, sid)
                payload = '{"destDev":[],"keys":["6400_00260100","6100_40263F00","6100_00464800","6100_40465300"]}'

                try:
                    r = requests.post(url, data=payload, headers=self.headers, verify=False, timeout=self.httpTimeout)
                    j = r.json()
                except Exception as e:
                    Domoticz.Log("No data from SMA inverter on %s; %s" % (Parameters["Address"], e))
                else:
                    Domoticz.Debug("Received data: %s" % j)
                    if "err" in j:
                        continue

                    result = list(j['result'].values())[0]
                    sma_pv_watt = result['6100_40263F00']['1'][0]['val']
                    sma_kwh_total = result['6400_00260100']['1'][0]['val']
                    sma_ac_volt = result['6100_00464800']['1'][0]['val']
                    sma_ac_current = result['6100_40465300']['1'][0]['val']


                    if sma_pv_watt is None:
                        sma_pv_watt = 0

                    if sma_ac_volt is None:
                        sma_ac_volt = 0

                    if sma_ac_current is None:
                        sma_ac_current = 0

                    if sma_kwh_total is None:
                        Domoticz.Log("Received data from %s, but values are None" % Parameters["Address"])
                        break
                    Devices[1].Update(nValue=0, sValue=str(sma_pv_watt)+";"+str(sma_kwh_total))
                    svalue = "%.2f" % (sma_kwh_total/1000)
                    Domoticz.Debug("kWh total: " + str(svalue))
                    Devices[2].Update(nValue=0, sValue=svalue)
                    svalue = "%.2f" % (sma_ac_volt/100)
                    Domoticz.Debug("AC Volt L1: " + str(svalue))
                    Devices[3].Update(nValue=0, sValue=svalue)
                    svalue = "%.2f" % (sma_ac_current/1000)
                    Domoticz.Debug("AC Current L1: " + str(svalue))
                    Devices[4].Update(nValue=0, sValue=svalue)
                    break

        self.lastPolled += 1
        self.lastPolled %= int(Parameters["Mode3"])


global _plugin
_plugin = BasePlugin()


def onStart():
    global _plugin
    _plugin.onStart()


def onStop():
    global _plugin
    _plugin.onStop()


def onHeartbeat():
    global _plugin
    _plugin.onHeartbeat()


# Generic helper functions
def DumpConfigToLog():
    for x in Parameters:
        if Parameters[x] != "":
            Domoticz.Debug("'" + x + "':'" + str(Parameters[x]) + "'")
    Domoticz.Debug("Device count: " + str(len(Devices)))
    for x in Devices:
        Domoticz.Debug("Device:           " + str(x) + " - " + str(Devices[x]))
        Domoticz.Debug("Device ID:       '" + str(Devices[x].ID) + "'")
        Domoticz.Debug("Device Name:     '" + Devices[x].Name + "'")
        Domoticz.Debug("Device nValue:    " + str(Devices[x].nValue))
        Domoticz.Debug("Device sValue:   '" + Devices[x].sValue + "'")
        Domoticz.Debug("Device LastLevel: " + str(Devices[x].LastLevel))
    return
    
RPi3b+/RFXCOM rfxtrx433E/Shelly/Xiaomi Gateway/Philips HUE Lights/Atag Zone One/2 SunnyBoy inverters/AirconWithMe/P1 smartmeter/Domoticz latest Beta
User avatar
Bospieper
Posts: 166
Joined: Thursday 07 November 2019 10:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: NL
Contact:

Re: Domoticz SMA Inverter error

Post by Bospieper »

Hi,
I have the same situation at my home, Two inverters. I will try your solution and let you know.
Regards Piet
User avatar
waltervl
Posts: 5724
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Domoticz SMA Inverter error

Post by waltervl »

Perhaps also take a look at this one https://github.com/derenback/Domoticz-SMA-Inverter
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
Bospieper
Posts: 166
Joined: Thursday 07 November 2019 10:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: NL
Contact:

Re: Domoticz SMA Inverter error

Post by Bospieper »

Hi,
After installing the plugin I have the following errors:

The used password is correct I checked by using ip and password to login
Attachments
Schermafbeelding 2024-08-09 125258.png
Schermafbeelding 2024-08-09 125258.png (15.65 KiB) Viewed 1828 times
User avatar
Bospieper
Posts: 166
Joined: Thursday 07 November 2019 10:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: NL
Contact:

Re: Domoticz SMA Inverter error

Post by Bospieper »

waltervl wrote: Friday 09 August 2024 12:15 Perhaps also take a look at this one https://github.com/derenback/Domoticz-SMA-Inverter
My first post was based on the plugin you suggested.
Grz. Piet
User avatar
mvveelen
Posts: 687
Joined: Friday 31 October 2014 10:22
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Hoorn, The Netherlands
Contact:

Re: Domoticz SMA Inverter error

Post by mvveelen »

Bospieper wrote: Friday 09 August 2024 12:59 Hi,
After installing the plugin I have the following errors:

The used password is correct I checked by using ip and password to login
Did you try changing your password into something easier? And, are you sure you use the correct password (can you login with the credentials on the SMA directly)? Beware that you only login with the plugin and be logged off from the inverter itself.
RPi3b+/RFXCOM rfxtrx433E/Shelly/Xiaomi Gateway/Philips HUE Lights/Atag Zone One/2 SunnyBoy inverters/AirconWithMe/P1 smartmeter/Domoticz latest Beta
User avatar
Bospieper
Posts: 166
Joined: Thursday 07 November 2019 10:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: NL
Contact:

Re: Domoticz SMA Inverter error

Post by Bospieper »

Hi,
As I stated before I can login by using the ip of the sma and password.
Does this mean that I can't logon at the same time as the login from the sma app?
Grz Piet
User avatar
mvveelen
Posts: 687
Joined: Friday 31 October 2014 10:22
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Hoorn, The Netherlands
Contact:

Re: Domoticz SMA Inverter error

Post by mvveelen »

Bospieper wrote: Saturday 17 August 2024 14:37 Hi,
As I stated before I can login by using the ip of the sma and password.
Does this mean that I can't logon at the same time as the login from the sma app?
Grz Piet
Not sure, try?
RPi3b+/RFXCOM rfxtrx433E/Shelly/Xiaomi Gateway/Philips HUE Lights/Atag Zone One/2 SunnyBoy inverters/AirconWithMe/P1 smartmeter/Domoticz latest Beta
User avatar
Bospieper
Posts: 166
Joined: Thursday 07 November 2019 10:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: NL
Contact:

Re: Domoticz SMA Inverter error

Post by Bospieper »

Both possible solutions don't work.
This is the reading of the status log:
Schermafbeelding 2024-08-17 status.png
Schermafbeelding 2024-08-17 status.png (14.69 KiB) Viewed 1671 times
and this of the problem log:
Schermafbeelding 2024-08-problem.png
Schermafbeelding 2024-08-problem.png (21.67 KiB) Viewed 1671 times
User avatar
mvveelen
Posts: 687
Joined: Friday 31 October 2014 10:22
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Hoorn, The Netherlands
Contact:

Re: Domoticz SMA Inverter error

Post by mvveelen »

I have no idea what can be wrong, just for reference: you did everything that is in the README ?
# Domoticz-SMA-SunnyBoy
Domoticz plugin to get SMA Sunny Boy information

Tested with Python version 3.7 and 3.8, Domoticz versions 4.10717, 4.11799, 2020.1, 2020.2 and 2021.1

## Installation

Assuming that domoticz directory is installed in your home directory.

```bash
cd ~/domoticz/plugins
git clone https://github.com/rklomp/Domoticz-SMA-SunnyBoy
# restart domoticz:
sudo /etc/init.d/domoticz.sh restart
```
In the web UI, navigate to the Hardware page. In the hardware dropdown there will be an entry called "SMA Sunny Boy".

Make sure to (temporarily) enable 'Accept new Hardware Devices' in System Settings so that the plugin can add devices.

Please note you need python dev for the plugin to work To install Python Dev
```bash
sudo apt install python3-dev
```

## Known issues

## Updating

Like other plugins, in the Domoticz-SMA-SunnyBoy directory:
```bash
git pull
sudo /etc/init.d/domoticz.sh restart
```

## Parameters

| Parameter | Value |
| :--- | :--- |
| **IP address** | IP of the SMA Sunny Boy eg. 192.168.1.231 |
| **Password** | password for the User Group, not the Installer one |
| **Query interval** | how often is data retrieved from the SMA |
| **Debug** | show debug logging |

## Acknowledgements

Based on the scripts found here

https://github.com/merlot-dev/Domoticz-SMA-SunnyBoy \
https://community.openhab.org/t/example ... r/50963/19

Wait, is web connect active on the SMA?
Scherm­afbeelding 2024-08-17 om 17.06.39.png
Scherm­afbeelding 2024-08-17 om 17.06.39.png (27 KiB) Viewed 1663 times
RPi3b+/RFXCOM rfxtrx433E/Shelly/Xiaomi Gateway/Philips HUE Lights/Atag Zone One/2 SunnyBoy inverters/AirconWithMe/P1 smartmeter/Domoticz latest Beta
User avatar
Bospieper
Posts: 166
Joined: Thursday 07 November 2019 10:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: NL
Contact:

Re: Domoticz SMA Inverter error

Post by Bospieper »

Hi,
This morning I did the whole installation again, I changed the password to a easier one. Unfortunately I'am getting the same errors again.
And yes the Webconnect is active on both SMA's
Grz. Piet
User avatar
Bospieper
Posts: 166
Joined: Thursday 07 November 2019 10:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: NL
Contact:

Re: Domoticz SMA Inverter error

Post by Bospieper »

Hi,
I narrowd the problem now to one inverter. I have two, changing to the second one it immediately reads the solar data.
The difference between both is tat the one with the prolem is connecting by cable (speedwire) and the other is connection by WiFi
Last edited by Bospieper on Sunday 18 August 2024 11:31, edited 1 time in total.
User avatar
mvveelen
Posts: 687
Joined: Friday 31 October 2014 10:22
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Hoorn, The Netherlands
Contact:

Re: Domoticz SMA Inverter error

Post by mvveelen »

Bospieper wrote: Sunday 18 August 2024 10:46 Hi,
I narrowd the problem now to one inverter. I have two, changing to the second one it immediately reads the solar data.
Ah, and are the settings of both exactly the same? Webconnect? Other settings?

Oh, and which ones are they, because there might be a difference between the two I remember.

Edit:

I have one with HTTP and the other with HTTPS in the Domoticz settings. Try that, that was for me the solution !
RPi3b+/RFXCOM rfxtrx433E/Shelly/Xiaomi Gateway/Philips HUE Lights/Atag Zone One/2 SunnyBoy inverters/AirconWithMe/P1 smartmeter/Domoticz latest Beta
User avatar
Bospieper
Posts: 166
Joined: Thursday 07 November 2019 10:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: NL
Contact:

Re: Domoticz SMA Inverter error

Post by Bospieper »

Hi,
I have one inverter the SB2.5-1VL-40 and the other is a SB1.5-1VL-40
Changing te one with the error to https doesn't solve the problem.
User avatar
mvveelen
Posts: 687
Joined: Friday 31 October 2014 10:22
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Hoorn, The Netherlands
Contact:

Re: Domoticz SMA Inverter error

Post by mvveelen »

Hmmmm..... I've ran out of options then. This setting did the trick for me when I wasn't able to get both online. Will search in my old messages for any other suggestions, but I'm afraid this is it for me.
RPi3b+/RFXCOM rfxtrx433E/Shelly/Xiaomi Gateway/Philips HUE Lights/Atag Zone One/2 SunnyBoy inverters/AirconWithMe/P1 smartmeter/Domoticz latest Beta
User avatar
Bospieper
Posts: 166
Joined: Thursday 07 November 2019 10:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: NL
Contact:

Re: Domoticz SMA Inverter error

Post by Bospieper »

Hi,
I understand,thanx sofar. I know now that it is not the software (plugin) but probely some adjustment in the parameters of the inverter.
Again thanx.
Grz. Piet
solarboy
Posts: 333
Joined: Thursday 01 November 2018 19:47
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.6
Location: Portugal
Contact:

Re: Domoticz SMA Inverter error

Post by solarboy »

Have you considered the SBFspot plugin. I've found it to be exemplary with my SB 5.0 40.
Intel NUC with Ubuntu Server VM (Proxmox),mosquitto(docker),RFXtrx433E,zwavejsUI (docker),Zigbee2mqtt(docker),SMA Hub (docker),Harmony Hub plugin, Kodi plugin,Homebridge(docker)+Google Home,APC UPS,SMA Modbus,Mitsubishi MQTT, Broadlink,Dombus
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest