GoodWe Solar: get data from the new semsportal (lua script)
Moderator: leecollings
-
- Posts: 8
- Joined: Tuesday 30 July 2019 23:01
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: GoodWe Solar: get data from the new semsportal (lua script)
Thanks hoping to get this to work though (steep learning curve for me), got the first 120 lines working now, don't ask me how. but am now stuck at 121 in function getSessionID
Error: EventSystem: in anything: [string "-- Created by Raymond Wiertz..."]:121: bad argument #1 to 'sub' (string expected, got nil)
Errors are quite vague in my opinion, as in not clear as what to do to fix it.
Error: EventSystem: in anything: [string "-- Created by Raymond Wiertz..."]:121: bad argument #1 to 'sub' (string expected, got nil)
Errors are quite vague in my opinion, as in not clear as what to do to fix it.
-
- Posts: 8
- Joined: Tuesday 30 July 2019 23:01
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: GoodWe Solar: get data from the new semsportal (lua script)
Lines 116 and 117 where commented out for some reason. no more errors but no data showing either. will continue to troubleshoot.Peter2807 wrote: ↑Wednesday 31 July 2019 16:00 Thanks hoping to get this to work though (steep learning curve for me), got the first 120 lines working now, don't ask me how. but am now stuck at 121 in function getSessionID
Error: EventSystem: in anything: [string "-- Created by Raymond Wiertz..."]:121: bad argument #1 to 'sub' (string expected, got nil)
Errors are quite vague in my opinion, as in not clear as what to do to fix it.
-
- Posts: 8
- Joined: Tuesday 30 July 2019 23:01
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: GoodWe Solar: get data from the new semsportal (lua script)
Sincze, what pre-requisites besides php 7 are needed when running this script on a Synology? I''m getting a few warnings:
PHP Warning: Constants may only evaluate to scalar values in /volume1/@appstore/domoticz/var/scripts/pass2php/Goodwe.php on line 56
Warning: Constants may only evaluate to scalar values in /volume1/@appstore/domoticz/var/scripts/pass2php/Goodwe.php on line 56
PHP Warning: Constants may only evaluate to scalar values in /volume1/@appstore/domoticz/var/scripts/pass2php/Goodwe.php on line 63
Warning: Constants may only evaluate to scalar values in /volume1/@appstore/domoticz/var/scripts/pass2php/Goodwe.php on line 63
PHP Notice: Use of undefined constant LOGINHEADER - assumed 'LOGINHEADER' in /volume1/@appstore/domoticz/var/scripts/pass2php/Goodwe.php on line 84
Notice: Use of undefined constant LOGINHEADER - assumed 'LOGINHEADER' in /volume1/@appstore/domoticz/var/scripts/pass2php/Goodwe.php on line 84
PHP Warning: curl_setopt(): You must pass either an object or an array with the CURLOPT_HTTPHEADER argument in /volume1/@appstore/domoticz/var/scripts/pass2php/Goodwe.php on line 84
Warning: curl_setopt(): You must pass either an object or an array with the CURLOPT_HTTPHEADER argument in /volume1/@appstore/domoticz/var/scripts/pass2php/Goodwe.php on line 84
PHP Warning: Constants may only evaluate to scalar values in /volume1/@appstore/domoticz/var/scripts/pass2php/Goodwe.php on line 56
Warning: Constants may only evaluate to scalar values in /volume1/@appstore/domoticz/var/scripts/pass2php/Goodwe.php on line 56
PHP Warning: Constants may only evaluate to scalar values in /volume1/@appstore/domoticz/var/scripts/pass2php/Goodwe.php on line 63
Warning: Constants may only evaluate to scalar values in /volume1/@appstore/domoticz/var/scripts/pass2php/Goodwe.php on line 63
PHP Notice: Use of undefined constant LOGINHEADER - assumed 'LOGINHEADER' in /volume1/@appstore/domoticz/var/scripts/pass2php/Goodwe.php on line 84
Notice: Use of undefined constant LOGINHEADER - assumed 'LOGINHEADER' in /volume1/@appstore/domoticz/var/scripts/pass2php/Goodwe.php on line 84
PHP Warning: curl_setopt(): You must pass either an object or an array with the CURLOPT_HTTPHEADER argument in /volume1/@appstore/domoticz/var/scripts/pass2php/Goodwe.php on line 84
Warning: curl_setopt(): You must pass either an object or an array with the CURLOPT_HTTPHEADER argument in /volume1/@appstore/domoticz/var/scripts/pass2php/Goodwe.php on line 84
-
- Posts: 15
- Joined: Monday 04 August 2014 18:43
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Netherlands
- Contact:
Re: GoodWe Solar: get data from the new semsportal (lua script)
Scripts is woking fine for a while. Then i had some troubles with my router. That is fixed, but i think i have since that time an error:
Error: EventSystem: in Goodwe portal: [string "-- Note: The GoodWe data is refreshed every 6..."]:116: attempt to perform arithmetic on a nil value
on line 116 the code is dayTotal = tonumber(eDay)*1000
lines 115 etc
current = tonumber(stripchars(output_power, "kwhKWH"))
dayTotal = tonumber(eDay)*1000
UpdateDevice(sensorSolarPanels, current..";"..dayTotal)
end
Anyone an idea why i get this message.
voltage and current are updated.
Error: EventSystem: in Goodwe portal: [string "-- Note: The GoodWe data is refreshed every 6..."]:116: attempt to perform arithmetic on a nil value
on line 116 the code is dayTotal = tonumber(eDay)*1000
lines 115 etc
current = tonumber(stripchars(output_power, "kwhKWH"))
dayTotal = tonumber(eDay)*1000
UpdateDevice(sensorSolarPanels, current..";"..dayTotal)
end
Anyone an idea why i get this message.
voltage and current are updated.
- sincze
- Posts: 1299
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: GoodWe Solar: get data from the new semsportal (lua script)
Hi Peter.
Please try latest version here: https://github.com/sincze/Domoticz/blob ... Goodwe.php
Checked on my DS412
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
-
- Posts: 8
- Joined: Tuesday 30 July 2019 23:01
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: GoodWe Solar: get data from the new semsportal (lua script)
Sincze, I downloaded and modified the script, deleted old sensors and created new ones just to be sure. No errors or warnings when executing the script however no data seems to be coming in, also nothing in the log indicating anything is running besides what was already running. Will investigate over the weekend. Thanks for now.sincze wrote: ↑Thursday 01 August 2019 18:21Hi Peter.
Please try latest version here: https://github.com/sincze/Domoticz/blob ... Goodwe.php
Checked on my DS412
- sincze
- Posts: 1299
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: GoodWe Solar: get data from the new semsportal (lua script)
Please turn Debug On. Do it will show you the results in between is the cookie created?
Does it say cookie writable?
If not... You will see no data indeed and no errors.
Does it say cookie writable?
If not... You will see no data indeed and no errors.
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
-
- Posts: 8
- Joined: Tuesday 30 July 2019 23:01
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: GoodWe Solar: get data from the new semsportal (lua script)
Cookie is writable, and changes every few minutes (new timestamp and inside a see a new session-ID)
Now trying to figure out how and where to turn on debugging
Been looking at the Pass2PhP sub-forum also, sofar not helpful looking in the wrong topics most likely.
- sincze
- Posts: 1299
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: GoodWe Solar: get data from the new semsportal (lua script)
It is the variable "debug" on top of the script.
So cookie is created. That is good.
Now look at the Domoticz logging for the debug lines.
We can add additional ones in the script is needed.
But first check what Domoticz log says.
So cookie is created. That is good.
Now look at the Domoticz logging for the debug lines.
We can add additional ones in the script is needed.
But first check what Domoticz log says.
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
-
- Posts: 8
- Joined: Tuesday 30 July 2019 23:01
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: GoodWe Solar: get data from the new semsportal (lua script)
Sincze,
For as far as I can see the script is running all the way to the end (without errors), I put some typo's in it to see what happened and sure I got syntax errors. It looks like it's working the only problem is I don't see any data being displayed.
It would be nice to see what the script is doing and where it's keeping the temporary data.
This is the log (removed some duplicate lines.)
For as far as I can see the script is running all the way to the end (without errors), I put some typo's in it to see what happened and sure I got syntax errors. It looks like it's working the only problem is I don't see any data being displayed.
It would be nice to see what the script is doing and where it's keeping the temporary data.
This is the log (removed some duplicate lines.)
- 2019-08-02 19:26:27.061 Status: Domoticz V4.10717 (c)2012-2019 GizMoCuz
2019-08-02 19:26:27.061 Status: Build Hash: b38b49e-modified, Date: 2019-05-09 13:04:08
2019-08-02 19:26:27.061 Status: Startup Path: /usr/local/domoticz/
2019-08-02 19:26:27.122 Status: PluginSystem: Started, Python version '3.5.1'.
2019-08-02 19:26:27.127 Status: WebServer(HTTP) started on address: :: with port 8084
2019-08-02 19:26:27.130 Status: WebServer(SSL) started on address: :: with port 8443
2019-08-02 19:26:27.132 Status: TCPServer: shared server started...
2019-08-02 19:26:27.132 Status: RxQueue: queue worker started...
2019-08-02 19:26:29.133 Status: P1 Smart Meter: Using serial port: /dev/ttyUSB0
2019-08-02 19:26:29.145 Status: P1 Smart Meter: Worker started...
2019-08-02 19:26:29.145 Status: Panasonic Plugin: Started
2019-08-02 19:26:29.145 Status: EventSystem: reset all events...
2019-08-02 19:26:29.146 Status: EventSystem: reset all device statuses...
2019-08-02 19:26:29.191 Status: Python EventSystem: Initalizing event module.
2019-08-02 19:26:29.191 Status: EventSystem: Started
2019-08-02 19:26:29.191 Status: EventSystem: Queue thread started...
2019-08-02 19:26:29.245 Status: Panasonic Plugin: (Woonkamer) Starting thread.
2019-08-02 19:26:29.246 Status: Panasonic Plugin: (Woonkamer) started.
2019-08-02 19:26:29.575 Status: PluginSystem: Entering work loop.
2019-08-02 19:26:37.284 Status: P1 Smart Meter: Meter reports as DSMR 4.2
2019-08-02 19:26:37.694 Status: P1 Smart Meter: Found gas meter on M-Bus channel 1
2019-08-02 20:00:00.337 Status: Starting automatic database backup procedure...
2019-08-02 20:00:00.517 Status: Ending automatic database backup procedure...
2019-08-02 23:00:00.954 Status: Starting automatic database backup procedure...
2019-08-02 23:00:01.142 Status: Ending automatic database backup procedure...
2019-08-03 00:00:00.926 Status: EventSystem: reset all events...
2019-08-03 00:00:00.937 Status: Starting automatic database backup procedure...
2019-08-03 00:00:01.521 Status: Ending automatic database backup procedure...
2019-08-03 01:00:00.378 Status: Starting automatic database backup procedure...
2019-08-03 12:36:22.906 Status: Incoming connection from: 192.168.1.101
2019-08-03 12:43:39.129 Status: EventSystem: reset all device statuses...
2019-08-03 13:00:00.674 Status: Starting automatic database backup procedure...
2019-08-03 13:00:00.889 Status: Ending automatic database backup procedure...
2019-08-03 13:12:48.422 Status: EventSystem: reset all device statuses...
2019-08-03 13:14:25.005 Status: EventSystem: reset all device statuses...
2019-08-03 13:20:47.969 (Slimme meter) P1 Smart Meter (Power)
2019-08-03 13:20:47.969 (Slimme meter) Usage (Usage L1)
2019-08-03 13:20:47.969 (Slimme meter) Usage (Delivery L1)
2019-08-03 13:20:57.989 (Slimme meter) P1 Smart Meter (Power)
- sincze
- Posts: 1299
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: GoodWe Solar: get data from the new semsportal (lua script)
Do you have a username and password on your Domoticz ?
Did you double check the port 8084 on Synology Vs 8080 on a pi?
Are you allowed to make curl calls to Domoticz without username and password.
Change lg debug statements to echo and you should see it on your screen instead of Domoticz log
Did you double check the port 8084 on Synology Vs 8080 on a pi?
Are you allowed to make curl calls to Domoticz without username and password.
Change lg debug statements to echo and you should see it on your screen instead of Domoticz log
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
-
- Posts: 8
- Joined: Tuesday 30 July 2019 23:01
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: GoodWe Solar: get data from the new semsportal (lua script)
Changing lg to echo got me this:
Goodwe JSON results Found! Goodwe: 433 W, today: 2.6 kWh, Inverter total: 10352 kwH for domoticz: 433;10352000 (udevice) | 16 => 0,433;10352000
So it looks as the script is working, still no nice graph in Domoticz
Port 8080 is what needed to be changed to 8084, so finally I'm seeing something on my screen (to bad not much sun today)
Next thing on the nice to have list is a way to import all the old data (4 years) to be displayed. I know the data is available just not how to get it.
Sincze bedankt. (ie thanks for those not speaking dutch)
Goodwe JSON results Found! Goodwe: 433 W, today: 2.6 kWh, Inverter total: 10352 kwH for domoticz: 433;10352000 (udevice) | 16 => 0,433;10352000
So it looks as the script is working, still no nice graph in Domoticz
Port 8080 is what needed to be changed to 8084, so finally I'm seeing something on my screen (to bad not much sun today)
Next thing on the nice to have list is a way to import all the old data (4 years) to be displayed. I know the data is available just not how to get it.
Sincze bedankt. (ie thanks for those not speaking dutch)
- Attachments
-
- generated-last-24-hours.jpeg (43.1 KiB) Viewed 3146 times
- sincze
- Posts: 1299
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: GoodWe Solar: get data from the new semsportal (lua script)
Excellent what 1 port change can doPeter2807 wrote: ↑Saturday 03 August 2019 15:26 Changing lg to echo got me this:
Goodwe JSON results Found! Goodwe: 433 W, today: 2.6 kWh, Inverter total: 10352 kwH for domoticz: 433;10352000 (udevice) | 16 => 0,433;10352000
So it looks as the script is working, still no nice graph in Domoticz
Port 8080 is what needed to be changed to 8084, so finally I'm seeing something on my screen (to bad not much sun today)
Next thing on the nice to have list is a way to import all the old data (4 years) to be displayed. I know the data is available just not how to get it.
Sincze bedankt. (ie thanks for those not speaking dutch)
Change echo back to lg and it will show the log in Domoticz.
Bedankt voor het testen van het script
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
-
- Posts: 59
- Joined: Tuesday 09 May 2017 23:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: NL
- Contact:
Re: GoodWe Solar: get data from the new semsportal (lua script)
I am having the same problem, where on Monday the total yield of Sunday is being used. Must be an issue surrounding the day number where on day 7 (or 0, I am not sure about that) a counter is not reset. This problem does not occur however when using the detour via PVOutput.org.Kencirot wrote: ↑Wednesday 05 June 2019 14:56 I experience the same issue as Marktap. The daily total of previous day is being used untill the currect day is higher for me.
I also notice when there is no power output I still get the last remain known output showing up (e.g 36Watts from 22:00h onwards till the morning).
Is there a way to set it to "0" when the solar system is offline?
solar.PNG
A workaround could be a reset of eDay the first time on Monday using os.time() and timedifference just before updating dayTotal, line 186. My lua knowledge is not good enough to implement this myself. Any coding suggestions anyone?
-‐----------------------------------------------------------
Running on rPi 3b (main) and rPi 2b (somfy), both RFLink
IthoRemote, Xiaomi Gateway, KAKU
Running on rPi 3b (main) and rPi 2b (somfy), both RFLink
IthoRemote, Xiaomi Gateway, KAKU
-
- Posts: 59
- Joined: Tuesday 09 May 2017 23:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: NL
- Contact:
Re: GoodWe Solar: get data from the new semsportal (lua script)
Seems to be a little different after all. Now it is tuesday and my dayTotal-value for tuesday has already been set, with the value that was reached on monday! Could there be a timing issue? Would forcing the script to run at 0:00hrs fix the issue?bldewit wrote: ↑Monday 05 August 2019 9:04I am having the same problem, where on Monday the total yield of Sunday is being used. Must be an issue surrounding the day number where on day 7 (or 0, I am not sure about that) a counter is not reset. This problem does not occur however when using the detour via PVOutput.org.Kencirot wrote: ↑Wednesday 05 June 2019 14:56 I experience the same issue as Marktap. The daily total of previous day is being used untill the currect day is higher for me.
I also notice when there is no power output I still get the last remain known output showing up (e.g 36Watts from 22:00h onwards till the morning).
Is there a way to set it to "0" when the solar system is offline?
solar.PNG
A workaround could be a reset of eDay the first time on Monday using os.time() and timedifference just before updating dayTotal, line 186. My lua knowledge is not good enough to implement this myself. Any coding suggestions anyone?
-‐----------------------------------------------------------
Running on rPi 3b (main) and rPi 2b (somfy), both RFLink
IthoRemote, Xiaomi Gateway, KAKU
Running on rPi 3b (main) and rPi 2b (somfy), both RFLink
IthoRemote, Xiaomi Gateway, KAKU
- sincze
- Posts: 1299
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: GoodWe Solar: get data from the new semsportal (lua script)
Are you sending E_Current;E_daily (total generated today) to your sensor or the E_Current;E_Total (total generated since install) from the inverter?
If it is the first it is known, the sensor only accepts an incremental counter. Resetting it daily to 0 will not do the trick.
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
- sincze
- Posts: 1299
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: GoodWe Solar: get data from the new semsportal (lua script)
For peopele still experiencing LUA issues.
New Python Semsportal plugin introduced here: https://github.com/dylian94/domoticz-GoodWeSEMS
New Python Semsportal plugin introduced here: https://github.com/dylian94/domoticz-GoodWeSEMS
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
-
- Posts: 27
- Joined: Thursday 26 September 2019 10:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: GoodWe Solar: get data from the new semsportal (lua script)
Good morning,
i have some problems with uploading the right data to pvoutput.org the enrgy used and power Used are continues on 0 in stead of data.
so what am is doing wrong?
i am using the following 2 scripts.
i have also the sems portal plugin in my domoticz.
Device Calculation script.
TIME SCRIPT
I get also the following error in domoticz log
...ticz/scripts/lua/script_device_calculate_consumption.lua:71: attempt to perform arithmetic on global 'PowerGeneration' (a string value)
2019-09-26 10:39:45.976 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_calculate_consumption.lua: ...ticz/scripts/lua/script_device_calculate_consumption.lua:71: attempt to perform arithmetic on global 'PowerGeneration' (a string value)
2019-09-26 10:39:45.995 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_calculate_consumption.lua: ...ticz/scripts/lua/script_device_calculate_consumption.lua:71: attempt to perform arithmetic on global 'PowerGeneration' (a string value)
i also think something is wrong with the energy import high and low.
because the low is higher than the importhigh
2019-09-26 10:44:18.992 Status: LUA: ----- EnergyGeneration = 339500.0 Wh
2019-09-26 10:44:18.992 Status: LUA: ----- PowerImport = 64 W
2019-09-26 10:44:18.992 Status: LUA: ----- EnergyImportLow = 51778 Wh
2019-09-26 10:44:18.992 Status: LUA: ----- EnergyImportHigh = 26840 Wh
2019-09-26 10:44:18.992 Status: LUA: ----- EnergyImport = 78618 Wh
2019-09-26 10:44:18.992 Status: LUA: ----- PowerExport = 0 W
2019-09-26 10:44:18.992 Status: LUA: ----- EnergyExportLow = 39607 Wh
2019-09-26 10:44:18.992 Status: LUA: ----- EnergyExportHigh = 75129 Wh
so what script do i have to use to get the right data to pvoutput.org and what am i doing wrong?
i have some problems with uploading the right data to pvoutput.org the enrgy used and power Used are continues on 0 in stead of data.
so what am is doing wrong?
i am using the following 2 scripts.
i have also the sems portal plugin in my domoticz.
Device Calculation script.
Code: Select all
-- /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 = "CurrentOutput" -- Device name of the Generated energy
local EnergyDeviceName = "Power" -- Name of the energy device that shows imported and exported energy
local ConsumptionIDX = 31 -- IDX of the energy device that shows calculated Consumption
local ConsumptionDeviceName = "ConsumptionDevice" -- Name of the energy device that shows calculated Consumption
----------------------------------------------------------------------------------------------------------
-- Require parameters
----------------------------------------------------------------------------------------------------------
local http = require("socket.http")
----------------------------------------------------------------------------------------------------------
-- Script parameters
----------------------------------------------------------------------------------------------------------
EnergyImportLow = 0 -- in Watt hours
EnergyImportHigh = 0 -- in Watt hours
EnergyExportLow = 0 -- in Watt hours
EnergyExportHigh = 0 -- in Watt hours
EnergyGeneration = 0 -- in Watt hours
PowerGeneration = 0 -- in Watts
EnergyImport = 0 -- in Watt hours
PowerImport = 0 -- in Watts
EnergyConsumption = 0 -- in Watt hours
PowerConsumption = 0 -- in Watts
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(" ----- PowerGeneration = " .. PowerGeneration .. " W");
print(" ----- EnergyGeneration = " .. EnergyGeneration .. " Wh");
end
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(" ----- EnergyImportLow = " .. EnergyImportLow .. " Wh");
print(" ----- EnergyImportHigh = " .. EnergyImportHigh .. " Wh");
print(" ----- EnergyImport = " .. EnergyImport .. " Wh");
print(" ----- PowerExport = " .. PowerExport .. " W");
print(" ----- EnergyExportLow = " .. EnergyExportLow .. " Wh");
print(" ----- EnergyExportHigh = " .. EnergyExportHigh .. " Wh");
print(" ----- EnergyExport = " .. EnergyExport .. " Wh");
end
-- Calculate consumption
PowerConsumption = PowerGeneration + PowerImport - PowerExport
if Debug=="YES" then
print(" ----- PowerConsumption = " .. PowerConsumption .. " W");
end
EnergyConsumption = EnergyGeneration + EnergyImport - EnergyExport
if Debug=="YES" then
print(" ----- EnergyConsumption = " .. EnergyConsumption .. " Wh");
end
-- Update comsumption device in Domoticz
if devicechanged[EnergyDeviceName] then
update(ConsumptionDeviceName, ConsumptionIDX, PowerConsumption, EnergyConsumption, 1)
end
return commandArray
TIME SCRIPT
Code: Select all
-- /home/pi/domoticz/scripts/lua/script_time_upload_to_PVoutput.lua
-- This script collects the values below from Domoticz
-- * The Power generation, energy generation and voltage from a Solar power inverter
-- * The temperature from a outside temperature sensor
-- * The Power consumption and energy consumption which is calculated in another Lua script
-- And uploads all of the values to a PVoutput account.
--
-- For more information about PVoutput, see their user documentation on http://www.pvoutput.org/help.html
----------------------------------------------------------------------------------------------------------
-- Domoticz IDX of devices
----------------------------------------------------------------------------------------------------------
local GenerationDeviceName = "PowerOutput" -- Device name of the Generated energy
local ConsumptionDeviceName = "ConsumptionDevice" -- Name of the energy device that shows calculated Consumption
local VoltageDeviceName = "VoltageOutput" -- Name of the voltage device that shows voltage of the inverter
local TemperatureDeviceName = "Temperatuur" -- Name of the temperature device that shows outside temperature
----------------------------------------------------------------------------------------------------------
-- PVoutput parameters
----------------------------------------------------------------------------------------------------------
local PVoutputApi = "c550e7568ba649922fd015828f********" -- Your PVoutput api key
local PVoutputSystemID = "699" -- Your PVoutput System ID
local PVoutputPostInterval = 5 -- The number of minutes between posts to PVoutput (normal is 5 but when in donation mode it's max 1)
local PVoutputURL = '://pvoutput.org/service/r2/addstatus.jsp?key=' -- The URL to the PVoutput Service
----------------------------------------------------------------------------------------------------------
-- Require parameters
----------------------------------------------------------------------------------------------------------
local http = require("socket.http")
----------------------------------------------------------------------------------------------------------
-- Script parameters
----------------------------------------------------------------------------------------------------------
EnergyGeneration = 0 -- v1 in Watt hours
PowerGeneration = 0 -- v2 in Watts
EnergyConsumption = 0 -- v3 in Watt hours
PowerConsumption = 0 -- v4 in Watts
CurrentTemp = 0 -- v5 in celcius
Voltage = 0 -- v6 in volts
c1 = 1 -- c1 = 0 when v1 is today's energy. c1 = 1 when v1 is lifetime energy.
Debug = "YES" -- Turn debugging on ("YES") or off ("NO")
----------------------------------------------------------------------------------------------------------
-- Lua Functions
----------------------------------------------------------------------------------------------------------
function UploadToPVoutput(self)
b, c, h = http.request("http" .. PVoutputURL .. PVoutputApi .. "&sid=".. PVoutputSystemID .. "&d=" .. os.date("%Y%m%d") .. "&t=" .. os.date("%H:%M") ..
"&v1=" .. EnergyGeneration .. "&v2=" .. PowerGeneration .. "&v3=" .. EnergyConsumption .. "&v4=" .. PowerConsumption .. "&v5=" .. CurrentTemp .. "&v6=" .. Voltage .. "&c1=" .. c1 )
if b=="OK 200: Added Status" then
print(" -- Current status successfully uploaded to PVoutput.org")
else
print(" -- " ..b)
end
print(" --Energy generation (v1) = ".. EnergyGeneration .. " Wh")
print(" --Power generation (v2) = " .. PowerGeneration .. " W")
print(" --Energy consumption (v3) = " .. EnergyConsumption .. " Wh")
print(" --Power consumption (v4) = " .. PowerConsumption .. " W")
print(" --Current temperature (v5) = " .. CurrentTemp .. " C")
print(" --Voltage (v6) = " .. Voltage .. "V")
print(" --Cumulative Flag (c1) = " .. c1 .. "")
end
function update(device, id, power, energy, index)
commandArray[index] = {['UpdateDevice'] = id .. "|0|" .. power .. ";" .. energy}
end
----------------------------------------------------------------------------------------------------------
-- CommandArray
----------------------------------------------------------------------------------------------------------
commandArray = {}
time = os.date("*t")
if PVoutputPostInterval > 1 then
TimeToGo = PVoutputPostInterval - (time.min % PVoutputPostInterval)
print('Time to go before upload to PVoutput: ' ..TimeToGo.. " minutes")
end
if((time.min % PVoutputPostInterval)==0)then
-- Generated
PowerGeneration, EnergyGeneration = otherdevices_svalues[GenerationDeviceName]:match("([^;]+);([^;]+)")
if Debug=="YES" then
print(" ---- The total generated energy is " .. EnergyGeneration .. " Wh");
print(" ---- The current generated power is " .. PowerGeneration .. " W");
end
-- Voltage
Voltage = otherdevices_svalues[VoltageDeviceName] :match("([^;]+)")
if Debug=="YES" then
print(" ---- The voltage of the inverter is " .. Voltage .. " V");
end
-- Temperature
CurrentTemp = otherdevices_svalues[TemperatureDeviceName]:match("([^;]+)")
if Debug=="YES" then
print(" ---- The outside temperature is " .. CurrentTemp .. " C.");
end
--EnergyGeneration = "0"
--PowerGeneration = "0"
-- Consumption
EnergyConsumption, PowerConsumption = otherdevices_svalues[ConsumptionDeviceName]:match("([^;]+);([^;]+)")
if Debug=="YES" then
print(" ---- The total consumed energy is " .. EnergyConsumption .. " Wh");
print(" ---- The current consumed power is " .. PowerConsumption .. " W");
end
-- Upload data to PVoutput
UploadToPVoutput()
end
return commandArray
...ticz/scripts/lua/script_device_calculate_consumption.lua:71: attempt to perform arithmetic on global 'PowerGeneration' (a string value)
2019-09-26 10:39:45.976 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_calculate_consumption.lua: ...ticz/scripts/lua/script_device_calculate_consumption.lua:71: attempt to perform arithmetic on global 'PowerGeneration' (a string value)
2019-09-26 10:39:45.995 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_calculate_consumption.lua: ...ticz/scripts/lua/script_device_calculate_consumption.lua:71: attempt to perform arithmetic on global 'PowerGeneration' (a string value)
i also think something is wrong with the energy import high and low.
because the low is higher than the importhigh
2019-09-26 10:44:18.992 Status: LUA: ----- EnergyGeneration = 339500.0 Wh
2019-09-26 10:44:18.992 Status: LUA: ----- PowerImport = 64 W
2019-09-26 10:44:18.992 Status: LUA: ----- EnergyImportLow = 51778 Wh
2019-09-26 10:44:18.992 Status: LUA: ----- EnergyImportHigh = 26840 Wh
2019-09-26 10:44:18.992 Status: LUA: ----- EnergyImport = 78618 Wh
2019-09-26 10:44:18.992 Status: LUA: ----- PowerExport = 0 W
2019-09-26 10:44:18.992 Status: LUA: ----- EnergyExportLow = 39607 Wh
2019-09-26 10:44:18.992 Status: LUA: ----- EnergyExportHigh = 75129 Wh
so what script do i have to use to get the right data to pvoutput.org and what am i doing wrong?
-
- Posts: 21
- Joined: Friday 28 December 2018 20:23
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.1
- Contact:
Re: GoodWe Solar: get data from the new semsportal (lua script)
I do have the same problem: ...ticz/scripts/lua/script_device_calculate_consumption.lua:71: attempt to perform arithmetic on global 'PowerGeneration' (a string value)
The problem is not the energy import high and low. because the low is higher than the importhigh. High means in this context high tarif and low tarif.
The problem is something with the global "PowerGenaration" For debugging I edited the script with the following rules before the error:
if Debug=="YES" then
print(" ---------------------------------------------------- ");
print(" ----- PowerConsumption = " .. PowerConsumption .. " W");
print(" ----- PowerGeneration = " .. PowerGeneration .. " W");
print(" ----- PowerImport = " .. PowerImport .. " W");
print(" ----- PowerExport = " .. PowerExport .. " W");
print(" -------------------------------------------");
end
PowerConsumption = PowerGeneration + PowerImport - PowerExport
With the result in the log:
2019-10-06 13:21:48.784 Status: LUA: ----------------------------------------------------
2019-10-06 13:21:48.784 Status: LUA: ----- PowerConsumption = 0 W
2019-10-06 13:21:48.784 Status: LUA: ----- PowerGeneration = 198W W
2019-10-06 13:21:48.784 Status: LUA: ----- PowerImport = 100 W
2019-10-06 13:21:48.784 Status: LUA: ----- PowerExport = 0 W
2019-10-06 13:21:48.784 Status: LUA: -------------------------------------------
2019-10-06 13:21:48.631 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_calculate_consumption.lua: ...ticz/scripts/lua/script_device_calculate_consumption.lua:82: attempt to perform arithmetic on global 'PowerGeneration' (a string value)
So the question is why does it not calculate Powerconsumption to 198+100-0 = 298
Anyone?
Thank you,
Pieter
The problem is not the energy import high and low. because the low is higher than the importhigh. High means in this context high tarif and low tarif.
The problem is something with the global "PowerGenaration" For debugging I edited the script with the following rules before the error:
if Debug=="YES" then
print(" ---------------------------------------------------- ");
print(" ----- PowerConsumption = " .. PowerConsumption .. " W");
print(" ----- PowerGeneration = " .. PowerGeneration .. " W");
print(" ----- PowerImport = " .. PowerImport .. " W");
print(" ----- PowerExport = " .. PowerExport .. " W");
print(" -------------------------------------------");
end
PowerConsumption = PowerGeneration + PowerImport - PowerExport
With the result in the log:
2019-10-06 13:21:48.784 Status: LUA: ----------------------------------------------------
2019-10-06 13:21:48.784 Status: LUA: ----- PowerConsumption = 0 W
2019-10-06 13:21:48.784 Status: LUA: ----- PowerGeneration = 198W W
2019-10-06 13:21:48.784 Status: LUA: ----- PowerImport = 100 W
2019-10-06 13:21:48.784 Status: LUA: ----- PowerExport = 0 W
2019-10-06 13:21:48.784 Status: LUA: -------------------------------------------
2019-10-06 13:21:48.631 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_calculate_consumption.lua: ...ticz/scripts/lua/script_device_calculate_consumption.lua:82: attempt to perform arithmetic on global 'PowerGeneration' (a string value)
So the question is why does it not calculate Powerconsumption to 198+100-0 = 298
Anyone?
Thank you,
Pieter
-
- Posts: 21
- Joined: Friday 28 December 2018 20:23
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.1
- Contact:
Re: GoodWe Solar: get data from the new semsportal (lua script)
A good look at my results in the log and I found this:
2019-10-06 13:21:48.784 Status: LUA: ----- PowerGeneration = 198W W
That's the problem I think. Now, find out what is the cause...
@sjoemie1985 : I think tou have the same problem. Just add the following two lines just before "PowerConsumption = PowerGeneration + PowerImport - PowerExport" in the script and check the result in your log.
print(" ----- PowerConsumption = " .. PowerConsumption .. " W");
print(" ----- PowerGeneration = " .. PowerGeneration .. " W");
2019-10-06 13:21:48.784 Status: LUA: ----- PowerGeneration = 198W W
That's the problem I think. Now, find out what is the cause...
@sjoemie1985 : I think tou have the same problem. Just add the following two lines just before "PowerConsumption = PowerGeneration + PowerImport - PowerExport" in the script and check the result in your log.
print(" ----- PowerConsumption = " .. PowerConsumption .. " W");
print(" ----- PowerGeneration = " .. PowerGeneration .. " W");
Who is online
Users browsing this forum: No registered users and 1 guest