domoticz_lua_scripts

Domoticz lua scripts, developed by Creasol https://www.creasol.it/domotics

In this repository you can find several LUA scripts and config files for Domoticz, the easy and powerful open-source home automation system controller.

More information, scripts, application notes, examples are available at https://www.creasol.it/support/domotics-home-automation-and-diy

Some scripts require that you install the dkjson package, with the command apt install lua-dkjson

All scripts are free to use, with absolute no warranty. Use them at your own risk.

All global variables and functions are stored in the files globalvariables.lua and globalfunctions.lua.

** The scripts are used with out set of industrial and home automation system modules, made in Italy: for more info, check below! **

For any requests, you can join DomBus channel on Telegram

Script script_device_master.lua

This is a main script called every time a device changes state: it’s optimized to

Script POWER

File: power.lua and config_power.lua

Destination directory: DOMOTICZ_DIR/scripts/lua

Called by script_device_master.lua and triggered when a device containing Power or Button in its name changes state.

Used to check power from energy meter (SDM120, SDM230, …) and performs the following actions

  1. Send notification when consumed power is above a threshold (to avoid power outage)
  2. Enabe/Disable electric heaters or other appliances, to reduced power consumption from the electric grid
  3. Emergency lights: turn ON some LED devices in case of power outage, and turn off when power is restored
  4. Show on DomBusTH LEDs red and green the produced/consumed power: red LED flashes 1..N times if power consumption is greater than 1..N kW; green LED flashes 1..M times if photovoltaic produces up to 1..M kW

Script to computes self-consumption power and percentage, and self-sufficiency percentage

Files: script_time_selfconsumption.lua config_power.lua globalfunctions.lua globalvariables.lua

Destination directory: DOMOTICZ_DIR/scripts/lua

Called every minute

This is a mandatory script for those who have at least one reneable generation plant in their building.

It manages one or more energy production plants (photovoltaic on the roof, photovoltaic in the garden and or wind turbine, …) computing the total generated energy/power, total used energy/power, self-consumption energy/power, self-consumption percentage and self-sufficiency percentage.

These are goods indicators to know if the building is optimized or not.

Detailed info are available at www.creasol.it/SelfConsumption page.

Script that, every time a power meter changes, computes the sum of 2 or more power meters and feeds that value to the DomBusEVSE virtual device

Files: script_device_evsegridpower.lua

