logo elektroda
logo elektroda
X
logo elektroda

Useful scripts for Domoticz. Dzvent''''s, LUA, Node Red, etc.

xury 27138 39
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #31 20804762
    Maciek1008
    Level 10  
    These are incremental meters of the Water type.
    IDX of the water main meter: 871
    IDX of garden water meter: 1146
    IDX of water meter to be calculated: 1164
    According to the IDX the script has to calculate: 871 - 1146 = 1164
  • ADVERTISEMENT
  • ADVERTISEMENT
  • #34 21378916
    Daro1003
    Level 34  
    Is there a chance to write a script that controls the heater based on data from the photovoltaics and current power consumption data in the house ?
  • #35 21441441
    sznickers
    Level 11  
    Hi, @xury very cool post. Thanks.
    Domoticz saves the parameters every 5 minutes. Is it possible to change it to do a save every 5 seconds for example? Why? I would like to know at night if the sump pump is switched on. If the recording is every 5 minutes, it can be missed - i.e. it won't record. The time it takes for the pump to run in one cycle is about 1-2 minutes.
  • ADVERTISEMENT
  • #36 21444762
    xury
    Automation specialist
    It is not possible to change the time of writing to the database without interfering with the source code and your own compilation.
    Instead, you can write at arbitrary intervals to the Influxdb database and then visualise this data on Grafana.
  • #38 21446908
    xury
    Automation specialist
    Helpful, I used to use it myself. If your sensor reports its values frequently to Domoticz
  • ADVERTISEMENT
  • #39 21447539
    sznickers
    Level 11  
    Maybe you could help :) , I have one small error:

    2025-02-19 22:40:00.579 Error: EventSystem: in LCD Falownik Lua all: [string "commandArray = {} ..."]:4: bad argument #1 to 'pairs' (table expected, got nil)
    2025-02-19 22:41:00.471 Error: EventSystem: in LCD Inverter Lua all: [string "commandArray = {} ..."]:4: bad argument #1 to 'pairs' (table expected, got nil)
    2025-02-19 22:42:00.522 Error: EventSystem: in LCD Inverter Lua all: [string "commandArray = {} ..."]:4: bad argument #1 to 'pairs' (table expected, got nil)
    2025-02-19 22:43:00.544 Error: EventSystem: in LCD Inverter Lua all: [string "commandArray = {} ..."]:4: bad argument #1 to 'pairs' (table expected, got nil)

    What does he mean by pairs, table?
    I've made a script to send data from the sensor to the ESP to the display. The script works, it displays what it is supposed to display on the display.

    my script:
    commandArray = {}
    
    -- loop through all the changed devices
    for deviceName,deviceValue in pairs(devicechanged) do
    
       if (deviceName=='L123FW') then
         commandArray['OpenURL']='http://192.168.0.113/control?cmd=LCD,1,1,'..tostring(deviceValue)..'_W'
       end
        if (deviceName=='L123FkWh') then
         commandArray['OpenURL']='http://192.168.0.113/control?cmd=LCD,2,1,'..tostring(deviceValue)..'_kWh'
       end
    
    end
    
    return commandArray
    .

    and this is the LUA script all instructions:
    commandArray = {}
    
    print ("All based event fired");
    -- loop through all the devices
    for deviceName,deviceValue in pairs(otherdevices) do
    --    if (deviceName=='myDevice') then
    --        if deviceValue == "On" then
    --            print("Device is On")
    --        elseif deviceValue == "Off" then
    --            commandArray['a device name'] = "On"
    --            commandArray['Scene:MyScene'] = "Off"
    --        end
    --    end
    end
    
    -- loop through all the variables
    for variableName,variableValue in pairs(uservariables) do
    --    if (variableName=='myVariable') then
    --        if variableValue == 1 then
    --            commandArray['a device name'] = "On"
    --            commandArray['Group:My Group'] = "Off AFTER 30"
    --        end
    --    end
    end
    .
ADVERTISEMENT