Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Notifications
Login / Register
Community
Community
Notifications
close
  • Forums
  • Knowledge Center
  • Events & Webinars
  • Ideas
  • Blogs
Help
Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Login / Register
Sustainability
Sustainability

We Value Your Feedback!
Could you please spare a few minutes to share your thoughts on Cloud Connected vs On-Premise Services. Your feedback can help us shape the future of services.
Learn more about the survey or Click here to Launch the survey
Schneider Electric Services Innovation Team!

HomeLynk: sending object log via email

SpaceLogic KNX Forum

Schneider Electric SpaceLogic KNX forum to get support and share knowledge including selection, installation and troubleshooting for spaceLYnk, Wiser for KNX, eConfigure KNX, SpaceLogic KNX Hybrid module and other topics.

cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Home
  • Schneider Electric Community
  • EcoStruxure Building
  • Light and Room Control
  • SpaceLogic KNX Forum
  • HomeLynk: sending object log via email
Options
  • Mark Topic as New
  • Mark Topic as Read
  • Float this Topic for Current User
  • Bookmark
  • Subscribe
  • Mute
  • Printer Friendly Page
Invite a Co-worker
Send a co-worker an invite to the portal.Just enter their email address and we'll connect them to register. After joining, they will belong to the same company.
You have entered an invalid email address. Please re-enter the email address.
This co-worker has already been invited to the Exchange portal. Please invite another co-worker.
Please enter email address
Send Invite Cancel
Invitation Sent
Your invitation was sent.Thanks for sharing Exchange with your co-worker.
Send New Invite Close
Top Experts
User Count
Thomas_Rohde
Sisko Thomas_Rohde Sisko
123
Erwin-vd-Zwart
Sisko Erwin-vd-Zwart Sisko
54
Heribert_Dölger
Lt. Commander Heribert_Dölger Lt. Commander
30
FZetina
Lt. Commander FZetina Lt. Commander
27
View All
Related Products
product field
SpaceLogic KNX - 4ʺ Touch Unit
product field
KNX Push Button Dynamic Labeling, universal
product field
Wiser for KNX : logic controller

Invite a Colleague

Found this content useful? Share it with a Colleague!

Invite a Colleague Invite
Solved Go to Solution
Back to SpaceLogic KNX Forum
Solved
Koen_Rowies
Lt. Commander Koen_Rowies Lt. Commander
Lt. Commander

Posted: ‎2015-01-28 06:11 AM . Last Modified: ‎2024-07-15 12:03 AM

1 Like
4
642
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2015-01-28 06:11 AM

HomeLynk: sending object log via email

Hello,

We have a customer who ask if it's possible to get the object log from HL via email once a day.

I have been testing with a script that sends every hour a .csv of the last hour events to an ftp and that works fine. But now i would like to let it send the .csv by mail using a gmail account. Is there someone who did this already or could help me with modifying this script?

Regards,

Koen

script:

----------------------------------------------------------------------------------------------------------------------------------

require('socket.ftp')

-- ftp file

ftpfile = string.format('ftp://ftp:ftp123@192.168.0.10/%s.csv', os.date('%Y-%m-%d_%H-%M'))

-- get past hour data (3600 seconds)

logtime = os.time() - 60 * 60

-- list of objects by id

objects = {}

-- objects with logging enabled

query = 'SELECT address, datatype, name FROM objects WHERE disablelog=0'

for _, object in ipairs(db:getall(query)) do

  objects[ tonumber(object.address) ] = {

    datatype = tonumber(object.datatype),

    name = tostring(object.name or ''),

  }

end

-- csv buffer

buffer = { '"date","address","name","value"' }

-- get object logs

query = 'SELECT src, address, datahex, logtime, eventtype FROM objectlog WHERE logtime >= ? ORDER BY id DESC'

for _, row in ipairs(db:getall(query, logtime)) do

  object = objects[ tonumber(row.address) ]

  -- found matching object and event type is group write

  if object and row.eventtype == 'write' then

    datatype = object.datatype

    -- check that object datatype is set

    if datatype then

      -- decode data

      data = knxdatatype.decode(row.datahex, datatype)

      -- remove null chars from char/string datatype

      if datatype == dt.char or datatype == dt.string then

        data = data:gsub('%z+', '')

      -- date to DD.MM.YYYY

      elseif datatype == dt.date then

        data = string.format('%.2d.%.2d.%.2d', data.day, data.month, data.year)

      -- time to HH:MM:SS

      elseif datatype == dt.time then

        data = string.format('%.2d:%.2d:%.2d', data.hour, data.minute, data.second)

      end

    else

      data = ''

    end

    -- format csv row

    logdate = os.date('%Y.%m.%d %H:%M:%S', row.logtime)

    csv = string.format('%q,%q,%q,%q', logdate, knxlib.decodega(row.address), object.name, tostring(data))

    -- add to buffer

    table.insert(buffer, csv)

  end

end

-- upload to ftp only when there's data in buffer

if #buffer > 1 then

  result, err = socket.ftp.put(ftpfile, table.concat(buffer, '\r\n'))

end

-- error while uploading

if err then

  alert('FTP upload error: %s', tostring(err))

end

----------------------------------------------------------------------------------------------------------------------------------

  • Thumbnail of SpaceLogic KNX - 4ʺ Touch Unit
    SpaceLogic KNX - 4ʺ Touch Unit
  • Thumbnail of KNX Push Button Dynamic Labeling, universal
    KNX Push Button Dynamic Labeling, universal
  • Thumbnail of Wiser for KNX : logic controller
    Wiser for KNX : logic controller
View products (3)
Reply
  • All forum topics
  • Previous Topic
  • Next Topic

Accepted Solutions
sesa299442
sesa299442 Schneider Alumni (Retired)
Schneider Alumni (Retired)

Posted: ‎2015-01-28 07:21 AM

0 Likes
1
578
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2015-01-28 07:21 AM

Hello,

you can use this example function enclosed. I composed it together of some other examples 🙂

You just need to set the parameters in User editable area of the function.

Then you can call the function with two parameters:

- to: destination address

- log_hrs: number of hours you want to display in the csv (backwards from now)

The problem is that there is some problem with LuaSocket library in homeLYnk version 1.2.1.

Please run this script once in order to install library update:

os.execute('opkg --force-depends install http://dl.openrb.com/pkg/luasocket_2.0.2-7_mxs.ipk'))

If you cannot access internet from your homeLYnk, set proxy IP in the command (bold):

os.execute('export http_proxy=http://1.1.1.1:8080/ opkg --force-depends install http://dl.openrb.com/pkg/luasocket_2.0.2-7_mxs.ipk'))

Regards

Tomas

See Answer In Context

Attachments
ObjectLog_CSV_email.txt.zip
Reply
Replies 4
lfiat
Ensign lfiat
Ensign

Posted: ‎2015-01-28 06:55 AM

0 Likes
3
578
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2015-01-28 06:55 AM

Hello Koen,

I propose to use Application for homeLYnk about how to send a email with homeLynk

AN_Email, SMS and FTP in homeLYnk

I suggest you not to send a csv file but the text of your current csv file as the mail content: I don't believe at moment with homeLYnk mail LUA library it is possible to send a file attached in a mail.

Regards,

Lionel

Reply
vaca
Ensign vaca
Ensign

Posted: ‎2015-01-28 07:06 AM

0 Likes
2
578
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2015-01-28 07:06 AM

Hi Lionel and Koen,

it is possible to send a file directly without a need of storing it somewhere and actually it is not so complicated.

Just contact this guy , he was solving this issue with me a week or two ago. For sure I will inform him about your question here.

Reply
sesa299442
sesa299442 Schneider Alumni (Retired)
Schneider Alumni (Retired)

Posted: ‎2015-01-28 07:21 AM

0 Likes
1
579
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2015-01-28 07:21 AM

Hello,

you can use this example function enclosed. I composed it together of some other examples 🙂

You just need to set the parameters in User editable area of the function.

Then you can call the function with two parameters:

- to: destination address

- log_hrs: number of hours you want to display in the csv (backwards from now)

The problem is that there is some problem with LuaSocket library in homeLYnk version 1.2.1.

Please run this script once in order to install library update:

os.execute('opkg --force-depends install http://dl.openrb.com/pkg/luasocket_2.0.2-7_mxs.ipk'))

If you cannot access internet from your homeLYnk, set proxy IP in the command (bold):

os.execute('export http_proxy=http://1.1.1.1:8080/ opkg --force-depends install http://dl.openrb.com/pkg/luasocket_2.0.2-7_mxs.ipk'))

Regards

Tomas

Attachments
ObjectLog_CSV_email.txt.zip
Reply
Koen_Rowies
Lt. Commander Koen_Rowies Lt. Commander
Lt. Commander

Posted: ‎2015-02-02 05:24 AM

0 Likes
0
578
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2015-02-02 05:24 AM

Hello Tomas,

Works perfect from the first test!

Thanks!

5653

Reply
To The Top!

Forums

  • APC UPS Data Center Backup Solutions
  • EcoStruxure IT
  • EcoStruxure Geo SCADA Expert
  • Metering & Power Quality
  • Schneider Electric Wiser

Knowledge Center

Events & webinars

Ideas

Blogs

Get Started

  • Ask the Community
  • Community Guidelines
  • Community User Guide
  • How-To & Best Practice
  • Experts Leaderboard
  • Contact Support
Brand-Logo
Subscribing is a smart move!
You can subscribe to this board after you log in or create your free account.
Forum-Icon

Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.

Register today for FREE

Register Now

Already have an account? Login

Terms & Conditions Privacy Notice Change your Cookie Settings © 2025 Schneider Electric

This is a heading

With achievable small steps, users progress and continually feel satisfaction in task accomplishment.

Usetiful Onboarding Checklist remembers the progress of every user, allowing them to take bite-sized journeys and continue where they left.

of