Giter Club home page Giter Club logo

domoticz-goodwesems's Introduction

Domoticz GoodWe Solar Inverter plugin (SEMS API)

This plugin provides information about your GoodWe solar inverter too Domoticz. This plugin has been made by analysing requests made by the GoodWe SEMS Portal website and following the API documentation provided by GoodWe.

Installation and setup

Follow the Domoticz guide on Using Python Plugins.

Login to a shell, go to the domoticz plugin directory and clone this repository:

cd domoticz/plugins
git clone https://github.com/dylian94/domoticz-GoodWeSEMS.git

Restart Domoticz server, you can try one of these commands (on Linux):

sudo systemctl restart domoticz.service
sudo service domoticz.sh restart

Open the Domoticz interface and go to: Setup > Hardware. You can add new Hardware add the bottom, in the list of hardware types choose for: GoodWe inverter (via SEMS portal).

Follow the instructions shown in the form.

Updating

Login to a shell, go to the plugin directory inside the domoticz plugin directory and execute git pull:

cd domoticz/plugins
cd domoticz-GoodWeSEMS
git pull

Contributing

Even if you do not know how to develop software you can help by using the GitHub Issues for feature request or bug reports. If you DO know how to develop software please help improving this project by submitting pull-requests.

Current features

  1. Get all stations for a specific user account
  2. Automatically get data for all inverters (for one or all stations)
  3. The following devices are added to Domoticz for each inverter:
    • temperature: Inverter temperature (Celcius)
    • power: Current and total output power (Watts)
    • current - Output current (ampere)
    • voltage - Output Voltage

There is a lot more information available trough the GoodWe API if you would like to have a specific feature added too this plugin please submit an issue as indicated in the paragraph above.

domoticz-goodwesems's People

Contributors

dylian94 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

domoticz-goodwesems's Issues

Remove string formatting from data passed too Domoticz

Describe the bug
I want to use te powergeneration read from the device tot calculate and upload to pvoutput.org
In the calculation I get the following error: "attempt to perform arithmetic on global 'PowerGeneration' (a string value)".
After adding the command "print(" ----- PowerConsumption = " .. PowerConsumption .. " W"); I found out that to the value a W is added. This makes the value a string value.
Can you remove the W?

To Reproduce
Install following script:

`` - /home/pi/domoticz/scripts/lua/script_device_calculate_consumption.lua

-- This script collects the values below from Domoticz
-- * The Power and energy values (import and export) from a smartmeter
-- * The Power and energy values from a Solar power inverter
-- It then calculates the consumed power and energy from the values above with the formula's
-- * EnergyConsumption = EnergyGeneration + EnergyImport - EnergyExport
-- * PowerConsumption = PowerGeneration + PowerImport - PowerExport
-- It then updates a virtual device which displays the consumed power and energy in Domoticz


-- Domoticz IDX and names of the needed devices

local GenerationDeviceName = "GoodWe solar - Power" -- Device name of the Generated energy
local EnergyDeviceName = "..................." -- Name of the energy device that shows imported and exported energy
local ConsumptionIDX = .... -- IDX of the energy device that shows calculated Consumption
local ConsumptionDeviceName = "Calculation" -- Name of the energy device that shows calculated Consumption


-- Require parameters

local http = require("socket.http")


-- Script parameters

PowerGeneration = 0 -- in Watts
EnergyGeneration = 0 -- in Watt hours
PowerImport = 0 -- in Watts
EnergyImportLow = 0 -- in Watt hours
EnergyImportHigh = 0 -- in Watt hours
EnergyImport = 0 -- in Watt hours
PowerExport = 0 -- in Watts (toegevoegd)
EnergyExportLow = 0 -- in Watt hours
EnergyExportHigh = 0 -- in Watt hours
EnergyExport = 0 -- in Watt hours
PowerConsumption = 0 -- in Watts
EnergyConsumption = 0 -- in Watt hours
Debug = "YES" -- Turn debugging on ("YES") or off ("NO")


-- Lua Functions

function update(device, id, power, energy, index)
commandArray[index] = {['UpdateDevice'] = id .. "|0|" .. power .. ";" .. energy}
end


-- CommandArray

