LogicMachine Forum
script P1 poort voor homelynk - Printable Version

+- LogicMachine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: OLD visualization (https://forum.logicmachine.net/forumdisplay.php?fid=9)
+--- Thread: script P1 poort voor homelynk (/showthread.php?tid=5859)



script P1 poort voor homelynk - cheist - 26.01.2025

Hallo

Heeft iemand script om de P1 poort van slimme meter uit te lezen door een homelynk?

alvast bedankt.


RE: script P1 poort voor homelynk - CristianAgata - 26.01.2025

(26.01.2025, 10:42)cheist Wrote: Hallo

Heeft iemand script om de P1 poort van slimme meter uit te lezen door een homelynk?

alvast bedankt.

Hi,
which brand of Smart Meter?
BR Cristian


RE: script P1 poort voor homelynk - Erwin van der Zwart - 26.01.2025

Hi,

Please use EN next time so everyone understands the question..

Code:
--P1 poort van slimme meter uitlezen lastchar = '!' require('serial') port = serial.open('/dev/ttyUSB0', { -- Let op type van de slimme meter voor de onderstaande instellingen.   baudrate = 9600,         --DSMR 2/3 = 9600        DSMR 4 = 115200   databits = 7,                --DSMR 2/3 = 7            DSMR 4 = 8   stopbits = 1,                --DSMR 2/3 = 1            DSMR 4 = 1   parity = 'even',        --DSMR 2/3 = even        DSMR 4 = none   duplex = 'full' }) function readdata(port)   local char, buf   buf = {}   while true do     char = port:read(1)     -- error (timeout) or newline, stop     if char == nil or char == lastchar then       --table.insert(buf, char)       break     -- ignore cr char     elseif char ~= '\r' then       table.insert(buf, char)     end   end   return table.concat(buf) end data = readdata(port) port:flush() --log(data) --------------------------------------------------------------- if data then    -- Totaal verbruik tarief 1 uitlezen kWh   tarief_1 = data:match([[1-0:1.8.1%((%d+.%d+)]])   if nil ~= tarief_1 then     tarief_1 = tonumber(tarief_1)     --log("Tarief 1: " .. tarief_1 .. " kWh")     grp.checkupdate('32/0/1', tarief_1)   end   -- Totaal verbruik tarief 2 uitlezen kWh   tarief_2 = data:match([[1-0:1.8.2%((%d+.%d+)]])   if nil ~= tarief_2 then     tarief_2 = tonumber(tarief_2)     --log("Tarief 2: " .. tarief_2 .. " kWh")     grp.checkupdate('32/0/2', tarief_2)   end   -- Totaal verbruik tarief 1 + 2   if nil ~= tarief_1 or nil ~= tarief_2 then     tarief_totaal = tarief_1 + tarief_2     --log("Totaal verbruik: " .. tarief_totaal .. " kWh")     grp.checkupdate('32/0/0', tarief_totaal)     grp.checkupdate('32/0/9', tarief_totaal * 1000)   end   -- Totale retourlevering tarief 1 uitlezen kWh   retour_1 = data:match([[1-0:2.8.1%((%d+.%d+)]])   if nil ~= retour_1 then     retour_1 = tonumber(retour_1)     --log("Retour 1: " .. retour_1 .. " kWh")     grp.checkupdate('32/0/4', retour_1)   end   -- Totale retourlevering tarief 2 uitlezen kWh   retour_2 = data:match([[1-0:2.8.2%((%d+.%d+)]])   if nil ~= retour_2 then     retour_2 = tonumber(retour_2)     --log("Retour 2: " .. retour_2 .. " kWh")     grp.checkupdate('32/0/5', retour_2)   end   -- Totale retourlevering tarief 1 + 2   if nil ~= retour_1 or nil ~= retour_2 then     retour_totaal = retour_1 + retour_2     --log("Totaal retour: " .. retour_totaal .. " kWh")     grp.checkupdate('32/0/3', retour_totaal)     grp.checkupdate('32/0/10', retour_totaal * 1000)   end   -- Actuele tariefstand uitlezen T1/T2   actueel_tarief = data:match([[0-0:96.14.0%(%d%d%d(%d)]])   if nil ~= actueel_tarief then     --log("Actueel tarief: T" .. actueel_tarief)     grp.checkupdate('32/0/6', tonumber(actueel_tarief))   end   -- Actueel verbruik uitlezen kW   actueel_verbruik = data:match([[1-0:1.7.0%((%d+.%d+)]])   if nil ~= actueel_verbruik then     actueel_verbruik = tonumber(actueel_verbruik)     --log("Actueel verbruik: " .. actueel_verbruik .. " kW")     grp.checkupdate('32/0/7', actueel_verbruik)     grp.checkupdate('32/0/11', actueel_verbruik * 1000)   end   -- Actuele retourlevering uitlezen kW   actueel_retour = data:match([[1-0:2.7.0%((%d+.%d+)]])   if nil ~= actueel_retour then     actueel_retour = tonumber(actueel_retour)     --log("Actueel retour: " .. actueel_retour .. " kW")     grp.checkupdate('32/0/8', actueel_retour)     grp.checkupdate('32/0/12', actueel_retour * 1000)   end   end



RE: script P1 poort voor homelynk - cheist - 02.02.2025

Ok thank you. it works


RE: script P1 poort voor homelynk - Keitz - 02.03.2025

(26.01.2025, 21:27)Erwin van der Zwart Wrote: Hi,

Please use EN next time so everyone understands the question..

Code:
--P1 poort van slimme meter uitlezen lastchar = '!' require('serial') port = serial.open('/dev/ttyUSB0', { -- Let op type van de slimme meter voor de onderstaande instellingen.   baudrate = 9600,         --DSMR 2/3 = 9600        DSMR 4 = 115200   databits = 7,                --DSMR 2/3 = 7            DSMR 4 = 8   stopbits = 1,                --DSMR 2/3 = 1            DSMR 4 = 1   parity = 'even',        --DSMR 2/3 = even        DSMR 4 = none   duplex = 'full' }) function readdata(port)   local char, buf   buf = {}   while true do     char = port:read(1)     -- error (timeout) or newline, stop     if char == nil or char == lastchar then       --table.insert(buf, char)       break     -- ignore cr char     elseif char ~= '\r' then       table.insert(buf, char)     end   end   return table.concat(buf) end data = readdata(port) port:flush() --log(data) --------------------------------------------------------------- if data then    -- Totaal verbruik tarief 1 uitlezen kWh   tarief_1 = data:match([[1-0:1.8.1%((%d+.%d+)]])   if nil ~= tarief_1 then     tarief_1 = tonumber(tarief_1)     --log("Tarief 1: " .. tarief_1 .. " kWh")     grp.checkupdate('32/0/1', tarief_1)   end   -- Totaal verbruik tarief 2 uitlezen kWh   tarief_2 = data:match([[1-0:1.8.2%((%d+.%d+)]])   if nil ~= tarief_2 then     tarief_2 = tonumber(tarief_2)     --log("Tarief 2: " .. tarief_2 .. " kWh")     grp.checkupdate('32/0/2', tarief_2)   end   -- Totaal verbruik tarief 1 + 2   if nil ~= tarief_1 or nil ~= tarief_2 then     tarief_totaal = tarief_1 + tarief_2     --log("Totaal verbruik: " .. tarief_totaal .. " kWh")     grp.checkupdate('32/0/0', tarief_totaal)     grp.checkupdate('32/0/9', tarief_totaal * 1000)   end   -- Totale retourlevering tarief 1 uitlezen kWh   retour_1 = data:match([[1-0:2.8.1%((%d+.%d+)]])   if nil ~= retour_1 then     retour_1 = tonumber(retour_1)     --log("Retour 1: " .. retour_1 .. " kWh")     grp.checkupdate('32/0/4', retour_1)   end   -- Totale retourlevering tarief 2 uitlezen kWh   retour_2 = data:match([[1-0:2.8.2%((%d+.%d+)]])   if nil ~= retour_2 then     retour_2 = tonumber(retour_2)     --log("Retour 2: " .. retour_2 .. " kWh")     grp.checkupdate('32/0/5', retour_2)   end   -- Totale retourlevering tarief 1 + 2   if nil ~= retour_1 or nil ~= retour_2 then     retour_totaal = retour_1 + retour_2     --log("Totaal retour: " .. retour_totaal .. " kWh")     grp.checkupdate('32/0/3', retour_totaal)     grp.checkupdate('32/0/10', retour_totaal * 1000)   end   -- Actuele tariefstand uitlezen T1/T2   actueel_tarief = data:match([[0-0:96.14.0%(%d%d%d(%d)]])   if nil ~= actueel_tarief then     --log("Actueel tarief: T" .. actueel_tarief)     grp.checkupdate('32/0/6', tonumber(actueel_tarief))   end   -- Actueel verbruik uitlezen kW   actueel_verbruik = data:match([[1-0:1.7.0%((%d+.%d+)]])   if nil ~= actueel_verbruik then     actueel_verbruik = tonumber(actueel_verbruik)     --log("Actueel verbruik: " .. actueel_verbruik .. " kW")     grp.checkupdate('32/0/7', actueel_verbruik)     grp.checkupdate('32/0/11', actueel_verbruik * 1000)   end   -- Actuele retourlevering uitlezen kW   actueel_retour = data:match([[1-0:2.7.0%((%d+.%d+)]])   if nil ~= actueel_retour then     actueel_retour = tonumber(actueel_retour)     --log("Actueel retour: " .. actueel_retour .. " kW")     grp.checkupdate('32/0/8', actueel_retour)     grp.checkupdate('32/0/12', actueel_retour * 1000)   end   end

Thank you for the code.
How to read code 1.6.0 ? Thats the max peak per month. 
1-0:1.6.0(230514091500S)(01.672*kW)


RE: script P1 poort voor homelynk - admin - 03.03.2025

Try this:
Code:
value = data:match([[1-0:1.6.0%(%d+%a%)%((%d+.%d+)%*kW%)]])