Page 8 of 9

Re: Python Plugin: Volvo EV

Posted: Tuesday 15 October 2024 10:35
by akamming
rensbr wrote: Tuesday 15 October 2024 10:20
rensbr wrote: Friday 20 September 2024 13:22 Since every (post) function we try returns an error 500, it looks liket that someting is clearly wrong on the Volvo side, so I can report that to them.
To quote myself, It looks like Volvo has changed something at their side, because locking/unlocking the car seems to work now.
Tx, glad it works!

Unfortunately that is not the only thing Volvo changed: They also now enforce 2factor authentication. Fortunately i already built the support for that some time ago, but it more work to get the plugin up and running.

So if you get "unauthenticated" messages in the plugin logging: See the paragraph "2 Factor Authentication" in the docs (https://github.com/akamming/Domoticz_Vo ... rge_Plugin) on how to fix (basically running the authenticate.py script in the plugin directory and restart the plugin) to fix

Re: Python Plugin: Volvo EV

Posted: Tuesday 15 October 2024 10:36
by rensbr
akamming wrote: Tuesday 15 October 2024 10:35
rensbr wrote: Tuesday 15 October 2024 10:20
rensbr wrote: Friday 20 September 2024 13:22 Since every (post) function we try returns an error 500, it looks liket that someting is clearly wrong on the Volvo side, so I can report that to them.
To quote myself, It looks like Volvo has changed something at their side, because locking/unlocking the car seems to work now.
Tx, glad it works!

Unfortunately that is not the only thing Volvo changed: They also now enforce 2factor authentication.

So if you get "unauthenticated" messages in the plugin logging: See the paragraph "2 Factor Authentication" in the docs (https://github.com/akamming/Domoticz_Vo ... rge_Plugin) on how to fix (basically running the authenticate.py script in the plugin directory and restart the plugin) to fix
I haven't expericied any problems, so far. But good to know that your plugin also supports 2FA now, great work!

Re: Python Plugin: Volvo EV

Posted: Tuesday 15 October 2024 10:52
by akamming
rensbr wrote: Tuesday 15 October 2024 10:36
I haven't expericied any problems, so far. But good to know that your plugin also supports 2FA now, great work!
Very likely that's because you are already on the latest version which support 2FA and already made the tokens persistent for a restart. But if domoticz is down for about 2 hours, you will need to re-authenticate and then you will now need to use the 2FA authorization script

Re: Python Plugin: Volvo EV

Posted: Tuesday 15 October 2024 11:06
by HvdW
Since 09-10-2024 the plugin didn't update anymore.
Several times I reset the car,.... nothing
I just read the posts about 2FA and did the sequence.

Still,.... nothing
The logs:

Code: Select all

2024-10-15 11:00:59.692 Status: PluginSystem: Failed dynamic library load, install the latest libpython3.x library that is available for your platform.
2024-10-15 11:00:59.719 Status: PluginSystem: 'Volvo' Registration ignored, Plugins are not enabled.

Re: Python Plugin: Volvo EV

Posted: Tuesday 15 October 2024 11:17
by akamming
HvdW wrote: Tuesday 15 October 2024 11:06 Since 09-10-2024 the plugin didn't update anymore.
Several times I reset the car,.... nothing
I just read the posts about 2FA and did the sequence.

Still,.... nothing
The logs:

Code: Select all

2024-10-15 11:00:59.692 Status: PluginSystem: Failed dynamic library load, install the latest libpython3.x library that is available for your platform.
2024-10-15 11:00:59.719 Status: PluginSystem: 'Volvo' Registration ignored, Plugins are not enabled.
What is the next step?
Your error has nothing to do with 2FA.

it's in the line:

Code: Select all

2024-10-15 11:00:59.692 Status: PluginSystem: Failed dynamic library load, install the latest libpython3.x library that is available for your platform.
Domoticz doesn't load any plugins, due to the fact there is something wrong with the python library on your system...

i am not a system administrator, maybe someone else can give a clue on how to fix this... (or do a google search on this error message, it does give a lot of hits with people who have had this issue before)

Re: Python Plugin: Volvo EV

Posted: Tuesday 15 October 2024 11:34
by HvdW
Problem solved:
Found this page.
Did:

Code: Select all

sudo apt-get install python3.11-dev
Why it did function normally befor the 9th of october?
No idea.

Hope this helps other in troubleshooting.

PS
Afrterwards everything gets clear.
I changed SD card for a new one, so python3.11-dev wasn't installed.
Positive:
I copied the old Domoticz directory to the new SD card as domoticz.bak directory to be able to copy domoticz.db to the newly install.
When installing Domoticz with

Code: Select all

sudo bash -c "$(curl -sSfL https://install.domoticz.com)"
to my surprise the 'Domoticz automated installer' found and used the former setup so all I had to do was nothing . Everything was back in place like before.
Everything, except python3.11-dev
Maybe the developers can add that one as well in the future like if imported plugins then install python3.11-dev

Remaining charging time

Posted: Sunday 03 November 2024 1:18
by HvdW
The Volvo plugin offers new opportunities.
First of all it can be used to set a desired charging level.
Create a sensor , a slider to set a level from 0 to 100%
Compare the desired level with domoticz.devices('XC40-ChargeLevel').state and control when the battery charging should be stopped.

On the other hand it is nice to be able to see after how many hours and minutes the desired charging level will be reached an write this information in a Text sensor.

Code: Select all

  -------- AUTO OPLADEN  ----------------
 
        if domoticz.devices('Volvo-aangesloten').state ~= 'Disconnected' then
            carConnected = 'Connected'
        else
            carConnected = 'not Connected' 
        end
        
        if laadvermogen > 1000 then -- if charging is in progress
            laadvermogen = domoticz.devices('Laadpaal').actualWatt/1000
        else
            laadvermogen = 3600/1000  -- calculate using the max current of 16A (in my case)
        end
        -- x/1000  is Watt to kW
        
        local batteryCapacity = 79 -- kW
       
        -- laadtijd berekenen tot dynamisch
        local remainingTime = (batteryCapacity/100)*((domoticz.devices('XC40 battery charge set').levelVal - domoticz.devices('XC40-ChargeLevel').state))/laadvermogen
               
        uren, honderdsten = math.modf(remainingTime)
        minuten = honderdsten*60
        minuten = math.floor(minuten+0.5)
        
        domoticz.devices('Volvo').setIcon(107)
        domoticz.devices('Volvo').updateText('Charge level set     ' .. tostring(domoticz.devices('XC40 battery charge set').levelVal) ..'%'.. 
            '\n Charge level actual   ' .. tostring(domoticz.devices('XC40-ChargeLevel').nValue) ..'% '..
            '\n Plug connected    ' .. carConnected ..
            -- '\n Plug connected    ' .. chargingState ..
            '\n \n \n      Charging level     ' .. domoticz.devices('Charging Level').state ..
            '\n &emsp;&emsp;&emsp;&emsp; Charging state &nbsp;&emsp;&emsp;&emsp;' .. domoticz.devices('Volvo-Opladen').state ..'</font> '..
            '\n \n &emsp; Charging to '..tostring(domoticz.devices('XC40 battery charge set').levelVal)..'% : '.. tostring(uren) .. ' hours, ' .. tostring(minuten) .. ' minutes'..
            '\n &nbsp;')

Re: Remaining charging time

Posted: Sunday 03 November 2024 9:03
by akamming
HvdW wrote: Sunday 03 November 2024 1:18 The Volvo plugin offers new opportunities.
First of all it can be used to set a desired charging level.
Create a sensor , a slider to set a level from 0 to 100%
Compare the desired level with domoticz.devices('XC40-ChargeLevel').state and control when the battery charging should be stopped.

On the other hand it is nice to be able to see after how many hours and minutes the desired charging level will be reached an write this information in a Text sensor.

Code: Select all

  -------- AUTO OPLADEN  ----------------
 
        if domoticz.devices('Volvo-aangesloten').state ~= 'Disconnected' then
            carConnected = 'Connected'
        else
            carConnected = 'not Connected' 
        end
        
        if laadvermogen > 1000 then -- if charging is in progress
            laadvermogen = domoticz.devices('Laadpaal').actualWatt/1000
        else
            laadvermogen = 3600/1000  -- calculate using the max current of 16A (in my case)
        end
        -- x/1000  is Watt to kW
        
        local batteryCapacity = 79 -- kW
       
        -- laadtijd berekenen tot dynamisch
        local remainingTime = (batteryCapacity/100)*((domoticz.devices('XC40 battery charge set').levelVal - domoticz.devices('XC40-ChargeLevel').state))/laadvermogen
               
        uren, honderdsten = math.modf(remainingTime)
        minuten = honderdsten*60
        minuten = math.floor(minuten+0.5)
        
        domoticz.devices('Volvo').setIcon(107)
        domoticz.devices('Volvo').updateText('Charge level set &nbsp;&ensp;&emsp;&emsp;' .. tostring(domoticz.devices('XC40 battery charge set').levelVal) ..'%'.. 
            '\n Charge level actual &nbsp;&emsp;' .. tostring(domoticz.devices('XC40-ChargeLevel').nValue) ..'% '..
            '\n Plug connected &emsp;&emsp;&emsp;' .. carConnected ..
            -- '\n Plug connected &emsp;&emsp;&emsp;' .. chargingState ..
            '\n \n \n &emsp;&emsp;&emsp;&emsp; Charging level &ensp;&emsp;&emsp;&emsp;' .. domoticz.devices('Charging Level').state ..
            '\n &emsp;&emsp;&emsp;&emsp; Charging state &nbsp;&emsp;&emsp;&emsp;' .. domoticz.devices('Volvo-Opladen').state ..'</font> '..
            '\n \n &emsp; Charging to '..tostring(domoticz.devices('XC40 battery charge set').levelVal)..'% : '.. tostring(uren) .. ' hours, ' .. tostring(minuten) .. ' minutes'..
            '\n &nbsp;')
The volvo plugin (unfortunately) does not offer support to set the target charging level (i it is wish for me to implement it, but unfortunately the functionality is not available in the Volvo API). I assume you are referring to a custom script someone made which controls the wallbox based on the SoC level which is reported by the plugin..

Re: Python Plugin: Volvo EV

Posted: Sunday 03 November 2024 10:19
by HvdW
Your assumption is correct.
I'm using the data received from the Volvo plugin about current charging level.
A slider switch in Domoticz sets the desired battery level.
SmartEVSE cuts off the charging when the reported charging level from the Volvo plugin matches the preset level from the slider.

Beforehand I used a relay like this one to switch mains to the charging box.
I have changed the charging box to be smart using a SmartEVSE device and now the charging can be started and charging current changed using MQTT.

Re: Python Plugin: Volvo EV

Posted: Tuesday 05 November 2024 11:38
by joostvanderlinde
akamming wrote: Tuesday 15 October 2024 10:35
rensbr wrote: Tuesday 15 October 2024 10:20
rensbr wrote: Friday 20 September 2024 13:22 Since every (post) function we try returns an error 500, it looks liket that someting is clearly wrong on the Volvo side, so I can report that to them.
To quote myself, It looks like Volvo has changed something at their side, because locking/unlocking the car seems to work now.
Tx, glad it works!

Unfortunately that is not the only thing Volvo changed: They also now enforce 2factor authentication. Fortunately i already built the support for that some time ago, but it more work to get the plugin up and running.

So if you get "unauthenticated" messages in the plugin logging: See the paragraph "2 Factor Authentication" in the docs (https://github.com/akamming/Domoticz_Vo ... rge_Plugin) on how to fix (basically running the authenticate.py script in the plugin directory and restart the plugin) to fix
When I first saw the mention of 2FA in this thread my plugin was till working so i did not pay much attention to it.... Today I noticed the data of my my C40 devices were outdated and I noticed a 'client not authorized' in the log.
Solution was indeed pretty simple: Update the plugin and run the authorize.py script. As per https://github.com/akamming/Domoticz_Vo ... rge_Plugin

Nice!!!

Re: Python Plugin: Volvo EV

Posted: Sunday 17 November 2024 12:36
by HvdW
I just wrote some new text for my Volvo text sensor.

Code: Select all

        if domoticz.devices('Volvo-aangesloten').state ~= 'Disconnected' then
            carConnected = 'Connected'
        else
            carConnected = 'not Connected' 
        end
           if laadvermogen > 1000 then 
            laadvermogen = domoticz.devices('Laadpaal').actualWatt/1000
        else
            laadvermogen = 3600/1000  -- Watt to kWh
        end
        
        -- calculate range
        local batteryCapacity = 79 -- kW
        local certainRange = 25    -- kWh/100km
        local currentRange = math.floor((domoticz.devices('XC40-ChargeLevel').state * batteryCapacity)/certainRange)
        local expectedRange = math.floor((domoticz.devices('XC40 battery charge set').levelVal * batteryCapacity)/certainRange)
        
        
        -- laadtijd berekenen tot dynamisch
        local resttijd = (batteryCapacity/100)*((domoticz.devices('XC40 battery charge set').levelVal - domoticz.devices('XC40-ChargeLevel').state))/laadvermogen
        domoticz.log('Battery set - Battery state '..domoticz.devices('XC40 battery charge set').levelVal..' - '.. domoticz.devices('XC40-ChargeLevel').state.. 'Laadvermogen : '..laadvermogen,domoticz.LOG_DEBUG)
        -- resttijd = round(resttijd,2)
        uren, honderdsten = math.modf(resttijd)
        minuten = honderdsten*60
        minuten = math.floor(minuten+0.5)
        -- certain range based on 25 kWh/100km
        
        domoticz.devices('Volvo').setIcon(107)
        domoticz.devices('Volvo').updateText('Charge level set &nbsp;&ensp;&emsp;&emsp;' .. tostring(domoticz.devices('XC40 battery charge set').levelVal) ..'%'.. 
            '\n Charge level actual &nbsp;&emsp;' .. tostring(domoticz.devices('XC40-ChargeLevel').nValue) ..'% '..
            '\n Plug connected &emsp;&emsp;&emsp;' .. carConnected ..
            -- '\n Plug connected &emsp;&emsp;&emsp;' .. chargingState ..
            '\n \n \n &emsp;&emsp;&emsp;&emsp; Expected range &ensp;&emsp;&emsp;' .. expectedRange ..' km '..
            '\n &emsp;&emsp;&emsp;&emsp; Current range &nbsp;&emsp;&emsp;&emsp;' .. currentRange ..' km'..
            '\n \n &emsp; Charging to '..tostring(domoticz.devices('XC40 battery charge set').levelVal)..'% : '.. tostring(uren) .. ' hours, ' .. tostring(minuten) .. ' minutes'..
            '\n &nbsp;')
     
Up till now it displayed Charging state and Set charging state.
volvo.jpg
volvo.jpg (16.82 KiB) Viewed 1985 times
It now displays Expected Range and Actual Range as well.
Range is calculated using an electricity consumption of 25 kWh/100 km which is based on the Spritmonitor consumption.
In summer our Volvo uses 23 kWh/100 km, in winter 25 kWh/100 km

Re: Python Plugin: Volvo EV

Posted: Thursday 21 November 2024 7:20
by rensbr
Updated the plugin today and runt the script, works like a charm with my EX30 now, thanks! @akamming

Re: Python Plugin: Volvo EV

Posted: Friday 13 December 2024 21:02
by HvdW
On tweakers I saw this:

Code: Select all

 "data": [
        {
            "command": "LOCK_REDUCED_GUARD",
            "href": "/v2/vehicles/vin/commands/lock-reduced-guard"
        },
        {
            "command": "LOCK",
            "href": "/v2/vehicles/vin/commands/lock"
        },
        {
            "command": "UNLOCK",
            "href": "/v2/vehicles/vin/commands/unlock"
        },
        {
            "command": "HONK",
            "href": "/v2/vehicles/vin/commands/honk"
        },
        {
            "command": "HONK_AND_FLASH",
            "href": "/v2/vehicles/vin/commands/honk-flash"
        },
        {
            "command": "FLASH",
            "href": "/v2/vehicles/vin/commands/flash"
        },
        {
            "command": "CLIMATIZATION_START",
            "href": "/v2/vehicles/vin/commands/climatization-start"
        },
        {
            "command": "CLIMATIZATION_STOP",
            "href": "/v2/vehicles/vin/commands/climatization-stop"
        }
    ]
}
Flash & Honk

Re: Python Plugin: Volvo EV

Posted: Saturday 14 December 2024 14:41
by FireWizard
Hi @HvdW,

You can easily check, what commands are supported by your car, by querying the following endpoint:

https://api.volvocars.com/connected-veh ... >/commands

This will return an array of objects. Each element in the array will list the specific command and its endpoint.

For flash and honk it is:

https://api.volvocars.com/connected-veh ... honk-flash

Regards

Re: Python Plugin: Volvo EV

Posted: Tuesday 17 December 2024 15:57
by akamming
HvdW wrote: Friday 13 December 2024 21:02 On tweakers I saw this:

Code: Select all

 "data": [
        {
            "command": "LOCK_REDUCED_GUARD",
            "href": "/v2/vehicles/vin/commands/lock-reduced-guard"
        },
        {
            "command": "LOCK",
            "href": "/v2/vehicles/vin/commands/lock"
        },
        {
            "command": "UNLOCK",
            "href": "/v2/vehicles/vin/commands/unlock"
        },
        {
            "command": "HONK",
            "href": "/v2/vehicles/vin/commands/honk"
        },
        {
            "command": "HONK_AND_FLASH",
            "href": "/v2/vehicles/vin/commands/honk-flash"
        },
        {
            "command": "FLASH",
            "href": "/v2/vehicles/vin/commands/flash"
        },
        {
            "command": "CLIMATIZATION_START",
            "href": "/v2/vehicles/vin/commands/climatization-start"
        },
        {
            "command": "CLIMATIZATION_STOP",
            "href": "/v2/vehicles/vin/commands/climatization-stop"
        }
    ]
}
Flash & Honk
This was my own message on tweakers (and already implemented flash-honk). So if you update to latest version it should work. (although it does require OTA update 3.3.16 on several cars before it works)

Re: Python Plugin: Volvo EV

Posted: Wednesday 25 December 2024 12:51
by akamming
For whoever is updating this plugin to latest version:

Volvo changed some things on the backend, which caused false "unspecified" values for the switches. I changed the code to use text sensors instead of selector switches.

So if you upgrade: You can delete all selector switches which were created by this plugin

Re: Python Plugin: Volvo EV

Posted: Sunday 05 January 2025 15:15
by HvdW
For the people who use this plugin and are interested in getting more data about the car there is this script which displays the EV consumtion in a text sensor.
To be published soon <Once a month data are written to a file so that you end up with a file in which average consumtion is calculated plus the average temperature.> (there seems to be some kind of relationship between thes two)
I hope that Volvo will add average speed in the API in the near future because there seems to be some kind of relationship between speed and consumtion as well.

Code: Select all

-- local function
local function spaces(count)
    return string.rep("&nbsp;", count)
end

return {
    on = {
        devices = {'Charging Level'},
        -- timer = {'at 23:21'}
    },
    logging = {
        level = domoticz.LOG_DEBUG,
        marker = "EV Verbruik"
    },
    data = {
        previousTimeStamp = { initial = '' },
        previousOdometer = { initial = 0 },
        previousBatteryLevel = { initial = 0 },
        previousdeltaDistance = { initial = 0 },
        previouskWhTotal = { initial = 0 },
        previouskWhPartial = { initial = 0 },
        previouskWh100km = { initial = 0 },
        previousEuro = { initial = 0 },
        previousavgTemp = { initial = 0 },
        previousselectorLevel = { initial = 0 },
        tempArray = { initial = {} }
    },
    execute = function(domoticz, device)
        -- Constants
        local BATTERY_CAPACITY = 79 -- kWh
        local PRICE_PER_KWH = 0.25 -- euro/kWh
        local CSV_FILE_PATH = "/home/pi/car_charging.csv"


        -- Lees de huidige waarden
        local selectorLevel = domoticz.devices('Charging Level').levelVal
        local batteryLevel = domoticz.devices('XC40-ChargeLevel').nValue
        local currentOdometer = domoticz.devices('Volvo-Odometer').nValue
        local currentkWhTotal = domoticz.devices('Laadpaal').WhTotal / 1000
        local temperature = tonumber(domoticz.devices('Buitentemperatuur').sValue)

        -- Controleer of alle benodigde waarden aanwezig zijn
        if not (selectorLevel and batteryLevel and currentOdometer and currentkWhTotal and temperature) then
            domoticz.log('Een of meer benodigde devices ontbreken of hebben geen waarde', domoticz.LOG_ERROR)
            return
        end

        local timestamp = os.date('%d-%m-%Y %H:%M')

        -- Lees het CSV bestand
        local file = io.open(CSV_FILE_PATH, "r")
        if file then
            local lastLine
            for line in file:lines() do
                lastLine = line
            end
            file:close()

            if lastLine then
                local fields = {}
                for field in string.gmatch(lastLine, "([^;]+)") do
                    table.insert(fields, field)
                end

                if #fields >= 9 then
                    domoticz.data.previousTimestamp = fields[1]
                    domoticz.data.previousOdometer = tonumber(fields[2]) or 0
                    domoticz.data.previousBatteryLevel = tonumber(fields[3]) or 0
                    domoticz.data.previousDeltaDistance = tonumber(fields[4]) or 0
                    domoticz.data.previouskWhTotal = tonumber(fields[5]) or 0
                    domoticz.data.previouskWhPartial = tonumber(fields[6]) or 0
                    domoticz.data.previouskWh100km = tonumber(fields[7]) or 0
                    domoticz.data.previousEuro = tonumber(fields[8]) or 0
                    domoticz.data.previousavgTemp = tonumber(fields[9]) or 0
                end
            end
        else
            domoticz.log('Kan het bestand niet openen: ' .. CSV_FILE_PATH, domoticz.LOG_ERROR)
        end

        -- Debug logging
        domoticz.log('Selector Level : ' .. selectorLevel, domoticz.LOG_DEBUG)
        domoticz.log('batteryLevel : ' .. batteryLevel, domoticz.LOG_DEBUG)
        domoticz.log('previousOdometer : ' .. domoticz.data.previousOdometer, domoticz.LOG_DEBUG)
        domoticz.log('currentOdometer : ' .. currentOdometer, domoticz.LOG_DEBUG)
        domoticz.log('currentkWhTotal : ' .. currentkWhTotal, domoticz.LOG_DEBUG)
        domoticz.log('Temperature : ' .. temperature, domoticz.LOG_DEBUG)
        domoticz.log('Timestamp : ' .. timestamp, domoticz.LOG_DEBUG)
        domoticz.log('Battery Capacity : ' .. BATTERY_CAPACITY, domoticz.LOG_DEBUG)
        domoticz.log(' ', domoticz.LOG_DEBUG)

        -- Temperatuur berekeningen
        table.insert(domoticz.data.tempArray, temperature)
        local sumTemp = 0
        for _, temp in ipairs(domoticz.data.tempArray) do
            sumTemp = sumTemp + temp
        end
        local avgTemp = sumTemp / #domoticz.data.tempArray

        -- Controleer laadstatus verandering
        if domoticz.data.previousselectorLevel > 0 and selectorLevel == 0 then
            local distance = currentOdometer - domoticz.data.previousOdometer
            local kWhPartial = currentkWhTotal - domoticz.data.previouskWhTotal
            local euro = kWhPartial * PRICE_PER_KWH

            -- Verbeterde EV consumptie berekening
            local batteryLevelDifference = (batteryLevel - domoticz.data.previousBatteryLevel)
            local batteryLevelDifferencekWh = batteryLevelDifference * (BATTERY_CAPACITY/100)
            local evConsumption = 0
            
            
            --local evConsumption = (kWhPartial - batteryLevelDifferencekWh) * (distance/10) 
            
            if distance > 0 then  -- Voorkom delen door nul
                --evConsumption = (kWhPartial - batteryLevelDifferencekWh) * (100/distance)
                evConsumption = ((kWhPartial - batteryLevelDifferencekWh)/distance)*100
            end

            -- Update display met formatting
            local displayText = string.format(
                "Datum : %s\n" ..
                "Current Odometer : %d\n" ..
                "Battery Level : %d\n" ..
                "Afstand : %d\n" ..
                "Partial kWh : %.2f\n" ..
                spaces(15).."Euro : %.2f\n" ..
                spaces(15).."Gemiddelde Temp : %.1f\n" ..
                spaces(15).."EV Consumption : %.2f kWh/100km\n\n",
                timestamp, 
                currentOdometer, 
                batteryLevel,
                distance, 
                kWhPartial, 
                euro, 
                avgTemp, 
                evConsumption
            )

            -- Update het display device
            local displayDevice = domoticz.devices('Charging Display')
            if displayDevice then
                displayDevice.updateText(displayText)
            else
                domoticz.log('Charging Display device niet gevonden', domoticz.LOG_ERROR)
            end

            -- Extra debug logging
            domoticz.log('*********************************** ', domoticz.LOG_DEBUG)
            domoticz.log(' ', domoticz.LOG_DEBUG)
            domoticz.log('Selector Level : ' .. selectorLevel, domoticz.LOG_DEBUG)
            domoticz.log('previousbatteryLevel : ' .. domoticz.data.previousBatteryLevel, domoticz.LOG_DEBUG)
            domoticz.log('batteryLevel : ' .. batteryLevel, domoticz.LOG_DEBUG)
            domoticz.log('batteryLevelDifference : ' .. batteryLevelDifference, domoticz.LOG_DEBUG)
            domoticz.log('batteryLevelDifferencekWh : ' .. batteryLevelDifferencekWh, domoticz.LOG_DEBUG)
            domoticz.log('previouskWhPartial : ' .. domoticz.data.previouskWhPartial, domoticz.LOG_DEBUG)
            domoticz.log('kWhPartial : ' .. kWhPartial, domoticz.LOG_DEBUG)
            domoticz.log('kWhPartial - batteryLevelDifferencekWh : ' .. kWhPartial - batteryLevelDifferencekWh, domoticz.LOG_DEBUG)
            domoticz.log('previousOdometer : ' .. domoticz.data.previousOdometer, domoticz.LOG_DEBUG)
            domoticz.log('currentOdometer : ' .. currentOdometer, domoticz.LOG_DEBUG)
            domoticz.log('previouskWhTotal : ' .. domoticz.data.previouskWhTotal, domoticz.LOG_DEBUG)
            domoticz.log('currentkWhTotal : ' .. currentkWhTotal, domoticz.LOG_DEBUG)
            domoticz.log('previouskWhPartial : ' .. domoticz.data.previouskWhPartial, domoticz.LOG_DEBUG)
            domoticz.log('kWhPartial : ' .. kWhPartial, domoticz.LOG_DEBUG)
            domoticz.log('Afstand : ' .. distance, domoticz.LOG_DEBUG)
            domoticz.log('evConsumption : ' .. evConsumption, domoticz.LOG_DEBUG)
            domoticz.log('Temperature : ' .. temperature, domoticz.LOG_DEBUG)
            domoticz.log('Gemiddelde Temp: ' .. avgTemp, domoticz.LOG_DEBUG)
            domoticz.log('Timestamp : ' .. timestamp, domoticz.LOG_DEBUG)
            domoticz.log(' ', domoticz.LOG_DEBUG)
        end

        -- Update selector level voor volgende iteratie
        domoticz.data.previousselectorLevel = selectorLevel
    end
}
It doesn't work from scratch.
In another post I have explained how to set charging limits using this plugin and a SmartEVSE charging post.
I have several other sensors.
- 'Charging Level' a selector switch which switches Off, 6A, 8A, 10A, 13A, 16A depending on PV power production
- 'EVSE Swich 16A' a switch to bypass PV powered car charging.
- The 'Charging Display' which shows several data amongst which kWh / 100km

Re: Python Plugin: Volvo EV

Posted: Sunday 05 January 2025 21:12
by FireWizard
Hello @HvdW,

You wrote:
I hope that Volvo will add average speed in the API in the near future because there seems to be some kind of relationship between speed and consumtion as well.
Average Speed is already available for a long time, both in the "Connected-Vehicle" API, as well in the "Legacy" API

See: https://developer.volvocars.com/apis/co ... tatistics/

Regards

Re: Python Plugin: Volvo EV

Posted: Sunday 05 January 2025 22:06
by HvdW
FireWizard wrote: Sunday 05 January 2025 21:12 Average Speed is already available for a long time, both in the "Connected-Vehicle" API, as well in the "Legacy" API
I cannot find a device with a name like speed or average in the Devices.
Hope akamming can add it to the Volvo plugin.

Re: Python Plugin: Volvo EV

Posted: Sunday 05 January 2025 22:44
by waltervl
You can add it yourself too in the plugin and help akamming to improve the plugin....