Battery charging terminate before 100% is reached
Posted: Monday 24 October 2022 1:13
Hi,
On the left side charging starts, it is switched off for a while, then charging continues and on the right side you see the # of Watts drop.
I want to use this phenomenon to protect the battery from being charged to 100% (which leads to a longer battery life)
So I want to measure Watt every minute and compare the current Watt with the Watt of let's say 10 minutes before.
If the Wattage dropped by 10% compared to 10 minutes before domoticz can switch off the switch which powers the charging. (this switch maybe a relay or a Shelly or whatever)
I have mastered dzvents a little bit, however can use some assistance.
- execute every minute
- copy value_9 to value_10
- copy value_8 to value_9
- copy value_7 to value_6
- copy value_6 to value_5
- copy value_5 to value_4
- copy value_4 to value_3
- copy value_3 to value_2
- copy value_2 to value_1
- read current value to value_0
- if value_0*1.1 < value_10
dz.devices(CHARGER_SWITCH).switchOff()
I made a start.
What you see is a charging diagram for charging a battery.On the left side charging starts, it is switched off for a while, then charging continues and on the right side you see the # of Watts drop.
I want to use this phenomenon to protect the battery from being charged to 100% (which leads to a longer battery life)
So I want to measure Watt every minute and compare the current Watt with the Watt of let's say 10 minutes before.
If the Wattage dropped by 10% compared to 10 minutes before domoticz can switch off the switch which powers the charging. (this switch maybe a relay or a Shelly or whatever)
I have mastered dzvents a little bit, however can use some assistance.
- execute every minute
- copy value_9 to value_10
- copy value_8 to value_9
- copy value_7 to value_6
- copy value_6 to value_5
- copy value_5 to value_4
- copy value_4 to value_3
- copy value_3 to value_2
- copy value_2 to value_1
- read current value to value_0
- if value_0*1.1 < value_10
dz.devices(CHARGER_SWITCH).switchOff()
I made a start.
Code: Select all
-- Script name is Batterycharger-switch
local CHARGER_SWITCH = 'ANY_SWITCH' -- switch device
local value_10 = 0
local value_9 = 0
local value_8 = 0
local value_7 = 0
local value_6 = 0
local value_5 = 0
local value_4 = 0
local value_3 = 0
local value_2 = 0
local value_1 = 0
local value_0 = 0
return
{
on =
{
timer =
{
'every minute'
},
-- device triggers
devices =
{
-- scripts is executed if the device that was updated matches with one of these triggers
'Battery switch', -- device name
},
},
--LOG levell: This is the log level you want for this script. Can be domoticz.LOG_INFO, domoticz.LOG_MODULE_EXEC_INFO, domoticz.LOG_DEBUG or domoticz.LOG_ERROR
--marker: A string that is prefixed before each log message. That way you can easily create a filter in the Domoticz log to see just these messages.
logging =
{
-- level: This is the log level you want for this script.
-- Can be domoticz.LOG_INFO, domoticz.LOG_MODULE_EXEC_INFO, domoticz.LOG_DEBUG or domoticz.LOG_ERROR
-- marker: A string that is prefixed before each log message.
level = domoticz.LOG_INFO and domoticz.LOG_DEBUG,
marker = "BATTERY CHARGER",
},
execute = function(dz)
}
-- end Batterycharger-switch