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

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?

Thanks,
Dan
Reply
#2
You can use this form:

$(MyDevice.MyField)

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:

Code:
If Not Devices::FieldRead(mydevice.myfield, LVar:Temp, False)
   LocalVars::SetVariable(LVar:Temp, ???)
EndIf
// 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
Software Geek Extraordinaire
Reply
#3
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,
Dan
Reply
#4
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:

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

// 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
Software Geek Extraordinaire
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  EMail from CQC using GMail jkmonroe 10 1,879 07-22-2016, 06:26 PM
Last Post: Dean Roddey
  Harmony Hub Device Control jkmonroe 6 2,297 07-03-2016, 02:36 PM
Last Post: potts.mike
  zwave device configuration jkmonroe 75 10,900 12-31-2015, 05:21 PM
Last Post: Deane Johnson
  Eventghost able to Ping device out of network EST 10 2,877 09-24-2015, 05:18 PM
Last Post: EST
  Simple HTTP Call to Device from CQC mjwhite214 7 2,036 07-05-2014, 08:16 PM
Last Post: mjwhite214
  Android based device Voice control of CQC How To Discussion Thread batwater 5 2,790 12-07-2013, 10:01 PM
Last Post: RichardU
  Email question karenlee 8 2,145 11-23-2012, 12:37 PM
Last Post: karenlee
  Ethernet/USB from PC to RS232 at the device Mukha 7 1,797 05-03-2011, 04:15 PM
Last Post: SomeWhatLost
  Template / Overlay design for mobile device - Seeking experience input batwater 4 3,244 09-12-2010, 11:45 AM
Last Post: Fonceur
  Logic to send an email only once on trigger potts.mike 11 2,527 12-09-2009, 04:22 PM
Last Post: potts.mike

Forum Jump:


Users browsing this thread: 1 Guest(s)