Get energy consumption (and more) from EV charger

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

Moderators: leecollings, remb0

azzilla
Posts: 8
Joined: Tuesday 01 January 2019 16:16
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Get energy consumption (and more) from EV charger

Post by azzilla »

New member so be kind :D

I have a EV charger from Garo (GLBMMN-T222WO) that has a web gui which has all sorts of information about energy consumption, connector status and so on.
I contacted the manufacurer and asked if there is an api that i could pull data from but there wasn't, i also got a tone of "don't meddle with our stuff" from the support rep. :lol:

I managed to find a specific url when i looked in the browser console that pulls a status.json file.
It looks like this.
Image

What i would like to be able to do is. If possible that is?
  • Status from "connector" translated to a virtual sensor so i can get a notification to my phone when it disconnects/connects. There have been an increase in cables being stolen in my area and i want to at least try to prevent it. They are effin expensive.
  • Status from "currentChargingPower" translated to a virtual sensor so i can monitor the wattage of the charger.
If anyone can point me in the right direction or better, help me set this up i would appreciate it so much. I am really bummed about the choice of EV Charger but i hope i can make it somewhat smarter with this solution.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Get energy consumption (and more) from EV charger

Post by waaren »

azzilla wrote: Tuesday 01 January 2019 19:57 I have a EV charger from Garo (GLBMMN-T222WO).
I managed to find a specific url when i looked in the browser console that pulls a status.json file.
What i would like to be able to do is. If possible that is?
  • Status from "connector" translated to a virtual sensor so i can get a notification to my phone when it disconnects/connects. There have been an increase in cables being stolen in my area and i want to at least try to prevent it. They are effin expensive.
  • Status from "currentChargingPower" translated to a virtual sensor so i can monitor the wattage of the charger.
Please share the exact url and the raw JSON return and also the notification app you use from domoticz to your mobile.
With that information a dzVents script can be created that stores the information in a virtual alert sensor and a virtual electric usage device.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
azzilla
Posts: 8
Joined: Tuesday 01 January 2019 16:16
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Get energy consumption (and more) from EV charger

Post by azzilla »

waaren wrote: Tuesday 01 January 2019 20:40
azzilla wrote: Tuesday 01 January 2019 19:57 I have a EV charger from Garo (GLBMMN-T222WO).
I managed to find a specific url when i looked in the browser console that pulls a status.json file.
What i would like to be able to do is. If possible that is?
  • Status from "connector" translated to a virtual sensor so i can get a notification to my phone when it disconnects/connects. There have been an increase in cables being stolen in my area and i want to at least try to prevent it. They are effin expensive.
  • Status from "currentChargingPower" translated to a virtual sensor so i can monitor the wattage of the charger.
Please share the exact url and the raw JSON return and also the notification app you use from domoticz to your mobile.
With that information a dzVents script can be created that stores the information in a virtual alert sensor and a virtual electric usage device.
The link
http://192.168.1.15:2222/rest/chargebox ... 6334042114

The json info
{
"ocppState": null,
"freeCharging": false,
"ocppConnectionState": null,
"connector": "NOT_CONNECTED",
"mode": "ALWAYS_OFF",
"currentLimit": 32,
"factoryCurrentLimit": 32,
"switchCurrentLimit": 32,
"powerMode": "OFF",
"currentChargingCurrent": 0,
"currentChargingPower": 0,
"accSessionEnergy": 0,
"latestReading": 57000,
"currentTemperature": 11,
"pilotLevel": 0,
"sessionStartValue": 57000,
"nrOfPhases": 1
}

I use Prowl. Do you also need the API key or should i fill this in myself?
Thanks a bunch for your help!
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Get energy consumption (and more) from EV charger

Post by waaren »

azzilla wrote: Tuesday 01 January 2019 21:02 I use Prowl. Do you also need the API key or should i fill this in myself?
I will have a look and assume you configured Prowl in domoticz already. I will use that in the script, so no need to share your api key.
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 energy consumption (and more) from EV charger

Post by waaren »

azzilla wrote: Tuesday 01 January 2019 19:57 I have a EV charger from Garo (GLBMMN-T222WO) that has a web gui which has all sorts of information about energy consumption, connector status and so on. I managed to find a specific url when i looked in the browser console that pulls a status.json file.
Please start with reading the required setup steps for dzVents.
Also this Quickstart is very useful to get a basic understanding of dzVents Lua for domoticz.

