This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Send data from LM over IP
#1
I'm using the next script p1-smart-metering for reading out my smart meter over P1 port. This is working fine.

I also want use this data on another server and want sent it over IP.

part of the script to show what i mean. *rule 9 and 16
Code:
if data then
  --log(data)
 
  -- Totaal verbruik tarief 1: nacht- of weekendtarief uitlezen kWh
  tarief_1 = data:match'1.8.1%((%d+.%d+)'
  tarief_1 = tonumber(tarief_1)
--log("Tarief 1 nacht- of weekendtarief: " .. tarief_1 .. " kWh")
  grp.checkupdate('13/0/28', tarief_1)
sent this data over IP on port 19928 (if the value chanced)
       
  -- Totaal verbruik tarief 2: dagtarief uitlezen kWh
  tarief_2 = data:match'1.8.2%((%d+.%d+)'
  tarief_2 = tonumber(tarief_2)
  --log("Tarief 2 dagtarief: " .. tarief_2 .. " kWh")
  grp.checkupdate('13/0/29', tarief_2)
sent this data over IP on port 19929 (if the value chanced)
       

This is the first time i use a IP command.
I hope someone can help me with how to do this.
Reply
#2
Is it TCP or UDP? Is there some specific protocol or the value should be sent as a string without any conversion?
Reply
#3
What i want is sent these data to another server with 'Domoticz' aka 'Home Assistent'.
and read this value with these servers.

there is no conversion needed.
UDP is enough
Reply
#4
Use this:
Code:
data = tostring(tarief_1)
sock = require('socket').udp()
sock:sendto(data, '192.168.1.204', 19928)
sock:close()
Reply
#5
Yes thanks, it is working
Reply


Forum Jump: