LUA script that manages electricity power

Moderator: leecollings

Post Reply
User avatar
psubiaco
Posts: 233
Joined: Monday 20 August 2018 9:38
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Italy
Contact:

LUA script that manages electricity power

Post by psubiaco »

Hi,
I've written a LUA script for Domoticz that add the following functions to Domoticz:

* power outage detect => turns on Leds (and other devices) in case of blackout (power failure)

* import and export power displaying, through red/green leds on DomBusTH (red led flashes 1 time if import power <1kW, 2 times if <2kW, ... green led flashes 1 time if export power <1kW, 2 times if power < 2kW, ....)

* in case of high power usage, program heat pump to work at lower level, or disconnect loads to prevent power disconnect. In case there are not any load that can be disconnect, send alert through leds/buzzer/siren, and send alert by Telegram

* automatically enable loads in case of extra power from renewable sources, to increase the own-consuming: for example activate an electric heater if temperature is below a level and available power is greater than heater power.

This is the procedure to install it (just copy and paste in the linux shell): for any troubles, don't hesitate to contact me by PM or Telegram ( creasol_psubiaco ).

Code: Select all

#from linux shell, type the following commands (copy and paste): lines starting with # are comments, and can be ignored
#become root
sudo su -
#enter domoticz directory /scripts/lua
cd ~pi/Domoticz/scripts/lua
if [ -d domoticz_lua_scripts ]; then
  cd domoticz_lua_scripts
  #update domoticz_lua_script local repository
  git pull
  cd ..
else
  which git
  if [ $? -ne 0 ]; then
    #install git
    apt install git
  fi
  #download domoticz_lua_scripts repository with all scripts
  git clone https://github.com/CreasolTech/domoticz_lua_scripts.git
fi
cp -i domoticz_lua_scripts/script_device_power.lua domoticz_lua_scripts/config_power.lua .
if [ ! -r globalvariables.lua ]; then cp domoticz_lua_scripts/globalvariables.lua . ; fi
if [ ! -r globalfunctions.lua ]; then cp domoticz_lua_scripts/globalfunctions.lua . ; fi
#now edit config file
nano config_power.lu
For those who use windows, just install the files script_device_power.lua config_power.lua globalvariables.lua globalfunctions.lua from https://github.com/CreasolTech/domoticz_lua_scripts to the domoticz/scripts/lua folder and edit those files to meet your home automation system.
Below a schema that resumes what the script does: obviously, it works with any device supported by Domoticz.
Image
Paolo
--
I use DomBus modules to charge EV car, get a full alarm system, control heat pump, fire alarm detection, lights and much more. Video
Facebook page - Youtube channel
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest