Get local Enphase data from individual solar panels in domoticz

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Get local Enphase data from individual solar panels in domoticz

Post by waaren »

Yet another way of accessing the Enphase data. Make sure you read the comment lines and enter your settings..

History
0.201909210900 -- Start design / coding
0.201909251100 -- First version for forum
0.201909261300 -- Add automated change of inverter device Type to delivery
0.201910122300 -- Prepared for windows

As always please feel free to comment, ask for clarification, report bugs etc.. by replying here on the forum.

Have Fun !

Code: Select all

--[[

    This dzVents script is one approach to collect data from your local Enphase system

    It is inspired by the various postings on the domoticz forum about getting details
    from your own solar panels.

    The script uses the installer login for which an Android password generator tool
    is available. Full process description about the development of this tool can be found at

    https://thecomputerperson.wordpress.com/2016/08/28/reverse-engineering-the-enphase-installer-toolkit/

    the Android tool described can be downloaded from
    https://www.dropbox.com/s/xc40op8eqfrykaa/AndroidXam.AndroidXam.Signed2019.apk?dl=0

    The script uses wget calls and interprets the JSON returns.
    for Windows you can get a wget executable via https://eternallybored.org/misc/wget/

    If the createDevices switch is set to true. The script will create ALL the individual devices 
    if they do not exist on the system yet. (1 total and 1 per panel (so if you own 20 panels it creates 21 devices)

    Before activating the script:
    Please read the GETTING STARTED section of the dzVents wiki.
        For windows users download and install the wget utility
        Define a dummy hardware in domoticz if not already done
        Enter your settings at the appropriate place
        Have fun !!

    Please use the domoticz forum fore reporting bugs, asking questions for clarification, tips for improvement, etc..

    History
    0.201909210900 -- Start design / coding
    0.201909251100 -- First version for forum
    0.201909261300 -- Add automated change of inverter device Type to delivery
    0.201910122300 -- Prepared for windows

]]--

local scriptVersion = '0.201910122300'
local scriptVar  =  'Enphase_' .. scriptVersion
local frequency = 15 -- -- As far as I know Enphase reporting is only once / 15 minutes

return
{
    on =
    {
        timer = { 'every ' .. frequency .. ' minutes between sunrise and 45 minutes after sunset' }, 
    },

    logging =
    {
        level = domoticz.LOG_DEBUG, -- Change to info or Error if everything works as expected.
        marker = scriptVar,
    },

    data = { inverters = { initial = {} }},

    execute = function(dz)
        -- ==============================
        -- Your setting here
        -- ==============================
        -- Change to reflect location of your wget and remove -- ( comment ) in front of the declaration for your OS  
        -- wgetExecutable = '/usr/bin/wget'                 -- Linux
        -- wgetExecutable = 'c:\\"Program files"\\wget.exe' -- Windows: double back slashes where one is in the path

                local Enphase =    {
                                ip = 'xxx.xxx.xxx.xxx',         -- IP address of your local enphase hub
                                password = 'a2B4bdA',            -- Change to your calculated password. See description above on how to get this.

                                dummyHardwareIDX = XX,               -- Change to ID of your virtual hardware
                                useProduction = true,
                                productionDeviceName = 'Enphase production',
                                useInverters = true,
                                inverterDevicePrefix = 'micro inverter: ',  -- script use this prefix + serial number of inverter.
                                createDevices = true,              -- Should the script create devices if they are not defined yet.

                                -- please note that the counter display will only show a rough estimate
                                -- of the produced energy over the period the device lives in domoticz and the script is active.

        -- =========================================
        -- == No changes required below this line ==
        -- ==========================================
                                user = 'installer',                                     -- I think this is a fixed username
                                inverterDeviceType = 'Electric (instant+Counter)',      -- script use this type for inverters
                                productionDeviceType = 'Electric (instant+Counter)',    -- script use this type for total production
                                productionAPI = '/api/v1/production',
                                invertersAPI = '/api/v1/production/inverters',

                            }

        local function createEnphaseDevice(deviceType, deviceName)
            local sensorMappedTypes =   {
                                            ['Electric (instant+Counter)'] = '0xF31D',
                                            ['Youless'] = '0xFC01',
                                            ['Usage (electric)'] = '0xF801',
                                        }
            Enphase.openURLDelay = Enphase.openURLDelay or 0                 -- This wil lprevent domoticz to get overloaded by repetative createDevice calls
            local deviceName = dz.utils.urlEncode(deviceName)
            url =   dz.settings['Domoticz url'] .. '/json.htm?type=createdevice&idx=' ..
                    Enphase.dummyHardwareIDX .. '&sensorname=' ..
                    deviceName .. '&sensormappedtype='.. sensorMappedTypes[deviceType]
            dz.openURL(url).afterSec(Enphase.openURLDelay)
            Enphase.openURLDelay = Enphase.openURLDelay + 1
        end

        local function changeInverter2DeliveryType(inverter)
            Enphase.openURLDelay = Enphase.openURLDelay or 0
            url =   dz.settings['Domoticz url'] .. '/json.htm?type=setused&description=&switchtype=4&EnergyMeterMode=0&used=true' .. 
                    '&idx=' ..  inverter.id  ..
                    '&name=' .. dz.utils.urlEncode(inverter.name)
            dz.openURL(url).afterSec(Enphase.openURLDelay)
            dz.log('Changing inverter ' .. inverter.name ..' to delivery type: \n' .. url,dz.LOG_FORCE)
            Enphase.openURLDelay = Enphase.openURLDelay + 1
        end

        local function osCommand(cmd)
            dz.log(cmd,LOG_DEBUG)
            local fileHandle = assert(io.popen(cmd, 'r'))
            local commandOutput = assert(fileHandle:read('*a'))
            local returnTable = {fileHandle:close()}

            if returnTable[3] ~= 0 then
                dz.log("ReturnCode: " .. returnTable[3] .. "\ncommandOutput:\n" .. commandOutput, dz.LOG_ERROR)
            else
                return commandOutput
            end
            dz.log("ReturnCode: " .. returnTable[3] .. "\ncommandOutput:\n" .. commandOutput, dz.LOG_ERROR)
        end

        local function getEnphaseData(api)
            local baseCommand = wgetExecutable .. ' -T 3 --user ' .. Enphase.user .. ' --password ' .. Enphase.password ..' -O - '
            local cmd = baseCommand .. Enphase.ip .. api
            return osCommand(cmd)
        end

        local function updateInverter(device, newInverter, deviceName )
            if device then
                for _, oldInverter in ipairs(dz.data.inverters) do
                    if oldInverter['serialNumber'] == newInverter['serialNumber'] then -- ignore inverter if no history (will be there next run)
                        device.updateElectricity(newInverter['lastReportWatts'],device.WhTotal + tonumber(newInverter['lastReportWatts']) / ( 60 / frequency ) )
                        if device.switchTypeValue ~= 4 then changeInverter2DeliveryType(device) end
                        if dz.time.matchesRule('between 25 minutes after sunset and 23:59') then device.updateElectricity(0,device.WhTotal) end
                    end
                end
            else
                dz.log('Device ' .. deviceName .. ' does not exist. ', dz.LOG_ERROR)
            end
        end

        local function getInverters()
            return dz.utils.fromJSON(getEnphaseData(Enphase.invertersAPI) or {})
        end

        local function procesInverters(inverterTable)
            if inverterTable[1] == nil then
                dz.log('Empty return from Enphase. Go check it out', dz.LOG_ERROR)
                return
            end

            for _, inverter in ipairs(inverterTable) do
                local deviceName = Enphase.inverterDevicePrefix .. inverter.serialNumber
                if not(dz.utils.deviceExists(deviceName)) and Enphase.createDevices then
                    dz.log('Device ' .. deviceName .. ' will be created. ', dz.LOG_FORCE)
                    createEnphaseDevice(Enphase.inverterDeviceType, deviceName)
                else
                    updateInverter(dz.devices(deviceName), inverter, deviceName )
                end
           end
            dz.data.inverters = inverterTable -- store data for next run
        end

        local function getProduction()
           return dz.utils.fromJSON(getEnphaseData(Enphase.productionAPI) or {})
        end

        local function procesProduction(productionTable)
            if productionTable.wattsNow == nil then
                dz.log('Empty return from Enphase. Go check it out', dz.LOG_ERROR)
                return
            end

            local noDevice = not(dz.utils.deviceExists(Enphase.productionDeviceName))
            if noDevice and Enphase.createDevices then
                 dz.log('Device ' .. Enphase.productionDeviceName .. ' will be created. ', dz.LOG_FORCE)
                 createEnphaseDevice(Enphase.productionDeviceType, Enphase.productionDeviceName)
            elseif noDevice then
                dz.log('Device ' .. Enphase.productionDeviceName .. ' does not exist. ', dz.LOG_ERROR)
            else
                dz.devices(Enphase.productionDeviceName).updateElectricity(productionTable.wattsNow, productionTable.wattHoursLifetime )
            end
        end

        -- main
        if Enphase.useProduction then procesProduction(getProduction()) end
        if Enphase.useInverters then procesInverters(getInverters()) end
    end
}

Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Get local Enphase data from individual solar panels in domoticz

Post by FireWizard »

Hello waaren,

First of all, it is a good initiative, as I would like to see, that the data from individual solar panels, connected to Enphase, but also others, will be available in Domoticz.
I made already a suggestion in: viewtopic.php?f=31&t=29170&p=223951#p223951

Your dZVents script aims at the same goal.

I have seen several scripts, as well, that try to poll the individual inverters using this URL: http://<IP Address>/api/v1/production/inverters.
Like you, they all use the backdoor, with the installer username/password. I have no idea how to get the installer password, while I registered myself as an installer. The Android app works, I can confirm, but requires that users copy the apk file and enable the developer options.
Quite a complex way.

Going through the front door is, in my opinion, easier. It requires also a username/password.
Like the installer username, this username is also fixed, envoy. It is not necessary to configure the password as you can easily asked for it by polling e.g. http://<IP Address>/info.xml. You will find after "sn".

The only challenge, you get is that this URL doesn't use basic authentication, but digest authentication.
For wget I found something here: https://www.computerhope.com/unix/wget.htm.
Digest Authentication has already been done in Domoticz. Curl supports it, as well.

If you are able to get this authentication issue solved, access is much easier, than installing an app on your phone.

There exist very little documentation on the API of Enphase. In fact only 1, hard to find, sheet, describing http://<IP Address>/api/v1/production.

I'm not sure it is legally allowed, but I attach that sheet.

Envoy-API-Technical-Brief-small.pdf
(73.37 KiB) Downloaded 754 times

You mentioned in your script, that the update frequency is once/15 minutes.
As you will see in the provided document, Enphase mentions 1 update/5 minutes.
I did some tests and I even found that there was not a consequent pattern of updates and I saw even 2 updates in the same minute.

Therefore, I use the same update frequency as the Domoticz "hardware" does, 30 seconds.
That works fine for me.

Another thing to know is that the Domoticz "hardware" URL uses: http://<IP Address>/production.json.

This URL updates in a different pattern, then http://<IP Address>/api/v1/production.
There can exist small differences between the two URL's, which will give more or less the same information, but the last URL is always accurate, if it comes to the accumulation of the individual inverter values.

Another URL you might be interested in, is: http://<IP Address>/inventory.json.

I hope that this info has some value for you and keep up your good work,

Regards
Last edited by FireWizard on Wednesday 20 April 2022 18:45, edited 2 times in total.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Get local Enphase data from individual solar panels in domoticz

Post by waaren »

@Firewizard,
thanks for your detailed reaction and the provided documents. I will study them and if usable for my situation I will certainly try to improve the script or switch to another method of getting the information I am interested in.

I can follow most of your remarks but not all. Maybe my solarpanel installation is slightly different from the ones you worked with. I tried the method to get a password as described in your reaction but it did not work. That's why I use the username installer for which I do have a working method to get into my own system.
FireWizard wrote: Wednesday 25 September 2019 22:01 The Android app works, I can confirm, but requires that users copy the apk file and enable the developer options. Quite a complex way.
The use of this app is a once of action and it took me less then 5 minutes including the download of the APK to install, use and get a working code.
You mentioned in your script, that the update frequency is once/15 minutes.
I also tried different frequencies but could not get new data. Maybe an older version firmware (my installation is > 4 years old now) or maybe a setting I have not discovered yet.

As said, I will continue with reading the available documentation to see if better ways of getting the useful solarpanel information in my domoticz. My personal preference is to have this as domoticz "hardware" but until now I had no luck with that. Second best in my book is to use one dzVents script.

What I like most here is that domoticz allow us to try different routes so there is something to choose.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Get local Enphase data from individual solar panels in domoticz

Post by waaren »

Updated version in first post:

It's a rainy day in the Netherlands....
Solar panels.png
Solar panels.png (162.75 KiB) Viewed 8813 times
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Get local Enphase data from individual solar panels in domoticz

Post by FireWizard »

Hello waaren,

Looks nice
Pretty low values today, I recognize that as well :cry:

For your information:

My system is quite new, about 4-5 month. Even the Envoy-S is black, while in all documents it is said, that the Envoy-S is grey and the metered is black.
My software version is: D5.0.34 (6e87e2).
My Software Build Date: 26 Jun, 2019 9:36 AM

I did a test and found that both the username/password set as envoy/6 last digits of serial number, as well as installer/password generated by app works.
However both require "digest authentication". I could not log in with "basic authentication".
I log directly into http://<IP Address>/api/v1/production/inverters.

You said
The use of this app is a once of action and it took me less then 5 minutes including the download of the APK to install, use and get a working code.
I agree, as long as you have the knowledge is OK. You and I are probably using applications, as Domoticz, Android apps, etc on a daily base, but for the majority of Android users it is not common to install apps from a downloaded apk file, or even F-Droid.
That is what I mean, so if we can make it easier for a bigger group of users, it is better.
My personal preference is to have this as domoticz "hardware" but until now I had no luck with that.
Yes , yes, yes and that's why I started the suggestion: https://www.domoticz.com/forum/viewtopi ... 31&t=29170

Regards
Last edited by FireWizard on Sunday 13 October 2019 11:10, edited 2 times in total.
User avatar
Chrisjuh
Posts: 2
Joined: Saturday 12 October 2019 12:02
Target OS: Windows
Domoticz version: 4.11351
Location: The Netherlands
Contact:

Re: Get local Enphase data from individual solar panels in domoticz

Post by Chrisjuh »

Hello Waaren,

Thanx for the script!!

This was my first 'custom' script I imported in Domoticz as an real newby to the software.
Als I had a problem with the standard feature for the Enphase panels and I do like the feature of having them all displayed like in your script.

It took a few hours to find out how to make the script work, copy it in the right folder dit not work, copy/paste it into the script editor dit work, so now it is in the database. But unfortunely the script does not worked on my side, I dit get the installer password and tried it to logon the system manually and that works fine, now I can add solarpanels all by myself ;)
I dit found out the script only work on solar production hours, so that's why I don't get results right now (21:53 pm) and both scripts seems to work. ( I tried the first script yesterday evening during the dark hours :roll:

For now I'n new to .lue scripting so I have to ask what the error means.
Can you help me out on this first quest?

I hope you can help me out.
Thanx, Chris

Below the error message from the log:

2019-10-12 15:00:00.579 Error: dzVents: Error: (2.4.29) Enphase_0.201909261300: ReturnCode: 1
2019-10-12 15:00:00.579 commandOutput:
2019-10-12 15:00:00.579
2019-10-12 15:00:00.579 Error: dzVents: Error: (2.4.29) Enphase_0.201909261300: ReturnCode: 1
2019-10-12 15:00:00.579 commandOutput:
2019-10-12 15:00:00.579
2019-10-12 15:00:00.586 Error: dzVents: Error: (2.4.29) Enphase_0.201909261300: Error parsing json to LUA table: C:\Program Files\Domoticz\scripts\dzVents\../lua/JSON.lua:660: expected string argument to JSON:decode(), got table
2019-10-12 15:00:00.586 Error: dzVents: Error: (2.4.29) Enphase_0.201909261300: An error occurred when calling event handler MySolar
2019-10-12 15:00:00.587 Error: dzVents: Error: (2.4.29) Enphase_0.201909261300: ...ogram Files\Domoticz\scripts\dzVents\scripts/MySolar.lua:171: attempt to index local 'productionTable' (a nil value)
Stewart's Law Of Retroaction: It Is Easier To Get Forgiveness Than Permission.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Get local Enphase data from individual solar panels in domoticz

Post by waaren »

Chrisjuh wrote: Saturday 12 October 2019 21:56 I dit found out the script only work on solar production hours, so that's why I don't get results right now (21:53 pm) and both scripts seems to work. ( I tried the first script yesterday evening during the dark hours :roll:
For now I'n new to .lua scripting so I have to ask what the error means.
Can you help me out on this first quest?
The error shown probably means that wget is not installed on your windows system or that it's not in path of the domoticz user.

I modified the script in the first post to allow to enter the wget executable location. If you do not have installed the wget utility yet then first go to https://eternallybored.org/misc/wget/ and install the utility at a location that can be executed by the domoticz user and use the latest version of the script. ( 0.201910122300 )
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
Chrisjuh
Posts: 2
Joined: Saturday 12 October 2019 12:02
Target OS: Windows
Domoticz version: 4.11351
Location: The Netherlands
Contact:

Re: Get local Enphase data from individual solar panels in domoticz

Post by Chrisjuh »

waaren wrote: Saturday 12 October 2019 23:38
The error shown probably means that wget is not installed on your windows system or that it's not in path of the domoticz user.

I modified the script in the first post to allow to enter the wget executable location. If you do not have installed the wget utility yet then first go to https://eternallybored.org/misc/wget/ and install the utility at a location that can be executed by the domoticz user and use the latest version of the script. ( 0.201910122300 )
Thanx Waaren,

I guess you forgot a comment tag in your script..

I'll changed the script, set a comment tag on the red line below and installed wget.exe and wait for the results in the morning, no errors in the log right now...

Greetz!!

-- ==============================
-- Your setting here
-- ==============================
Change to reflect location of your wget and remove -- ( comment ) in front of the declaration for your OS
-- wgetExecutable = '/usr/bin/wget' -- Linux
-- wgetExecutable = 'c:\\"Program files"\\wget.exe' -- Windows: double back slashes where one is in the path
Stewart's Law Of Retroaction: It Is Easier To Get Forgiveness Than Permission.
bert
Posts: 17
Joined: Monday 27 October 2014 23:57
Target OS: Linux
Domoticz version:
Contact:

Re: Get local Enphase data from individual solar panels in domoticz

Post by bert »

Moving from a Raspberry pi with Domoticz running on the bare metal to a NUC intel i5 running a docker setup under CentOS gave me quite a few challenges. After having bested most of them, today I realize that my solar installation is not updating.
Having done all in the late hours, (when the schript is not running) I did not spot the errors in the log at that moment.

Code: Select all

2022-01-02 11:30:00.121 Error: dzVents: Error: (3.1.8) Enphase_0.201910122300: ReturnCode: 127
2022-01-02 11:30:00.121 commandOutput:
2022-01-02 11:30:00.121
2022-01-02 11:30:00.121 Error: dzVents: Error: (3.1.8) Enphase_0.201910122300: ReturnCode: 127
2022-01-02 11:30:00.121 commandOutput:
2022-01-02 11:30:00.121
2022-01-02 11:30:00.121 Error: dzVents: Error: (3.1.8) Enphase_0.201910122300: An error occurred when calling event handler DzVents Enphase metering
2022-01-02 11:30:00.121 Error: dzVents: Error: (3.1.8) Enphase_0.201910122300: ...s/dzVents/generated_scripts/DzVents Enphase metering.lua:177: attempt to index a nil value (local 'productionTable')
Turns out, the official Domoticz docker distribution does not include wget.
Curl is available though, so herewith my alteration that makes it work again:

line 64

Code: Select all

        wgetExecutable = '/usr/bin/curl'                 -- linux

line 130

Code: Select all

        local function getEnphaseData(api)
            local baseCommand = wgetExecutable .. ' --digest -u ' .. Enphase.user .. ':' .. Enphase.password ..' -o - http://'
            local cmd = baseCommand .. Enphase.ip .. api
            return osCommand(cmd)
        end

By the way; Waaren - massive thanks for this script!! :-)
benedict
Posts: 16
Joined: Thursday 16 December 2021 16:05
Target OS: Linux
Domoticz version:
Contact:

Re: Get local Enphase data from individual solar panels in domoticz

Post by benedict »

I've been trying to get this script to work, but apparently I'm doing something wrong. Is there a tutorial somewhere on how to run a dzVents script, because that seems to be the issue? I can edit the script just fine, add panels and change login creds for the Envoy, but the script just does not run.
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Get local Enphase data from individual solar panels in domoticz

Post by waltervl »

benedict wrote: Thursday 27 January 2022 16:29 I've been trying to get this script to work, but apparently I'm doing something wrong. Is there a tutorial somewhere on how to run a dzVents script, because that seems to be the issue? I can edit the script just fine, add panels and change login creds for the Envoy, but the script just does not run.
Check the video here: https://domoticz.com/forum/viewtopic.php?f=59&t=18143
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
bert
Posts: 17
Joined: Monday 27 October 2014 23:57
Target OS: Linux
Domoticz version:
Contact:

Re: Get local Enphase data from individual solar panels in domoticz

Post by bert »

benedict wrote: Thursday 27 January 2022 16:29 I've been trying to get this script to work, but apparently I'm doing something wrong. Is there a tutorial somewhere on how to run a dzVents script, because that seems to be the issue? I can edit the script just fine, add panels and change login creds for the Envoy, but the script just does not run.
Are you running Domoticz from Docker?
if so, you have to manually add some directories to make DZvents work at all.
cd /opt/domoticz (this is where I have my docker-compose.yml file)
sudo mkdir config
cd config/
sudo mkdir scripts
sudo mkdir scripts/lua
sudo mkdir scripts/dzVents
sudo mkdir scripts/dzVents/generated_scripts
sudo mkdir scripts/dzVents/data

after that, in my case DZvents started working.
benedict
Posts: 16
Joined: Thursday 16 December 2021 16:05
Target OS: Linux
Domoticz version:
Contact:

Re: Get local Enphase data from individual solar panels in domoticz

Post by benedict »

waltervl wrote: Thursday 27 January 2022 17:50
benedict wrote: Thursday 27 January 2022 16:29 I've been trying to get this script to work, but apparently I'm doing something wrong. Is there a tutorial somewhere on how to run a dzVents script, because that seems to be the issue? I can edit the script just fine, add panels and change login creds for the Envoy, but the script just does not run.
Check the video here: https://domoticz.com/forum/viewtopic.php?f=59&t=18143
This is about an older domoticz version. Either way, I still did not get dzVents to run, no matter what I tried. Even checked file permission issues, which made no difference. I'm back to the other, the Node red option.
Dellie
Posts: 10
Joined: Wednesday 03 April 2019 12:03
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9
Location: Netherlands
Contact:

Re: Get local Enphase data from individual solar panels in domoticz

Post by Dellie »

Anyone who can help me out.
Script fails when adding the virtual switches.

From the logging:
2022-04-04 11:40:00.423 Status: dzVents: Info: Enphase_0.201910122300: /usr/bin/wget -T 3 --user installer --password 1234567 -O - 192.168.178.171/api/v1/production
2022-04-04 11:40:00.455 Status: dzVents: !Info: Enphase_0.201910122300: Device Enphase production will be created.
2022-04-04 11:40:00.455 Status: dzVents: Debug: Enphase_0.201910122300: OpenURL: url = http://127.0.0.1:8080/json.htm?type=cre ... ype=0xF31D
2022-04-04 11:40:00.455 Status: dzVents: Debug: Enphase_0.201910122300: OpenURL: method = GET
2022-04-04 11:40:00.455 Status: dzVents: Debug: Enphase_0.201910122300: OpenURL: post data = nil
2022-04-04 11:40:00.456 Status: dzVents: Debug: Enphase_0.201910122300: OpenURL: headers = nil
2022-04-04 11:40:00.456 Status: dzVents: Debug: Enphase_0.201910122300: OpenURL: callback = nil
2022-04-04 11:40:00.456 Status: dzVents: Info: Enphase_0.201910122300: /usr/bin/wget -T 3 --user installer --password 1234567 -O - 192.168.178.171/api/v1/production/inverters
2022-04-04 11:40:00.524 Status: dzVents: !Info: Enphase_0.201910122300: Device micro inverter: 122206032705 will be created.
2022-04-04 11:40:00.524 Status: dzVents: Debug: Enphase_0.201910122300: OpenURL: url = http://127.0.0.1:8080/json.htm?type=cre ... ype=0xF31D
2022-04-04 11:40:00.524 Status: dzVents: Debug: Enphase_0.201910122300: OpenURL: method = GET
2022-04-04 11:40:00.524 Status: dzVents: Debug: Enphase_0.201910122300: OpenURL: post data = nil
2022-04-04 11:40:00.524 Status: dzVents: Debug: Enphase_0.201910122300: OpenURL: headers = nil
2022-04-04 11:40:00.524 Status: dzVents: Debug: Enphase_0.201910122300: OpenURL: callback = nil
2022-04-04 11:40:00.524 Status: dzVents: !Info: Enphase_0.201910122300: Device micro inverter: 122206034010 will be created.
....


2022-04-04 11:40:00.532 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2022-04-04 11:40:00.563 Error: Error opening url: http://127.0.0.1:8080/json.htm?type=cre ... ype=0xF31D
2022-04-04 11:40:01.536 Error: Error opening url: http://127.0.0.1:8080/json.htm?type=cre ... ype=0xF31D
.....

If I run"http://IP_DOMOTICZ:8080/json.htm?type=createdevice&idx=23&sensorname=Enphase+production&sensormappedtype=0xF31D"
I get "401 Unauthorized"

Idea could be to create the swicthes manualy, but waht type do I have to create?

sensormappedtype=0xF31D??
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Get local Enphase data from individual solar panels in domoticz

Post by waltervl »

For using Dzvents in Domoticz you have to set the Local Network connection (no username/password) setting correctly
https://www.domoticz.com/wiki/DzVents:_ ... h_Domoticz
Also make sure that in the Security section in the settings (Setup > Settings > System > Local Networks (no username/password) you allow 127.0.0.1 (and / or ::1 when using IPv6 ) to not need a password. dzVents does use this port to get the location settings and to send certain commands to Domoticz.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
BurningTyre
Posts: 28
Joined: Wednesday 21 August 2019 15:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Arnhem, The Netherlands
Contact:

Re: Get local Enphase data from individual solar panels in domoticz

Post by BurningTyre »

I'm missing the information about what type of dummy hardware needs to be created?

When creating a new dzVents script, what type of script to create? (i assume All(recommended))

Image

After i created a dummy sensor and filled in that IDx in the script it looks it started to work, the devices are created.

Image

The only problem is that it is not reporting any production, and every "set frequency / 15min" there are created new devices again....this is clearly not right! What did i do wrong? There is a connection from the script to the envoy, otherwise it could not got the micro inverter serials...

Image
SanderRoelofs
Posts: 17
Joined: Thursday 11 March 2021 10:03
Target OS: Windows
Domoticz version:
Contact:

Re: Get local Enphase data from individual solar panels in domoticz

Post by SanderRoelofs »

Only create a dummy hardware device not sensors.
Create just a normal dzvents scripts and make sure that settings are like below (offcourse use your own addresses)

local Enphase = {
ip = 'ip_address',
password = 'password',
dummyHardwareIDX = idx_number,
useProduction = true,
productionDeviceName = 'Enphase production',
useInverters = true,
inverterDevicePrefix = 'micro inverter: ',
createDevices = true,

Also make sure Domoticz is allowed creating new sensors (in the Settings page).



BurningTyre wrote: Tuesday 19 July 2022 14:39 I'm missing the information about what type of dummy hardware needs to be created?

When creating a new dzVents script, what type of script to create? (i assume All(recommended))

Image

After i created a dummy sensor and filled in that IDx in the script it looks it started to work, the devices are created.

Image

The only problem is that it is not reporting any production, and every "set frequency / 15min" there are created new devices again....this is clearly not right! What did i do wrong? There is a connection from the script to the envoy, otherwise it could not got the micro inverter serials...

Image
BurningTyre
Posts: 28
Joined: Wednesday 21 August 2019 15:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Arnhem, The Netherlands
Contact:

Re: Get local Enphase data from individual solar panels in domoticz

Post by BurningTyre »

ah my mistake.

I did not know that the dummy hardware was having an own idx.

Working now! Is there any way to get a single graph with all the lines from all micro inverters in it?

SanderRoelofs wrote: Tuesday 19 July 2022 14:57 Only create a dummy hardware device not sensors.
Create just a normal dzvents scripts and make sure that settings are like below (offcourse use your own addresses)

local Enphase = {
ip = 'ip_address',
password = 'password',
dummyHardwareIDX = idx_number,
useProduction = true,
productionDeviceName = 'Enphase production',
useInverters = true,
inverterDevicePrefix = 'micro inverter: ',
createDevices = true,

Also make sure Domoticz is allowed creating new sensors (in the Settings page).



BurningTyre wrote: Tuesday 19 July 2022 14:39 I'm missing the information about what type of dummy hardware needs to be created?

When creating a new dzVents script, what type of script to create? (i assume All(recommended))

Image

After i created a dummy sensor and filled in that IDx in the script it looks it started to work, the devices are created.

Image

The only problem is that it is not reporting any production, and every "set frequency / 15min" there are created new devices again....this is clearly not right! What did i do wrong? There is a connection from the script to the envoy, otherwise it could not got the micro inverter serials...

Image
SanderRoelofs
Posts: 17
Joined: Thursday 11 March 2021 10:03
Target OS: Windows
Domoticz version:
Contact:

Re: Get local Enphase data from individual solar panels in domoticz

Post by SanderRoelofs »

Yes and no.

I'm using Influx with Grafana for viewing graphs


BurningTyre wrote: Tuesday 19 July 2022 19:05 ah my mistake.

I did not know that the dummy hardware was having an own idx.

Working now! Is there any way to get a single graph with all the lines from all micro inverters in it?

SanderRoelofs wrote: Tuesday 19 July 2022 14:57 Only create a dummy hardware device not sensors.
Create just a normal dzvents scripts and make sure that settings are like below (offcourse use your own addresses)

local Enphase = {
ip = 'ip_address',
password = 'password',
dummyHardwareIDX = idx_number,
useProduction = true,
productionDeviceName = 'Enphase production',
useInverters = true,
inverterDevicePrefix = 'micro inverter: ',
createDevices = true,

Also make sure Domoticz is allowed creating new sensors (in the Settings page).



BurningTyre wrote: Tuesday 19 July 2022 14:39 I'm missing the information about what type of dummy hardware needs to be created?

When creating a new dzVents script, what type of script to create? (i assume All(recommended))

Image

After i created a dummy sensor and filled in that IDx in the script it looks it started to work, the devices are created.

Image

The only problem is that it is not reporting any production, and every "set frequency / 15min" there are created new devices again....this is clearly not right! What did i do wrong? There is a connection from the script to the envoy, otherwise it could not got the micro inverter serials...

Image
Attachments
InfluxGrafana.png
InfluxGrafana.png (62.41 KiB) Viewed 2794 times
vwstepha
Posts: 23
Joined: Saturday 17 March 2018 12:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Marseille
Contact:

Re: Get local Enphase data from individual solar panels in domoticz

Post by vwstepha »

Good evening everyone! Best wishes for this New Year!!!! :)

I want to monitor my Enphase meter
I put the script available on the 1st page (thanks to the author!!) in the events
I created a Dummy and the idx 16 was assigned by Dz.
in the settings, there is the authorization to create new sensors.

Code: Select all

-- ==============================
        -- Your setting here
        -- ==============================
        -- Change to reflect location of your wget and remove -- ( comment ) in front of the declaration for your OS  
        -- wgetExecutable = '/usr/bin/wget'                 -- Linux
        -- wgetExecutable = 'c:\\"Program files"\\wget.exe' -- Windows: double back slashes where one is in the path

                local Enphase =    {
                                ip = '192.168.1.195',         -- IP address of your local enphase hub
                                password = 'ac6k4732',            -- Change to your calculated password. See description above on how to get this.

                                dummyHardwareIDX = 16,               -- Change to ID of your virtual hardware
                                useProduction = true,
                                productionDeviceName = 'l***l',
                                useInverters = true,
                                inverterDevicePrefix = 'micro inverter: ',  -- script use this prefix + serial number of inverter.
                                createDevices = true,              -- Should the script create devices if they are not defined yet.

                                -- please note that the counter display will only show a rough estimate
                                -- of the produced energy over the period the device lives in domoticz and the script is active.

        -- =========================================
        -- == No changes required below this line ==
        -- ==========================================
                                user = 'installer',                                     -- I think this is a fixed username
                                inverterDeviceType = 'Electric (instant+Counter)',      -- script use this type for inverters
                                productionDeviceType = 'Electric (instant+Counter)',    -- script use this type for total production
                                productionAPI = '/api/v1/production',
                                invertersAPI = '/api/v1/production/inverters',

                            }
I filled in my personal info except "micro inverter". I did not understand what I should put?
Do I have to put the serial number of the Micro inverter and therefore create as many scripts as there are micro inverters?
Can you help me?
Thank you :mrgreen:
Rpi Master 2022.2 Beta 14905 (Broadlink ok.....)
Rpi slave 2020.2 (since 10days but with error...) with 2 rflink(rts 433 + 833)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest