Page 1 of 1

graph by mail

Posted: Thursday 16 May 2019 10:04
by flyertoon
Hello,

I would like to receive this by mail. Can you help me? Thanks!!!

see attached file: temp graph

Re: graph by mail

Posted: Thursday 16 May 2019 10:23
by emme
print it as PDF or save it as image and attach it into an email ;)

Re: graph by mail

Posted: Thursday 16 May 2019 20:23
by flyertoon
Hello, thanks

My question was not clear. I would like to receive this graphic every day in my mailbox. Automatically, by script I think

Re: graph by mail

Posted: Thursday 16 May 2019 20:34
by waaren
flyertoon wrote: Thursday 16 May 2019 20:23 My question was not clear. I would like to receive this graphic every day in my mailbox. Automatically, by script I think
I don't think it's possible to get it as a graphic. Closest you can get is get the underlying data.

Re: graph by mail

Posted: Friday 17 May 2019 13:07
by flyertoon
... how can i get underlying data please ? or where are stored the log ?

thanks

Re: graph by mail

Posted: Friday 17 May 2019 14:17
by waaren
flyertoon wrote: Friday 17 May 2019 13:07 ... how can i get underlying data please ? or where are stored the log ?
A dzVents script to do this could look like the one in the code window below.

When not yet familiar with dzVents please start with reading Get started Before implementing. Special attention please for
"In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents disabled' is not checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."



Code: Select all

local scriptVar = "mailTemplog"

return  {
            on = { timer = { "every 5 minutes" },
                   httpResponses = { scriptVar .. "*" },
        },

        logging =   {   level   =   domoticz.LOG_DEBUG,    -- change to LOG_ERROR when script executes OK
                        marker  =   scriptVar},

    execute = function(dz, item)
        local temperatureSensor = 842                       -- idx or "name" of your tempSensor
        local emailAddress = '[email protected]'        -- Your Email address
        
        local function resultTable2String(t)
           str = ""
           for _, record in ipairs(t.result) do
                str = str .. record.d .. "," .. record.te .. "\\n" -- convert table to comma / LF separated
            end
            return str
        end

        local function getTempLog(idx)
            url = dz.settings['Domoticz url'] .. "/json.htm?type=graph&sensor=temp&range=day&idx=" ..  idx
            dz.openURL({    url = url,
                            method = "GET",
                            callback = scriptVar .. "_graph"}) -- collect graph data from domoticz
        end

        if item.isTimer or item.isDevice then
            getTempLog(temperatureSensor)            -- Call domoticz API
        else
            dz.email('Temperature log from device ' .. dz.devices(temperatureSensor).name, resultTable2String(item.json) , emailAddress )
        end
    end
}