commandArray = {}
-- Generated
PowerGeneration, EnergyGeneration = otherdevices_svalues[GenerationDeviceName]:match("([^;]+);([^;]+)")
if Debug=="YES" then
print(" ----- ---- ---- ---- ---- ---- ---- ---- ---- ");
print(" ----- PowerGeneration = " .. PowerGeneration .. " W");
print(" ----- EnergyGeneration = " .. EnergyGeneration .. " Wh");
print(" ----- ---- ---- ---- ---- ---- ---- ---- ---- ");
end

    -- Imported/Exported
    EnergyImportLow, EnergyImportHigh, EnergyExportLow, EnergyExportHigh, PowerImport, PowerExport = otherdevices_svalues[EnergyDeviceName]:match("([^;]+);([^;]+);([^$
    EnergyImport = EnergyImportLow + EnergyImportHigh
    EnergyExport = EnergyExportLow + EnergyExportHigh
    if Debug=="YES" then
            print("  ----- PowerImport = " .. PowerImport .. " W");
            print("  ----- EnergyImport = " .. EnergyImport .. " Wh");
            print("  ----- EnergyImportLow = " .. EnergyImportLow .. " Wh");
            print("  ----- EnergyImportHigh = " .. EnergyImportHigh .. " Wh");
            print("  ----- PowerExport = " .. PowerExport .. " W");
            print("  ----- EnergyExport = " .. EnergyExport .. " Wh");
            print("  ----- EnergyExportLow = " .. EnergyExportLow .. " Wh");
            print("  ----- EnergyExportHigh = " .. EnergyExportHigh .. " Wh");
    end

    -- Calculate consumption
    PowerConsumption = PowerGeneration + PowerImport - PowerExport
    EnergyConsumption = EnergyGeneration + EnergyImport - EnergyExport
    if Debug=="YES" then
            print("  ----- PowerConsumption = " .. PowerConsumption .. " W");
            print("  ----- EnergyConsumption = " .. EnergyConsumption .. " Wh");
    end

    -- Update consumption device in Domoticz
           PowerConsumption = PowerGeneration + PowerImport - PowerExport
    EnergyConsumption = EnergyGeneration + EnergyImport - EnergyExport
    if Debug=="YES" then
            print("  ----- PowerConsumption = " .. PowerConsumption .. " W");
            print("  ----- EnergyConsumption = " .. EnergyConsumption .. " Wh");
    end

    -- Update consumption device in Domoticz
    if devicechanged[EnergyDeviceName] then
            update(ConsumptionDeviceName, ConsumptionIDX, PowerConsumption, EnergyConsumption, 1)
    end

return commandArray
``
After running you will find
Expected behavior
You would expect to get the following result:
2019-10-12 22:35:37.731 Status: LUA: ----- ---- ---- ---- ---- ---- ---- ---- ----
2019-10-12 22:35:37.731 Status: LUA: ----- PowerGeneration = 1 W
2019-10-12 22:35:37.731 Status: LUA: ----- EnergyGeneration = 2426100.0 Wh
2019-10-12 22:35:37.731 Status: LUA: ----- ---- ---- ---- ---- ---- ---- ---- ----

But instead I get:

2019-10-12 22:35:37.731 Status: LUA: ----- ---- ---- ---- ---- ---- ---- ---- ----
2019-10-12 22:35:37.731 Status: LUA: ----- PowerGeneration = 1W W
2019-10-12 22:35:37.731 Status: LUA: ----- EnergyGeneration = 2426100.0 Wh
2019-10-12 22:35:37.731 Status: LUA: ----- ---- ---- ---- ---- ---- ---- ---- ----

Screenshots
If applicable, add screenshots to help explain your problem.

Domoticz environment (please complete the following information):

  • Domoticz Version: [e.g. 4.10717]
  • Python Version: Python 2.7.13 (default, Sep 26 2018, 18:42:22)

Additional context
Add any other context about the problem here.

Total generation not visable?

Describe the bug

Tried to figure out myself but (ofcourse) could not find the solution.
Although the "Devices" (Apparaten) tab shows the total generation of my panels over the years (12475.100kWh) the representation of it shows only the daily generation.
Hope the pictures explain.

totaal 2
totaal switch
I tried to play around with the line :
Devices[self.baseDeviceIndex + 4].Update(nValue=0, sValue=str(inverter["output_power"]) + ";" + str(inverter["etotal"] * 1000))
In the python script, but (I cleared cache in the browser) this did not work for me.
I did some logging on it and found the following line in the log:

2019-11-01 12:27:47.073 (Totaal gegenereerd Paneel) Updating device from 0:'382W;12475200.0' to have values 0:'392W;12475300.0'.
So looking at this, the update is correct but the "Domotics switch" shows only the first value (382W) and disregarding the second value (12475300)

Domoticz environment Raspberry PI (please complete the following information):

  • Domoticz Version: e.g. 4.10717]
  • Python Version: e.g. 3.4.4

