I am trying to sent out some information directy out of the veralite.
I can sent an email triggerd by a scedule (once a week)
but how can i sent out the value “gas” “kwh1” and ‘’'kwh2"
and they must be after ‘‘Meterstanden van " … os.date(“%c”)’’
this is what i have already working
your help is highy apprictated
==quote==
local smtp = require(“socket.smtp”)
local METER_DEV_ID = 139
local METER1_DEV_ID = 140
local METER2_DEV_ID = 141
local gas= luup.variable_get("urn:brutgrink-com:serviceId:dutchSmartMeter", "gas", METER_DEV_ID )
local kwh1= luup.variable_get("urn:micasaverde-com:serviceId:EnergyMetering1", "kwh", METER1_DEV_ID )
local kwh2= luup.variable_get(" urn:micasaverde-com:serviceId:EnergyMetering1 ", "kwh", METER2_DEV_ID )
local SMTP_SERVER = "xxx.xxx.com"
local SMTP_PORT = "25"
local USER_SENDING = "<xxxx@xxx.xx>"
local USER_RECEIVING = "<xxx@xxx.xx>"
local from = USER_SENDING
local rcpt = {USER_RECEIVING}
local mesgt = {
headers = {
to = USER_RECEIVING,
subject = "Meterstanden"
},
body = "Meterstanden van " .. os.date("%c")
}
local r, e = smtp.send{
from = from,
rcpt = rcpt,
source = smtp.message(mesgt),
server = SMTP_SERVER,
port = SMTP_PORT,
}
if (e) then
luup.log("Yikes " .. e)
end
Add default values for all the variables you get with luup.variable_get. Some may be nil, in which case you’ll get an error.
local gas= luup.variable_get("urn:brutgrink-com:serviceId:dutchSmartMeter", "gas", METER_DEV_ID ) or "0"
local kwh1= luup.variable_get("urn:micasaverde-com:serviceId:EnergyMetering1", "kwh", METER1_DEV_ID ) or "0"
local kwh2= luup.variable_get(" urn:micasaverde-com:serviceId:EnergyMetering1 ", "kwh", METER2_DEV_ID ) or "0"
Double check your capitalization, of both the service Id and the variable name. Case matters. I particularly suspect “kwh” should be “KWH”, but don’t take my word for it. Go look at the Advanced tab of the device and see what capitalization is needed.
Edit: Link to thread showing that capitalization was the issue.
[quote=“huib, post:8, topic:171899”]Problem solved
thanks for the help[/quote]
@ Huib
Could you tell us how you did this? I’d like to have a daily mail with the values of the meters (in and export tariff 1 and 2) better would even be the values between the day do this day - previous day equals usage current day.
any idea?
[quote=“JohnVS, post:9, topic:171899”]@ Huib
Could you tell us how you did this? I’d like to have a daily mail with the values of the meters (in and export tariff 1 and 2) better would even be the values between the day do this day - previous day equals usage current day.
any idea?[/quote]