Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Device varible in email

I have a quick question that I am sure is in the documentation, but I wasn't able to find it quickly.  I have a HA7net Temperature device and I want to take one of the readings off of it and send it in an email.  I am using an Event with an Action using the "System::Email" Command.  I want to put the temperature reading in the message body.  I know you can put Real Time Variables in using something line "%(StdRTV:HHMM)", but how do you put something read from a device?

You can use this form:


Or, if you want to be more fault tolerant, you can use Devices::FieldRead to read it into a variable, and then reference the variable in the subsequent e-mail command, checking for a failure to read:

If Not Devices::FieldRead(mydevice.myfield, LVar:Temp, False)
   LocalVars::SetVariable(LVar:Temp, ???)
// Send e-mail here, use %(LVar:Temp) to get the value from the variable

This will do FieldRead and tell it not to fail the action if it the field can't be read, but to just return False. So we do "If Not", so if FieldRead returned a false result, i.e. couldn't read the field. In that case, we put ??? into the variable to indicate we couldn't read it.

Is this a scheduled event or a triggered one? If it's a triggered one and is being caused by a trigger you put on the temp field, then the trigger info that was received will also include the temp that caused the trigger, so you could get it from that and not have to read the field again.
Dean Roddey
Explorans limites defectum
Thanks Dean!

That did the trick. I am using a scheduled event and it seems to be working fine. I am just putting $(MyDevice.MyField) in the message body.

One other question. The temperature field comes in looking something like 68.24000. Is there any formatting parameters I can put with the $(MyDevice.MyField) to remove everything after the "."? If there is a configuration document that goes over these kind of questions, can you point me toward it?

Thanks again,
There's no specific document, just the action reference material, which is in the /Reference area of the HTML help. You just have to get familiar with what's available, or ask.

If just want to keep the decimal digits, you could do something like:

If Devices::FieldRead(mydevice.myfield, LVar:Temp, False)
    If LocalVars::Find(%(LVar:Temp), LVar:PeriodAt, ., False)
        LocalVars::CapAt(LVar:Temp, %(LVar:PeriodAt));
   LocalVars::SetVariable(LVar:Temp, ???)

// Now use LVar:Temp as the value to put into the e-mail

It tries to read the field value into LVar:Temp. If not it sets it to ???. If it does, then it does a Find on that to see if the period character is in that resulting text. If so, LVarTongueeriodAt will be set to the index at which the period is found. Then use CapAt to cap the value in LVar:Temp at the index where the period was found.

You can then use %(LVar:Temp) to put the resulting clipped value into the e-mail.
Dean Roddey
Explorans limites defectum

Possibly Related Threads…
Thread Author Replies Views Last Post
  Simple HTTP Call to Device from CQC mjwhite214 19 7,156 01-23-2020, 03:35 PM
Last Post: simplextech
  EMail from CQC using GMail jkmonroe 10 4,361 07-22-2016, 06:26 PM
Last Post: Dean Roddey
  Harmony Hub Device Control jkmonroe 6 4,889 07-03-2016, 02:36 PM
Last Post: potts.mike
  zwave device configuration jkmonroe 75 27,094 12-31-2015, 05:21 PM
Last Post: Deane Johnson
  Eventghost able to Ping device out of network EST 10 5,656 09-24-2015, 05:18 PM
Last Post: EST
  Android based device Voice control of CQC How To Discussion Thread batwater 5 4,652 12-07-2013, 10:01 PM
Last Post: RichardU
  Email question karenlee 8 7,926 11-23-2012, 12:37 PM
Last Post: karenlee
  Ethernet/USB from PC to RS232 at the device Mukha 7 3,488 05-03-2011, 04:15 PM
Last Post: SomeWhatLost
  Template / Overlay design for mobile device - Seeking experience input batwater 4 4,677 09-12-2010, 11:45 AM
Last Post: Fonceur
  Logic to send an email only once on trigger potts.mike 11 4,928 12-09-2009, 04:22 PM
Last Post: potts.mike

Forum Jump:

Users browsing this thread: 1 Guest(s)