I could not test everything because I don't own this device and I don't use prowl as notification system but what I could test works.
More explanation is in the comments inside the script. Please feel free to ask for clarification if things are not clear or when you encounter problems.

PS. Please update your profile with the version you use. Thx

have Fun !

Code: Select all

-- Garo EV charger

--[[ 
            Create dummy hardware                               ( https://www.domoticz.com/wiki/Hardware_Setup#Dummy_Hardware )
            Create two virtual devices on the dummy hardware    ( https://www.domoticz.com/wiki/Virtual_meter )
            1. Alert Device
            2. Electric (instant and counter)
            
            modify names in lines between -- +++++++++
]] --
local callBack = "GaroCharger"

return {
             on =   {  
                        timer           =   { "every minute" },     -- when freq changed, energy total calc. must be modified as well (search for 60 in this script)   
                        httpResponses   =   { callBack       },    
                    },
                     
        logging =   {   
                        level   =   domoticz.LOG_DEBUG,                   
                        marker  =   "Garo EV charger"
                    },
                        
           data =   {   notificationSend = { initial = false     },
                        message          = { initial = ""        },
                        timeSend         = { initial = "not yet" },
                    },
     
    execute = function(dz,item)
       
        -- ++++++++++++++++ Enter your setting between these lines +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        local testMode              = false                    -- set to false when live
        local alert                 = dz.devices("garo Alert") -- Change to the name you use for this device
        local power                 = dz.devices("garo Power") -- Change to the name you use for this device
        local notificationResetTime = "09:00"                  -- Set time at when you want the notication to repeat when still not Connected
        
        local myNotificationTable   = {                         -- table with one or more notification systems. 
                                                                -- Can be one or more of them
                                                                -- Remove "--" in front of all notification systems you want to use    
                                                                -- dz.NSS_GOOGLE_CLOUD_MESSAGING, 
                                                                dz.NSS_PUSHOVER,               
                                                                -- dz.NSS_HTTP, 
                                                                -- dz.NSS_KODI, 
                                                                -- dz.NSS_LOGITECH_MEDIASERVER, 
                                                                -- dz.NSS_NMA,
                                                                dz.NSS_PROWL, 
                                                                -- dz.NSS_PUSHALOT, 
                                                                -- dz.NSS_PUSHBULLET, 
                                                                -- dz.NSS_PUSHOVER, 
                                                                -- dz.NSS_PUSHSAFER,
                                        }
        -- ++++++++++++++++ No modification should be needed below this line +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        
        local alertLevel            = dz.ALERTLEVEL_GREEN
        local connectionOK          = "CONNECTED" 
        local testData              = '{"ocppState": null,"connector": "CONNECTED","mode": "ALWAYS_OFF","currentChargingPower": 2227.1}' -- not used when live    
        local repeatNotification    = dz.time.matchesRule("at " .. notificationResetTime) and alert.color == dz.ALERTLEVEL_RED 
        
        -- output to domoticz log
        local function logWrite(str,level)
            dz.log(tostring(str),level or dz.LOG_DEBUG)
        end

        logWrite ("triggered by " .. item.trigger)
        
        -- call the url to get the JSON
        local function getJSON()
            local url = "http://192.168.1.15:2222/rest/chargebox/status?_=1546334042114"
            if testMode then
                url    = dz.settings['Domoticz url'] .. "/json.htm?type=command&param=addlogmessage&message=ChargeBox_test"
            end
            dz.openURL({    url =  url,
                            method = "GET",
                            callback = callBack })
        end
        
        -- convert json data to Lua table
        local function json2Table()
            if testMode then
                return dz.utils.fromJSON(testData)
            else  
                return dz.utils.fromJSON(item.data)
            end    
        end
        
        -- Get the relevant fields
        local function extractFields(t)
            return t.connector,t.currentChargingPower
        end
        
        local function updatePersistentData(val,message)
            dz.data.notificationSend = val
            if val then 
                dz.data.timeSend = dz.time.raw
                dz.data.message  = message
            end    
        end
        -- send notification to all systems active and in myNotificationTable when status changed or once a day
        local function notify(message, forced)
            if forced or not dz.data.notificationSend then
                dz.notify("Garo charger", message, dz.PRIORITY_NORMAL, dz.SOUND_INTERMISSION,    "",   myNotificationTable ) 
                updatePersistentData(true,message)        
            end
       end
        
        -- Update devices when needed   
        local function fillDevices(connected, Power)
            local changed = false
            if alert.text ~= connected then
                changed = true
                if connected ~= connectionOK then
                    alertLevel = dz.ALERTLEVEL_RED
                end
                alert.updateAlertSensor(alertLevel, connected)
                updatePersistentData(false)        
            end
            energy = power.WhTotal + Power / 60                     -- if you change the frequncy of the script you should also change the 60
            power.updateElectricity(Power, energy) 
            return changed
       end
        
        -- Main 
        if item.isTimer then
            getJSON()
        else
            local connector, currentChargingPower = extractFields(json2Table())
            if fillDevices(connector, currentChargingPower) or repeatNotification then
                notify("Charger is " .. connector, repeatNotification )
            end
        end
    end
}              
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
azzilla
Posts: 8
Joined: Tuesday 01 January 2019 16:16
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Get energy consumption (and more) from EV charger

Post by azzilla »

waaren wrote: Wednesday 02 January 2019 3:03
azzilla wrote: Tuesday 01 January 2019 19:57 I have a EV charger from Garo (GLBMMN-T222WO) that has a web gui which has all sorts of information about energy consumption, connector status and so on. I managed to find a specific url when i looked in the browser console that pulls a status.json file.
Please start with reading the required setup steps for dzVents.
Also this Quickstart is very useful to get a basic understanding of dzVents Lua for domoticz.

I could not test everything because I don't own this device and I don't use prowl as notification system but what I could test works.
More explanation is in the comments inside the script. Please feel free to ask for clarification if things are not clear or when you encounter problems.

PS. Please update your profile with the version you use. Thx

have Fun !

Code: Select all

-- Garo EV charger

--[[ 
            Create dummy hardware                               ( https://www.domoticz.com/wiki/Hardware_Setup#Dummy_Hardware )
            Create two virtual devices on the dummy hardware    ( https://www.domoticz.com/wiki/Virtual_meter )
            1. Alert Device
            2. Electric (instant and counter)
            
            modify names in lines between -- +++++++++
]] --
local callBack = "GaroCharger"

return {
             on =   {  
                        timer           =   { "every minute" },     -- when freq changed, energy total calc. must be modified as well (search for 60 in this script)   
                        httpResponses   =   { callBack       },    
                    },
                     
        logging =   {   
                        level   =   domoticz.LOG_DEBUG,                   
                        marker  =   "Garo EV charger"
                    },
                        
           data =   {   notificationSend = { initial = false     },
                        message          = { initial = ""        },
                        timeSend         = { initial = "not yet" },
                    },
     
    execute = function(dz,item)
       
        -- ++++++++++++++++ Enter your setting between these lines +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        local testMode              = false                    -- set to false when live
        local alert                 = dz.devices("garo Alert") -- Change to the name you use for this device
        local power                 = dz.devices("garo Power") -- Change to the name you use for this device
        local notificationResetTime = "09:00"                  -- Set time at when you want the notication to repeat when still not Connected
        
        local myNotificationTable   = {                         -- table with one or more notification systems. 
                                                                -- Can be one or more of them
                                                                -- Remove "--" in front of all notification systems you want to use    
                                                                -- dz.NSS_GOOGLE_CLOUD_MESSAGING, 
                                                                dz.NSS_PUSHOVER,               
                                                                -- dz.NSS_HTTP, 
                                                                -- dz.NSS_KODI, 
                                                                -- dz.NSS_LOGITECH_MEDIASERVER, 
                                                                -- dz.NSS_NMA,
                                                                dz.NSS_PROWL, 
                                                                -- dz.NSS_PUSHALOT, 
                                                                -- dz.NSS_PUSHBULLET, 
                                                                -- dz.NSS_PUSHOVER, 
                                                                -- dz.NSS_PUSHSAFER,
                                        }
        -- ++++++++++++++++ No modification should be needed below this line +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        
        local alertLevel            = dz.ALERTLEVEL_GREEN
        local connectionOK          = "CONNECTED" 
        local testData              = '{"ocppState": null,"connector": "CONNECTED","mode": "ALWAYS_OFF","currentChargingPower": 2227.1}' -- not used when live    
        local repeatNotification    = dz.time.matchesRule("at " .. notificationResetTime) and alert.color == dz.ALERTLEVEL_RED 
        
        -- output to domoticz log
        local function logWrite(str,level)
            dz.log(tostring(str),level or dz.LOG_DEBUG)
        end

        logWrite ("triggered by " .. item.trigger)
        
        -- call the url to get the JSON
        local function getJSON()
            local url = "http://192.168.1.15:2222/rest/chargebox/status?_=1546334042114"
            if testMode then
                url    = dz.settings['Domoticz url'] .. "/json.htm?type=command&param=addlogmessage&message=ChargeBox_test"
            end
            dz.openURL({    url =  url,
                            method = "GET",
                            callback = callBack })
        end
        
        -- convert json data to Lua table
        local function json2Table()
            if testMode then
                return dz.utils.fromJSON(testData)
            else  
                return dz.utils.fromJSON(item.data)
            end    
        end
        
        -- Get the relevant fields
        local function extractFields(t)
            return t.connector,t.currentChargingPower
        end
        
        local function updatePersistentData(val,message)
            dz.data.notificationSend = val
            if val then 
                dz.data.timeSend = dz.time.raw
                dz.data.message  = message
            end    
        end
        -- send notification to all systems active and in myNotificationTable when status changed or once a day
        local function notify(message, forced)
            if forced or not dz.data.notificationSend then
                dz.notify("Garo charger", message, dz.PRIORITY_NORMAL, dz.SOUND_INTERMISSION,    "",   myNotificationTable ) 
                updatePersistentData(true,message)        
            end
       end
        
        -- Update devices when needed   
        local function fillDevices(connected, Power)
            local changed = false
            if alert.text ~= connected then
                changed = true
                if connected ~= connectionOK then
                    alertLevel = dz.ALERTLEVEL_RED
                end
                alert.updateAlertSensor(alertLevel, connected)
                updatePersistentData(false)        
            end
            energy = power.WhTotal + Power / 60                     -- if you change the frequncy of the script you should also change the 60
            power.updateElectricity(Power, energy) 
            return changed
       end
        
        -- Main 
        if item.isTimer then
            getJSON()
        else
            local connector, currentChargingPower = extractFields(json2Table())
            if fillDevices(connector, currentChargingPower) or repeatNotification then
                notify("Charger is " .. connector, repeatNotification )
            end
        end
    end
}              
Working like charm! 8-)
Big thank you. Really!

Am going to read up on Lua/DzVents and take it from here.
Next sten is that i'll try to get ssh access to the box. The communication model in the box is a rPi and ssh is activated, i just need to convince the manufacturer to give me the credentials. :D
Then i should be able to modify the status.json and be able to send instructions to the charger.
Sweet!
ikke
Posts: 3
Joined: Sunday 16 October 2016 9:42
Target OS: Linux
Domoticz version:
Contact:

Re: Get energy consumption (and more) from EV charger

Post by ikke »

Hi,

we just got these boxes into our household, and I run into this topic while googling for the device. I noticed from manual that it seems to have raspberry pi inside. Based on that info google dropped me here. I was also wondering how to get access to the device for data. I don't get to open the box, but if someone could, it would be nice to get dumps of the cards connected to raspberrypi. There seems to be usb stick based on picture. So if you get your hands on the box, it would be trivial to install stuff there to get more data out of it. Personally I'd find it interesting to drop mqtt sender in there, to get all the info out of it into mqtt periodically. Like my other raspberry pi's do at home.

So in case you have hands on access to the box, I'm glad to help you with getting e.g. the ssh access to it. All you need to do is likey drop your ssh key in there. So getting out the ssd card/usb stick, and going to user's home directory, likely root, and adding the key to the end of .ssh/authorized_keys file. If it won't work, please copy here the /etc/passwd and the /etc/ssh/sshd_config files.

:!: :!: Remember to cut the power off from the box totally before messing with it. Just to be fully understanding that the electricity in there can easily kill you. Never do any of this while it's powered. Just in case for everyone reading this. :!: :!:

If you could power it down, extract the usb stick and the ssd card, and copy the contents of them, it would be super. No reason to share them publicly (contains your WLAN pwd, and we don't want to upset the vendor), but I sure would like to see what could be done with them. If possible, store them using some full image copy tool, like dd in Linux.
zadiraines
Posts: 2
Joined: Thursday 03 December 2020 13:12
Target OS: -
Domoticz version:
Contact:

Re: Get energy consumption (and more) from EV charger

Post by zadiraines »

I'm wondering if you managed to get the dump. I would be interested in digging into it, too. Looks like they use RPI 3 model B rev2 based on the images with no 5Ghz wireless support. I'd be interested in replacing it with a newer model, too. Both 3B+ and 4 support 802.11AC over 5Ghz.

Looking at this PDF it seems that there is an usb stick and an sd card. So a dump for both would be useful (asuming the USB stick is a mass storage device). My second guess would be the stick being a second wifi interface.
zadiraines
Posts: 2
Joined: Thursday 03 December 2020 13:12
Target OS: -
Domoticz version:
Contact:

Re: Get energy consumption (and more) from EV charger

Post by zadiraines »

So looks like the rest API is the best way of talking to the charging station. There is a server running on the RPi listening on port 2222 that relays [and en/decodes] messages to a serial device connected to the GPIO header. Theoretically, it would be possible to debug those messages and create an integration for serial console access - for those people who don't have the network upgrade option. The USB stick is a storage device, containing a database - so is irrelevant from the integration POV.

One thing every owner should know is that the RPi is creating an SSH connection out to some sort of management network, creating an ssh tunnel allowing certain SSH keys to connect back to it from the management network - so technically the support people from GARO would be able to access your internal home network through RPi as a bastion host. You may want to either disconnect it from the network and only connect when support is required or isolate it in a separate network of firewall outgoing traffic.
StarkJohan
Posts: 2
Joined: Wednesday 24 March 2021 18:49
Target OS: Linux
Domoticz version:
Contact:

Re: Get energy consumption (and more) from EV charger

Post by StarkJohan »

Just trying to put down the information I've found so far for anyone interested. At this point it's pretty much a list of random pieces of information.

The latest software seems to be posted here: https://www.webel-online.se/wifi/
To upload the zip package this url is used: http://<glb-ip>:8080/update/

You can download the update package, unzip it and poke around. There's a few bash scripts and a few jsp packages that probably can be edited as well as some java class that easily can be decompiled. I have not tried altering anything yet but maybe the files can be altered and then uploaded.

The java classes used when updating runs the bash scripts which performs the actual update: downloadandupdate.sh and updaterscript.sh

The tomcat manager is avalable here: http://tomcat:tTeFxaYBR73Y@<glb-ip>:8080/manager/
/var/lib/tomcat8/webapps/ROOT/index.html
For security reasons, using the manager webapp is restricted to users with role "manager-gui". The host-manager webapp is restricted to users with role "admin-gui". Users are defined in /etc/tomcat8/tomcat-users.xml.

The jsp uses these three urls on port 2222 (probably the ssh tunnel mentioned by zadiraines, there is a cronjob running for usr/local/bin/create_ssh_tunnel.sh) for getting current status as previously mentioned. I haven't looked to much into the json response but at least the current charge current/power can be read which currently is not shown in the GUI (1.2.2). The 13 digit timestamp at the end of the url is perhaps used for statistics but I'm not sure. It's not needed to get the json response but should probably be properly posted when writing any integrations.

For the box with the pi the first url is used. This seems to be called every second from the GUI.
http://<glb-ip>:2222/rest/chargebox/config?_=<13-digit-timestamp>

For the slave boxes (and also the master apparently): This URL is called roughly every 30 seconds.
http://<glb-ip>:2222/rest/chargebox/slaves/false?_=<13-digit-timestamp>

To get the available info from any load balancing "house" power meters us the modbus id as follows. This URL is also called roughly every 30 seconds.
http://<glb-ip>:2222/rest/chargebox/meterinfo/CENTRAL100?_=<13-digit-timestamp>

I have the intention to open up my box to dump the sd card some day but currently this is not a priority. You could probably add your ssh key to the sd card as previously suggested or alter one of the bash scripts to add a sudo user to get ssh access after pushing an update. I don't want to try the update route without dumping the sd card first though.

I haven't looked into the network activity much but I know that this is used for checking for new firmware. It is hard coded in the hosts file like this:
85.11.39.104 www.webel-online.se
Also, the url https://chargebox.webel.se/ is used for "easy access" to your web GUI which means the glb communicates with this server. Lookup shows it actually resolves to the same ip (85.11.39.104).
Grizz
Posts: 1
Joined: Thursday 01 April 2021 18:09
Target OS: OS X
Domoticz version:
Contact:

Re: Get energy consumption (and more) from EV charger

Post by Grizz »

Wow, I just have to say that I was almost at the point of giving up controlling my ev charger. Then I found this thread! Thank you ALL for sharing! :D
So I will share what I'm doing now to control my charger using Python.

I’m using http://<glb-ip>:2222/rest/chargebox/status to get the JSON response with info like if charger is enabled/disabled, current charging current/power and current limit.
Spoiler: show
# Get charger state
url = 'http://<glb-ip>:2222/rest/chargebox/status'
url_request = urllib.request.urlopen(url)
data = json.loads(url_request.read())
enabled = data['mode'] == 'ALWAYS_ON'
currentChargingCurrent = data['currentChargingCurrent']
currentChargingPower = data['currentChargingPower']
currentLimit = data['currentLimit']
chargeStatus = data['mainCharger']['chargeStatus']
nrOfPhases = data['nrOfPhases']
To enable/disable charger I’m posting JSON-string 'ALWAYS_ON'
or 'ALWAYS_OFF' to http://<glb-ip>:2222/rest/chargebox/mode with header {'Content-Type': 'application/json; charset=UTF-8'}
Spoiler: show
# Set charger state
mode = 'ALWAYS_OFF'
if enabled:
mode = 'ALWAYS_ON'
requests.post('http://<glb-ip>:2222/rest/chargebox/mode', data=mode, json=None, headers={'Content-Type': 'application/json; charset=UTF-8'})
To change charge current I’m posting JSON-string {"reducedIntervalsEnabled": true,"reducedCurrentIntervals": [{"schemaId": 1,"start": "00:00:00","stop": "24:00:00","weekday": 8,"chargeLimit": "<NEW_CHARGE_CURRENT>}]} to http://<glb-ip>:2222/rest/chargebox/currentlimit with header {'Content-Type': 'application/json; charset=UTF-8'}
Spoiler: show
# Set charge limit
url = 'http://<glb-ip>:2222/rest/chargebox/currentlimit'
data = '''{"reducedIntervalsEnabled": true,"reducedCurrentIntervals": [{"schemaId": 1,"start": "00:00:00","stop": "24:00:00","weekday": 8,"chargeLimit": "%s"}]}''' % str(currentLimit)
requests.post(url, data=data, json=None, headers={'Content-Type': 'application/json; charset=UTF-8'})
Hope this will help anyone else like me that is searching for a simple solution to control their charger! 8-)
fhloston
Posts: 1
Joined: Thursday 08 April 2021 21:44
Target OS: Linux
Domoticz version:
Contact:

Re: Get energy consumption (and more) from EV charger

Post by fhloston »

Hi, here is my few cents...

Maybe I should wait to post this as this part of the interface is currently broken. It broke in 1.2.2 from Garo. currently it is in 1.2.3 and still broken. I have a ticket for it at Garo though, so hoping to get it fixed....

"chargeStatus":64

This piece is giving that charge status of the car, or was before 1.2.2. I added that to the script created by waaren

I added a percentage device that shows current charge level of the car, and a nice graph of the history (when the box actually reports the correct values, currently it is very fond of reporting 64, but it varies).

And made some additions to the code. Look for "chargestatus" and "chargelevel"

My script now looks like this:

Code: Select all

-- Garo EV charger

--[[ 
            Create dummy hardware                               ( https://www.domoticz.com/wiki/Hardware_Setup#Dummy_Hardware )
            Create two virtual devices on the dummy hardware    ( https://www.domoticz.com/wiki/Virtual_meter )
            1. Alert Device
            2. Electric (instant and counter)
            
            modify names in lines between -- +++++++++
]] --
local callBack = "GaroCharger"

return {
             on =   {  
                        timer           =   { "every minute" },     -- when freq changed, energy total calc. must be modified as well (search for 60 in this script)   
                        httpResponses   =   { callBack       },    
                    },
                     
        logging =   {   
                        level   =   domoticz.LOG_DEBUG,                   
                        marker  =   "Garo EV charger"
                    },
                        
           data =   {   notificationSend = { initial = false     },
                        message          = { initial = ""        },
                        timeSend         = { initial = "not yet" },
                    },
     
    execute = function(dz,item)
       
        -- ++++++++++++++++ Enter your setting between these lines +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        local testMode              = false                    -- set to false when live
        local alert                 = dz.devices("garo Alert") -- Change to the name you use for this device
        local power                 = dz.devices("garo Power") -- Change to the name you use for this device
        local chargelevel           = dz.devices("Kona Charge") -- Charge level of car
        local notificationResetTime = "09:00"                  -- Set time at when you want the notication to repeat when still not Connected
        
        local myNotificationTable   = {                         -- table with one or more notification systems. 
                                                                -- Can be one or more of them
                                                                -- Remove "--" in front of all notification systems you want to use    
                                                                -- dz.NSS_GOOGLE_CLOUD_MESSAGING, 
                                                                dz.NSS_PUSHOVER,               
                                                                -- dz.NSS_HTTP, 
                                                                -- dz.NSS_KODI, 
                                                                -- dz.NSS_LOGITECH_MEDIASERVER, 
                                                                -- dz.NSS_NMA,
                                                                dz.NSS_PROWL, 
                                                                -- dz.NSS_PUSHALOT, 
                                                                -- dz.NSS_PUSHBULLET, 
                                                                -- dz.NSS_PUSHOVER, 
                                                                -- dz.NSS_PUSHSAFER,
                                        }
        -- ++++++++++++++++ No modification should be needed below this line +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        
        local alertLevel            = dz.ALERTLEVEL_GREEN
        local connectionOK          = "CONNECTED" 
        local testData              = '{"ocppState": null,"connector": "CONNECTED","mode": "ALWAYS_OFF","currentChargingPower": 2227.1,"chargeStatus":44}' -- not used when live    
        local repeatNotification    = dz.time.matchesRule("at " .. notificationResetTime) and alert.color == dz.ALERTLEVEL_RED 
        
        -- output to domoticz log
        local function logWrite(str,level)
            dz.log(tostring(str),level or dz.LOG_DEBUG)
        end

        logWrite ("triggered by " .. item.trigger)
        
        -- call the url to get the JSON
        local function getJSON()
            local url = "http://192.168.1.18:2222/rest/chargebox/status?_=1546334042114"
            if testMode then
                url    = dz.settings['Domoticz url'] .. "/json.htm?type=command&param=addlogmessage&message=ChargeBox_test"
            end
            dz.openURL({    url =  url,
                            method = "GET",
                            callback = callBack })
        end
        
        -- convert json data to Lua table
        local function json2Table()
            if testMode then
                return dz.utils.fromJSON(testData)
            else  
                return dz.utils.fromJSON(item.data)
            end    
        end
        
        -- Get the relevant fields
        local function extractFields(t)
            return t.connector,t.currentChargingPower,t.chargeStatus
        end
        
        local function updatePersistentData(val,message)
            dz.data.notificationSend = val
            if val then 
                dz.data.timeSend = dz.time.raw
                dz.data.message  = message
            end    
        end
        -- send notification to all systems active and in myNotificationTable when status changed or once a day
        local function notify(message, forced)
            if forced or not dz.data.notificationSend then
                dz.notify("Garo charger", message, dz.PRIORITY_NORMAL, dz.SOUND_INTERMISSION,    "",   myNotificationTable ) 
                updatePersistentData(true,message)        
            end
       end
        
        -- Update devices when needed   
        local function fillDevices(connected, Power, Chargelevel)
            local changed = false
            if alert.text ~= connected then
                changed = true
                if connected ~= connectionOK then
                    alertLevel = dz.ALERTLEVEL_RED
                end
                alert.updateAlertSensor(alertLevel, connected)
                updatePersistentData(false)        
            end
            energy = power.WhTotal + Power / 60                     -- if you change the frequncy of the script you should also change the 60
            power.updateElectricity(Power, energy) 
            chargelevel.updatePercentage(Chargelevel)
            return changed
       end
        
        -- Main 
        if item.isTimer then
            getJSON()
        else
            local connector, currentChargingPower, chargeStatus = extractFields(json2Table())
            if fillDevices(connector, currentChargingPower, chargeStatus) or repeatNotification then
                notify("Charger is " .. connector, repeatNotification )
            end
        end
    end
}
StarkJohan
Posts: 2
Joined: Wednesday 24 March 2021 18:49
Target OS: Linux
Domoticz version:
Contact:

Re: Get energy consumption (and more) from EV charger

Post by StarkJohan »

The REST api seems to have been moved from <ip>:2222/rest/chargebox/status to <ip>:8080/servlet/rest/chargebox/status
x3740xmx
Posts: 1
Joined: Tuesday 30 November 2021 9:44
Target OS: -
Domoticz version:
Contact:

Re: Get energy consumption (and more) from EV charger

Post by x3740xmx »

Has anyone managed to find a way who authorized the charge with rfid?
I have done some digging and found the seriallog and some other data.
If you open the web gui and then open the javascript console, these are some commands that can be executed.
javascript:openLogPopup() //Shows seriallog in the web ui
javascript:openSupportPopup() //Opens a modal for remote support?
javascript:downloadLogs() //Downloads seriallog from the last day
javascript:downloadSettings() //Exports settings in a pdf
azzilla
Posts: 8
Joined: Tuesday 01 January 2019 16:16
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Get energy consumption (and more) from EV charger

Post by azzilla »

Fun to see that someone else than me have made use of this script. Thanks again for your help waaren.

I am trying to make sense of something else regarding the Garo charger script now..
I have setup load balancing for my charger as I kept blowing the main fuse in the house when I set charging to full capacity. The charger is recieving values from a power meter in the mains fusebox. The meter keeps track on the overall load on all phases and reports the usage to the charger so that the charging current automatically steps down when load is close the what the main fuse is rated for. This has been such a great upgrade.
These values are available in json format via a subfolder in the url. In my case the url looks like this:
http://xxx.xx.x.xxx:8080/servlet/rest/c ... o/EXTERNAL and the values shown looks like this:
Image
Note that the url could differ for you as I've read some about this in the HomeAssistant forums.

The values that are of interest are "phaseXCurrent" and the values shown in the image corresponds to:
"phase1Current: 48" = 4,8A
"phase2Current: 31" = 3,1A
"phase3Current: 5" = 0,5A

Now to my "ask" :)
I would love it if I could get some help with either tweaking this script or creating a seperate script so that I could get a Power Meter device in Domoticz for power consumption tracking for my total consumption.
I can't imagine that this would be impossible as the values shown for amperage could easily be converted from A to W with (in this specific case) amps multiplied by 23 for wattage. For some reason they have decided to use "deciamps" (?)
tantgron
Posts: 3
Joined: Wednesday 03 August 2022 23:02
Target OS: Linux
Domoticz version:
Contact:

Re: Get energy consumption (and more) from EV charger

Post by tantgron »

I don't know if this thread is dead already, but I got my Garo ev-charger without the "databoard" that I installed later as a spare part, a regular Pi3 with some plastic material covering.

I copied the memory card before I even installed it for the first time, and also running it of a not-garo memory card.

If it would be if any help, I got it as a dump to e-mail/Dropbox.

Sorry for bad English.
tantgron
Posts: 3
Joined: Wednesday 03 August 2022 23:02
Target OS: Linux
Domoticz version:
Contact:

Re: Get energy consumption (and more) from EV charger

Post by tantgron »

It is a GLBDC-T222FC.
janbjorn
Posts: 2
Joined: Thursday 17 November 2022 0:37
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Get energy consumption (and more) from EV charger

Post by janbjorn »

tantgron wrote: Wednesday 03 August 2022 23:08 I copied the memory card before I even installed it for the first time, and also running it of a not-garo memory card.

If it would be if any help, I got it as a dump to e-mail/Dropbox.
I'd be really interested in that Pi3 dump if you still have it laying around. Accidentally ordered my charger without the "Wifi-card" and have a bunch of Pi3's laying around...
henjo
Posts: 2
Joined: Thursday 16 February 2023 11:44
Target OS: Linux
Domoticz version:
Contact:

Re: Get energy consumption (and more) from EV charger

Post by henjo »

Hi,
I have just bought a Garo GLB charger without the WIFI module. I am curious if anyone got it working with a regular RPI and a angled header connector?
henjo
Posts: 2
Joined: Thursday 16 February 2023 11:44
Target OS: Linux
Domoticz version:
Contact:

Re: Get energy consumption (and more) from EV charger

Post by henjo »

tantgron wrote: Wednesday 03 August 2022 23:08 I copied the memory card before I even installed it for the first time, and also running it of a not-garo memory card.

If it would be if any help, I got it as a dump to e-mail/Dropbox.
Hi,
I would be very happy if you sent me a copy of the SD-card dump.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 0 guests