Page 1 of 1
Script or Blockly for activate switch when battery is low
Posted: Tuesday 14 August 2018 15:31
by NetEye
I have a 24V battery which I monitor with a INA219 (Volt), I manually start the charger with a relais by a switch in domoticz.
Can anyone help me to make this action automatic?
For instance when the INA219 shows 23 Volt, -> activate the switch which starts the charger.
I use ESPEasy and a RPi as controller.
The voltage reading is a INA219 sensor connected to a ESP8266 with ESPEasy as software which measures voltage.
What I liked to have is for instance at 23 Volt it can activate an relais which is connected also to the ESP.
The relay works with the command:
Http://<ESP IP adresss>/control?cmd=GPIO,<pin>,0
Http://<ESP IP adresss>/control?cmd=GPIO,<pin>,1
(One for start and one for stop).
I read about rules in ESPEasy or Blockly in Domoticz and also there is a way with scripts.
I’am not familiar with these, maybe someone who can coach me?
Maybe somebody has a script which I maybe can modify to my wishes?
Regards
Re: Script or Blockly for activate switch when battery is low
Posted: Tuesday 14 August 2018 19:20
by waaren
NetEye wrote: ↑Tuesday 14 August 2018 15:31
I have a 24V battery which I monitor with a INA219 (Volt), I manually start the charger with a relais by a switch in domoticz.
Can anyone help me to make this action automatic?
For instance when the INA219 shows 23 Volt, -> activate the switch which starts the charger.
I use ESPEasy and a RPi as controller.
Maybe somebody has a script which I maybe can modify to my wishes?
Regards
How do you readout the batterylevel now ? Do you have a URL or domoticz sensor for that ?
Re: Script or Blockly for activate switch when battery is low
Posted: Sunday 19 August 2018 9:16
by NetEye
Hallo waaren, thanks for your quick answer.
The voltage reading is a INA219 sensor connected to a ESP8266 with ESPEasy as software which measures voltage.
What I liked to have is for instance at 23 Volt it can activate an relais which is connected also to the ESP.
The relay works with the command:
Http://<ESP IP adresss>/control?cmd=GPIO,<pin>,0
Http://<ESP IP adresss>/control?cmd=GPIO,<pin>,1
(One for start and one for stop).
I read about rules in ESPEasy or Blockly in Domoticz and also there is a way with scripts.
I’am not familiar with these, maybe someone (you?) can coach me?
Hope I informed you complete?
Regards,
Jan
Re: Script or Blockly for activate switch when battery is low
Posted: Monday 20 August 2018 0:50
by waaren
NetEye wrote: ↑Sunday 19 August 2018 9:16
The voltage reading is a INA219 sensor connected to a ESP8266 with ESPEasy as software which measures voltage.
The relay works with the command:
Http://<ESP IP adresss>/control?cmd=GPIO,<pin>,0
Http://<ESP IP adresss>/control?cmd=GPIO,<pin>,1
(One for start and one for stop).
Some additional questions: do you see the voltage in domoticz and if so what is the name of that virtual voltage meter ?
Re: Script or Blockly for activate switch when battery is low
Posted: Monday 20 August 2018 8:11
by NetEye
Dear waaren,
Yes I can see the voltage in domoticz on it’s own id nr and his name is: Licht accu
Regards
Jan
Re: Script or Blockly for activate switch when battery is low
Posted: Monday 20 August 2018 12:15
by waaren
NetEye wrote: ↑Monday 20 August 2018 8:11
Dear waaren,
Yes I can see the voltage in domoticz on it’s own id nr and his name is: Licht accu
Regards
Jan
I hope I understand your requirements and setup correctly.
If not; please do not hesitate...
Look at the 10 lines
Using dzVents with Domoticz for a short intro to dzVents and howto get this script active in domoticz.
Code: Select all
-- operateRelay.lua
return {
on = { timer = { "every 10 minutes" }},
logging = { level = domoticz.LOG_DEBUG,
marker = "operateRelay" },
execute = function(dz)
-- Modify values below this line ----------
relaySwitch = dz.devices("relaySwitch") -- Name of your relaySwitch within quotes or idx without quotes
voltageSensor = dz.devices("Licht accu") -- Name of your voltageSensor within quotes or idx without quotes
lowVoltage = 23 -- below this value the switch will be turned on
highVoltage = 23.5 -- Above this value the switch will be turned off
hysteresisDelay = 10 -- Delay to prevent too frequent on/off actions
-- Modify values above this line ----------
if relaySwitch.lastUpdate.minutesAgo > hysteresisDelay then
if voltageSensor.voltage > highVoltage then
relaySwitch.switchOff().checkFirst()
elseif voltageSensor.voltage < lowVoltage then
relaySwitch.switchOff().checkFirst()
end
end
end
}