first commit

This commit is contained in:
Souti
2025-03-06 11:09:58 +01:00
commit 11f7d440ff
330 changed files with 38306 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

29
lua_parsers/example.lua Normal file
View File

@@ -0,0 +1,29 @@
-- Example of parser handling data with the following format
-- TEMPERATURE,HUMIDITY,HUMIDITY_STATUS
-- A test with curl would be : curl -X POST -d "28,48,2" 'http://192.168.1.17:8080/json.htm?type=command&param=udevices&script=example.lua'
-- This function split a string according to a defined separator
-- Entries are returned into an associative array with key values 1,2,3,4,5,6...
local function split(str, sep)
if sep == nil then
sep = "%s"
end
local t={} ; i=1
local regex = string.format("([^%s]+)", sep)
for str in str:gmatch(regex) do
t[i] = str
i = i + 1
end
return t
end
-- Retrieve the request content
s = request['content'];
-- Split the content into an array of values
local values = split(s, ",");
-- Update some devices (index are here for this example)
domoticz_updateDevice(19,'',values[1])
domoticz_updateDevice(20,values[2],values[2] .. ";" .. values[3])

View File

@@ -0,0 +1,17 @@
-- Example of JSON parser handling data with the following structure
--{
-- "id": 13,
-- "name": "outside",
-- "temperature": 12.50,
-- "tags": ["France", "winter"]
--}
-- A test with curl would be : curl -X POST -d "@test.json" 'http://192.168.1.17:8080/json.htm?type=command&param=udevices&script=example_json.lua'
-- Retrieve the request content
s = request['content'];
-- Update some devices (index are here for this example)
local id = domoticz_applyJsonPath(s,'.id')
local s = domoticz_applyJsonPath(s,'.temperature')
domoticz_updateDevice(id,'',s)

View File

@@ -0,0 +1,34 @@
-- Example of XML parser handling data with the following structure
-- Data are coming from the OpenWeatherMap API : See http://www.openweathermap.org/current
-- <current>
-- <city id="12345" name="Paris">
-- <coord lon="2.35" lat="48.85"/>
-- <country>FR</country>
-- <sun rise="2016-04-22T04:45:07" set="2016-04-22T18:53:47"/>
-- </city>
-- <temperature value="14.94" min="14.94" max="14.94" unit="metric"/>
-- <humidity value="75" unit="%"/>
-- <pressure value="1020.69" unit="hPa"/>
-- <wind>
-- <speed value="1.96" name="Light breeze"/>
-- <gusts/>
-- <direction value="268.505" code="W" name="West"/>
-- </wind>
-- <clouds value="92" name="overcast clouds"/>
-- <visibility/>
-- <precipitation value="0.18" mode="rain" unit="3h"/>
-- <weather number="500" value="light rain" icon="10d"/>
-- <lastupdate value="2016-04-22T08:02:45"/>
-- </current>
-- Retrieve the request content
s = request['content'];
-- Update some devices (index are here for this example)
local temp = domoticz_applyXPath(s,'//current/temperature/@value')
local humidity = domoticz_applyXPath(s,'//current/humidity/@value')
local pressure = domoticz_applyXPath(s,'//current/pressure/@value')
domoticz_updateDevice(2988507,'',temp .. ";" .. humidity .. ";0;" .. pressure .. ";0")

View File

@@ -0,0 +1,18 @@
-- Example of XML parser handling data with the following structure
--<?xml version="1.0" encoding="UTF-8"?>
--<sensor>
-- <id>13</id>
-- <value>29.99</value>
--</sensor>
--}
-- A test with curl would be : curl -X POST -d "@test.xml" 'http://192.168.1.17:8080/json.htm?type=command&param=udevices&script=example_xml.lua'
-- Retrieve the request content
s = request['content'];
-- Update some devices (index are here for this example)
local id = domoticz_applyXPath(s,'//id/text()')
local s = domoticz_applyXPath(s,'//value/text()')
domoticz_updateDevice(id,'',s)