Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


sendmail maximum chars / html


mdejager

Recommended Posts

hi,

I send a weekly diagnostics report.  but I found out that the sendmail has a maximum number of characters .. about 832.

 

1) is there any other way to send out an email

 

2) Can I send html email with fibaro? 

 

Regards

Martijn 

Link to comment
Share on other sites

4 minutes ago, mdejager said:

hi,

I send a weekly diagnostics report.  but I found out that the sendmail has a maximum number of characters .. about 832.

 

1) is there any other way to send out an email

 

2) Can I send html email with fibaro? 

 

Regards

Martijn 

 

Hi @mdejager

Unfortunately there is only one email mechanism

You could split it up into a number of messages and send one by one

You could also try one of the other notification services such as pushover or telegram but I haven't tested the limits with those services

 

Link to comment
Share on other sites

  • Topic Author
  • Thanks

     

    seems to be the only solution .. 

     

    Do you know how the table of cpu should be interpreted?

     

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    6 minutes ago, mdejager said:

    Thanks

     

    seems to be the only solution .. 

     

    Do you know how the table of cpu should be interpreted?

     

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Please login or register to see this attachment.

     

     

    @mdejager

     

    Unfortunately I don't ..:-/

    I did look at it briefly a while back but reckoned that because it changes so much the memory and storage would be more useful to me

     

    I would be interested in the you code to generate the various reports if you'd be willing to share ?

     

    -f

     

     

     

     

    Link to comment
    Share on other sites

  • Topic Author
  • No problem. Here it is.. It is now runnning in a VD but I am thinking about moving it to a scene

    I still have to clean up a little. 

     

    it takes the labels from from memory VD. you need that code too?

     

    ---    UPDATE MEMORY VARIABLES
        fibaro:call(fibaro:getSelfId(), "pressButton", "8")

    ---    MAKE CONNECTION
        connection = Net.FHttp("127.0.0.1", 11111);


    ---    FUNCTION REQUEST DEVICES
        getData = function()

          ---    MAKE CONNECTION
            response ,status, errorCode = connection:GET( "/api/devices/" );

          ---    STATUS NOTIFICATIONS
            fibaro:debug("status = " .. status);
            fibaro:debug("errorCode = " .. errorCode);
      
          ---    IF SUCCES
            if (tonumber(status) == 200) then
        
            --- DECODE TO LUA TABLE
                deviceTable = json.decode(response);
     
            end
        return deviceTable;
    end

    ---    FUNCTION REQUEST CONSUMPTION
        getConsumption = function(url)
      
        --- MAKE CONNECTION
              response ,status, errorCode = connection:GET( url );
      
         --- IF SUCCES
            if (tonumber(status) == 200) then
                 consumptionTable = json.decode(response);
            end
        return consumptionTable;
    end

    ---    CONSTRUCT SUBSTRACTION DAYS START DATE OF LAST WEEK
        if(os.date("%a") == "Mon") then      substract = 7  
        elseif(os.date("%a") == "Tue") then substract = 8
        elseif(os.date("%a") == "Wed") then substract = 9
        elseif(os.date("%a") == "Thu") then substract = 10
        elseif(os.date("%a") == "Fri") then substract = 11
        elseif(os.date("%a") == "Sat") then substract = 12
        elseif(os.date("%a") == "Sun") then substract = 13 end


    --- SET VARIABLES
        UserId             = 2;
        lowBat             = 85;
        SelfId             = fibaro:getSelfId()
        dev                = getData();
        lowBattDevices    = "";
        deadDevices        = "";
        totalConsumption= 0 ;
        heavyConsumption= "";
        now                = os.date("*t")
        week_start        = os.time({year=now.year,month=now.month,day=now.day-substract,hour=0,min=0,sec=0}) --,
        week_end        = week_start + 604799 -- plus a week


    ---    LOOP THROUGH DEVICES
        for i = 1, #dev do
      
        --- SET VARS
              batLevel    = tonumber(dev.properties.batteryLevel);
             deadValue    = dev.properties.dead;
            deviceName    = tostring(dev.name);
            prestr         = "[" .. dev.id .. "] ➜ " .. deviceName;
        
        --- DEAD DEVICES
            if(dev.visible == true and deadValue == "true") then
        
            --- TRY TO WAKE
                fibaro:wakeUpDeadDevice(dev.id)         
                fibaro:sleep(2*1000); 
            
            ---    CHECK IF STILL DEAD
                if(fibaro:getValue(dev.id, 'dead') ~= "1") then
                       deadDevices = deadDevices .. prestr .. " ✔ Woke up \n";
                else
                    deadDevices = deadDevices .. prestr .. "❌ Did not wake up \n";
                  end
        
            end 

        --- LOW BATT / IF FIELD EXISTS
              if (dev.visible == true and (dev.properties.batteryLevel ~= nil)) then
        
            --- ONLY LOW BAT OF ALLREADYDEAD
                  if(deadValue == "true" or batLevel <= lowBat or (deadValue ~= "true" and batLevel == 255)) then
                    -- lowBattDevices = lowBattDevices .. prestr .. " - " .. string.format('<%s style="color:%s;">%s</%s>', "span", "red", dev.properties.batteryLevel .. " %", "span") .. "<br>\n"
                      lowBattDevices = lowBattDevices .. prestr .. " - " ..  dev.properties.batteryLevel .. "% ❌ \n"
                 else
                      lowBattDevices = lowBattDevices .. prestr .. " - " .. dev.properties.batteryLevel .. "% ✔ \n"
          
                end
            end
      
        --- CONSUMPTION
              if (dev.visible == true) then
        
            --- SET VARS
                url         = "/api/energy/" .. week_start .."/" .. week_end .. "/compare/devices/power/" .. dev.id  
                Consumption = getConsumption(url);
         
             ---    ONLY IF THERE IS A KWH FIELD
                  if(Consumption[1].kWh ~= nil)  then
          
                 --- SET VARS
                      kwh = tonumber(Consumption[1].kWh)
                  --- HEAVY USERS LOOP
                      if kwh > 1 then
                            heavyConsumption = heavyConsumption .. prestr .. " - " .. Consumption[1].kWh  .. " kWh \r";
                      end
                  ---    TOTAL CONSUMPTION SUM
                      totalConsumption = tonumber(totalConsumption) + kwh

                end 
              end
      end


    --- CONSTRUCT MAIL HOME REPORT
        emailContent = "Weekly Home Report \n";
        emailContent = emailContent .. "Date: " ..  os.date("%d %b %Y - %H:%M") .. "\n \n";
        emailContent = emailContent .. "➡ Low Battery ⬅\r";
        emailContent = emailContent .. lowBattDevices .. "\r \r";
        emailContent = emailContent .. "➡ Dead Nodes ⬅\n";
        emailContent = emailContent .. deadDevices .. "\n \n";

    ---    SEND MAIL
        fibaro:call(UserId,"sendEmail", "Weekly Home Report " .. os.date("%d %b %Y - %H:%M"),emailContent);

    --- CONSTRUCT MAIL CONSUMPTION REPORT
        emailContentConsumption = "Weekly Consumption Report \n";
        emailContentConsumption = emailContentConsumption .. "Date: " ..  os.date("%d %b %Y - %H:%M") .. "\n \n";
        emailContentConsumption = emailContentConsumption .. "➡ Consumption ⬅\n";
        emailContentConsumption = emailContentConsumption .. "From: " ..  os.date("%d %b %Y",week_start) .. " till " .. os.date("%d %b %Y",week_end) .. "\n \n";
        emailContentConsumption = emailContentConsumption .. "Heavy consumption \n";
        emailContentConsumption = emailContentConsumption .. heavyConsumption .. "\n\n";
        emailContentConsumption = emailContentConsumption .. "Consumption total\n";
        emailContentConsumption = emailContentConsumption .. totalConsumption .. " kWh \n\n";

    ---    SEND MAIL
        fibaro:call(UserId,"sendEmail", "Weekly Consumption Report " .. os.date("%d %b %Y - %H:%M"),emailContentConsumption);

    --- CONSTRUCT MAIL CONSUMPTION REPORT
        emailContentMemory = "Weekly Memory Report \n";
        emailContentMemory = emailContentMemory .. "Date: " ..  os.date("%d %b %Y - %H:%M") .. "\n \n";
        emailContentMemory = emailContentMemory .. "➡ Memory ⬅\n\n";
        emailContentMemory = emailContentMemory .. "➜ Free memory: " ..fibaro:getValue(SelfId, "ui.labFreeRam.value") .. "\n";
        emailContentMemory = emailContentMemory .. "➜ Maximum free: " ..fibaro:getValue(SelfId, "ui.labMax.value") .. "\n";
        emailContentMemory = emailContentMemory .. "➜ Minimum free: " ..fibaro:getValue(SelfId, "ui.labMini.value") .. "\n";
        emailContentMemory = emailContentMemory .. "➜ Memory Cache: " ..fibaro:getValue(SelfId, "ui.labCache.value") .. "\n";
        emailContentMemory = emailContentMemory .. "➜ Memory Buffers: " ..fibaro:getValue(SelfId, "ui.labBuffers.value") .. "\n";
        emailContentMemory = emailContentMemory .. "➜ Memory Used: " ..fibaro:getValue(SelfId, "ui.labUsed.value") .. "\n";
        emailContentMemory = emailContentMemory .. "➜ Storage: " ..fibaro:getValue(SelfId, "ui.labStorage.value") .. "\n";

    ---    SEND MAIL
        fibaro:call(UserId,"sendEmail", "Weekly Memory Report " .. os.date("%d %b %Y - %H:%M"),emailContentMemory);


     

    Link to comment
    Share on other sites

    Guest
    This topic is now closed to further replies.
    ×
    ×
    • Create New...