Plugin doesn't work when entering power station id

Describe the bug
When entering the optional power station ID in the Plugin config an error occurs:
2020-03-15 20:53:37.559 Error: (Zonnepanelen) 'onMessage' failed 'AttributeError':''str' object has no attribute 'id''. 2020-03-15 20:53:37.559 Error: (Zonnepanelen) ----> Line 368 in '/home/pi/domoticz/plugins/domoticz-GoodWeSEMS/plugin.py', function onMessage 2020-03-15 20:53:37.559 Error: (Zonnepanelen) ----> Line 192 in '/home/pi/domoticz/plugins/domoticz-GoodWeSEMS/plugin.py', function onMessage 2020-03-15 20:53:37.559 Error: (Zonnepanelen) ----> Line 287 in '/home/pi/domoticz/plugins/domoticz-GoodWeSEMS/GoodWe.py', function stationDataRequest

To Reproduce
Steps to reproduce the behavior:
add optional powerstation id and update plugin

Expected behavior
no error

Screenshots
If applicable, add screenshots to help explain your problem.

Domoticz environment (please complete the following information):

  • Domoticz Version: lastest dev
  • Python Version: 3.7
  • plugin version 1.2.2

Question: Any idea why the API requires "agreement_agreement: 1"?

Hi Dylian,

Thanks for you plugin. I'm the maintainer of a similar plugin for HomeAssistant. :) (https://github.com/TimSoethout/goodwe-sems-home-assistant)

When I do the post to /api/v2/Common/CrossLogin I only send account and pwd but not the is_local and agreement_agreement fields. It does seem to work. In a previous version I do send the agreement_agreement.

However, now some of my users have issues with the login token expiring too quickly. Do the extra field with this maybe?

I hope we can swap notes this way and you might have any clues on this. :)

Inverter temperature log no data when inverter offline

First/offtopic: Thank you for writing the GoodWeSEMS plugin. It is great to be able to log solar panel data again.

Most domoticz temperature logs do not log data when no data is available. This makes shure average temparutures are somewhat accurate and graphs make sense.

When my inverter turned off the inverter temperature turned to 0. this made the graph below.

image

I do not consider this a bug more a consitency issue/refinemend, thus logged as a feature request.

Power graph 2x higher then domotic value

The power in the domoticz screen is way lower then the value shown in the graph. This seems to be an factor 2. Yhe value shown in de domoticz screen and the value in the sems portal seem to match nicely. What is wrong with the graphs? Am I doing something wrong? setting??

best regards,

Arno

Add support for 3-phase inverter

I would like te see if:

  1. The Inverter is Off or On
  2. In case of a 3 fase-inverter the different AC-Voltage per fase
  3. In case of a 3 fase-inverter the different AC-Current per fase
  4. The AC-Frequency or in case of a 3 fase-inverter the different AC-frequencies per fase
    5 The DC-voltage/current per string.

See the corresponding red numbers in the screenshot.

Sems-Portal

Thank you,

Pieter

see PV voltage

Is your feature request related to a problem? Please describe.
Not a problem, just a feature update.

Describe the solution you'd like
Also pull string voltage(s) from Goodwe Server.

Additional context
I'm looking in to the "shadow mode" of the goodwe inverter. This data would help me alot.

already lots of thanks for putting the time into this python script. Much appreciated!

'onMessage' failed 'TypeError':'string indices must be integers'.

Log is showing me:
2019-11-25 19:06:50.782 Error: (puppypowers) 'onMessage' failed 'TypeError':'string indices must be integers'.
2019-11-25 19:06:50.782 Error: (puppypower) ----> Line 307 in '/home/domoticz/plugins/domoticz-GoodWeSEMS/plugin.py', function onMessage
2019-11-25 19:06:50.782 Error: (puppypowers) ----> Line 217 in '/home/domoticz/plugins/domoticz-GoodWeSEMS/plugin.py', function onMessage

To Reproduce
Steps to reproduce the behavior:

  1. Enabled and configured the plugin

Expected behavior
A working plugin :)

Domoticz environment (please complete the following information):
Raspbian GNU/Linux 9.11

  • Domoticz Version: [e.g. 4.10717]
    10717
  • Python Version: [e.g. 3.7]
    python -V:
    Python 2.7.13
    python3 -V:
    Python 3.5.3

Additional context
Add any other context about the problem here.

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.