This simple script is meant to compute the total power from the grid and feed it to the DomBusEVSE module, EV charging system that must know the total power from the grid, to prevent overloads and manage solar charging. In case of 2 or 3 meters are used (for example, a meter for the house, a meter for the electric car, and another meter for the garage, it computes the total power.

Script to control the EMMETI Mirai heat pump in a smart way

Files: heatpump.lua (script_time_heatpump_emmeti.lua) and config_heatpump_emmeti.lua

Destination directory: DOMOTICZ_DIR/scripts/lua

Called every minute

This script is designed for radiant systems:

Script for heat pump and gas heater

Files: script_time_heatpump.lua and heatpump_conf.lua

Destination directory: DOMOTICZ_DIR/scripts/lua

Called every minute

This script manages the heat pump, adjusting power and fluid temperature to meet the building demand.

If a photovoltaic system is installed, with a power meter measuring the power exchanged with the electric grid, during the summer the heat pump will try to work only when extra power from photovoltaic is produce. No power => heat pump off or at minimum level.

During the winter, the heat pump will work expecially during the day, when external temperature is high, and regulates the fluid temperature smartly to get the heat pump consuming the most energy from photovoltaic and working hard when external temperature is high, and works at minimum (or off) when the external temperature does not permit to get an high efficiency

Script for alarm system

Files: alarm.lua (script_device_alarm.lua) alarm_config.lua alarm_sendsnapshot.sh and alarmSet.sh

Destination directory: DOMOTICZ_DIR/scripts/lua

Called by script_device_master.lua and triggered when a device with name starting with PIR , MCS , SIREN, TAMPER, ALARM or Light, changes state, or when the variable alarmLevelNew is not zero (alarm started or stopped)

Scripts that manages a burglar alarm system: magnetic contact sensors on doors/windows/blinds, PIRs and radars, tampers, sirens.

Full notifications on Telegram and 3 working modes fully configurable:

Other features:

More info at https://www.creasol.it/freeBurglarAlarm

Fire detector scripts

Files: script_time_fireAlarm.lua config_fireAlarm.lua

Destination directory: DOMOTICZ_DIR/scripts/lua

LUA script that loads the rooms information from config_fireAlarm.lua and for any room if Temperature > averageTemperature + deltaT => fire alarm detected => send notification by Telegram

More information available at fire alarm page

Script that check rain and wind

File: script_time_rainCheck.lua

Destination directory: DOMOTICZ_DIR/scripts/lua

Called every minute

Script that checks the raining rate and wind speed, and performs several functions:

Script to get data from Fronius inverter

File: script_time_fronius.lua

Destination directory: DOMOTICZ_DIR/scripts/lua

Simple script that every minute fetch data, by http, from Fronius solar inverter.

Script that show earthquakes alert and send Telegram notifications

File script_time_earthquake.lua , together with globalvariables.lua and globalfunctions.lua, can be used to get earthquakes alert on Domoticz and, if magnitude is stronger than a certain threshold, also sends alert on a Telegram channel or group.

alt Show earthquakes alert on Domoticz home automation systems and telegram channel/group

Script that update a virtual P1 meter from an existing general kWh meter measuring grid power

File script_device_power2p1.lua is a LUA script for Domoticz useful for the Energy Dashboard. It can be used to update a virtual P1 meter (that you have to create by yourself from Setup -> Hardware menu), writing the current power and energy (usage and return). Also, the script can handle more generators (photovoltaic on roof, photovoltaic in the garden, wind generator, …) compute the sum of the power to a virtual device, used by the Energy Dashboard.

Just copy this script in scripts/lua folder and update the 6 variables at the top of file.

alt Example of a Domoticz Energy Dashboard


Example of a domotic system managing lights, door bell, alarm, heat pump, ventilation, irrigation, …

alt Domotic system using DomBus modules

Lua script that sends a message to Telegram channel/group/user

    -- script_time_example.lua  : simple example script that write a message to Telegram channel/group if temperature is less than 5
    commandArray={}
    dofile "script/lua/globalvariables.lua" -- read a file with some variables, including Telegram API key and ChatID
    dofile "script/lua/globalfunctions.lua" -- read a file with some functions
    if (tonumber(otherdevices['Temp_outdoor']) < 5) then  -- check that Temp_outdoor temperature sensor is >=5 Celsius, or send a notice to Telegram
    	telegramNotify("Low temperature: bring flowers inside")	-- send message by Telegram
    end
    return commandArray

Custom icons for Domoticz


Creasol DomBus modules

Our industrial and home automation modules are designed to be

Modules are available in two version:

  1. with DomBus proprietary protocol, working with Domoticz only
  2. with Modbus standard protocol, working with Home Assistant, OpenHAB, Node-RED

Store website - Information website

Youtube video showing DomBus modules

Creasol DomBus modules video

DomBusEVSE - EVSE module to build a Smart Wallbox / EV charging station

DomBusEVSE smart EVSE module to make a Smart Wallbox EV Charging station Complete solution to make a Smart EVSE, charging the electric vehicle using only energy from renewable source (photovoltaic, wind, …), or adding 25-50-75-100% of available power from the grid.


DomBusTH - Compact board to be placed on a blank cover, with temperature and humidity sensor and RGW LEDs

DomBusTH domotic board with temperature and humidity sensor, 3 LEDs, 6 I/O Compact board, 32x17mm, to be installed on blank cover with a 4mm hole in the middle, to exchange air for the relative humidity sensor. It can be installed in every room to monitor temperature and humidity, check alarm sensors, control blind motor UP/DOWN, send notifications (using red and green leds) and activate white led in case of power outage.

Includes:

DomBus12 - Compact domotic module with 9 I/Os

DomBus12 domotic module with 9 I/O Very compact, versatile and cost-effective module with 9 ports. Each port can be configured by software as:

DomBus23 - Domotic module with many functions

DomBus23 domotic module with many functions Versatile module designed to control gate or garage door.

DomBus31 - Domotic module with 8 relays

DomBus31 domotic module with 8 relay outputs DIN rail low profile module, with 8 relays and very low power consumption:

DomBus32 - Domotic module with 3 relays

DomBus32 domotic module with 3 relay outputs Versatile module with 230V inputs and outputs, and 5 low voltage I/Os.

DomBus33 - Module to domotize a light system using step relays

DomBus33 domotic module with 3 relay outputs that can control 3 lights Module designed to control 3 lights already existing and actually controlled by 230V pushbuttons and step-by-step relays. In this way each light can be activated by existing pushbuttons, and by the domotic controller.

Each relay can toggle the existing step-relay, switching the light On/Off. The optoisolator monitors the light status. The 5 I/Os can be connected to pushbuttons to activate or deactivate one or all lights.

DomBus36 - Domotic module with 12 relays

DomBus36 domotic module with 12 relay outputs DIN rail module, low profile, with 12 relays outputs and very low power consumption.

DomBus37 - 12 inputs, 3 115/230Vac inputs, 3 relay outputs

DomBus37 domotic module with 12 inputs, 3 AC inputs, 3 relay outputs Module designed to be connected to alarm sensors (magnetc contact sensors, PIRs, tampers): it’s able to monitor mains power supply (power outage / blackout) and also have 3 relays outputs.

DomRelay2 - 2x relays board

Relay board with 2 relays, to be used with DomBus domotic modules Simple module with 2 relays, to be used with DomBus modules or other electronic boards with open-collector or open-drain outputs

DomESP1 / DomESP2 - Board with relays and more for ESP8266 NodeMCU WiFi module

Relay board for ESP8266 NodeMCU module IoT board designed for NodeMCU v3 board using ESP8266 WiFi microcontroller