Author Topic: New user question on templates  (Read 940 times)

Offline jonathan-london

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
New user question on templates
« on: August 16, 2014, 01:57:19 pm »
Hi,

I want to embed the current (or last recorded) light level in alerts sent via SMTP and Syslog.  I've not had much luck.  I'm testing by sending test messages to syslog from the VeraAlerts device.  Simple messages work but when I try to use the device name, or drill down on detail, I'm getting nowhere :(

This is what I have tried:
Code: [Select]
test {Device([17].room.name)} => Aug 16 18:45:56 ha VeraAlert: test Outside
test {Device([17].description)} => Aug 16 18:46:19 ha VeraAlert: test Outside Detector
test {Device([19].description)} => Aug 16 18:46:31 ha VeraAlert: test Outside Light Level
test {Device([Outside Detector].description)} => [nothing syslogged]
test {Device([17].LightSensor.CurrentLevel)} => Aug 16 18:46:59 ha VeraAlert: test {Device([17].LightSensor.CurrentLevel)}
test {Device([17].description)} => Aug 16 18:47:14 ha VeraAlert: test Outside Detector

Here's the log

Code: [Select]
50 08/16/14 18:46:31.716 luup_log:25: VeraAlert:25:SendAlert:Sending to:Syslog <0x2b043000>
50 08/16/14 18:46:31.717 luup_log:25: VeraAlert:25:SyslogSend:To:192.168.1.61:514 Msg:<14>Aug 16 18:46:31 ha VeraAlert: test Outside Light Level
<0x2b043000>
06 08/16/14 18:46:31.718 Device_Variable::m_szValue_set device: 25 service: urn:richardgreen:serviceId:VeraAlert1 variable: LastMsgSent was: 18:46:19 Sat Aug 16 now: 18:46:31 Sat Aug 16 #hooks: 0 upnp: 0 v:0xcb4f78/NONE duplicate:0 <0x2b043000>
50 08/16/14 18:46:31.734 luup_log:25: VeraAlert:25:SendAlert:Memory:288852 <0x2b043000>
04 08/16/14 18:46:31.735 <0x2b043000>
08 08/16/14 18:46:47.465 JobHandler_LuaUPnP::HandleActionRequest device: 25 service: urn:richardgreen:serviceId:VeraAlert1 action: SendAlert <0x2d777680>
08 08/16/14 18:46:47.466 JobHandler_LuaUPnP::HandleActionRequest argument DeviceNum=25 <0x2d777680>
08 08/16/14 18:46:47.466 JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:richardgreen:serviceId:VeraAlert1 <0x2d777680>
08 08/16/14 18:46:47.466 JobHandler_LuaUPnP::HandleActionRequest argument action=SendAlert <0x2d777680>
08 08/16/14 18:46:47.466 JobHandler_LuaUPnP::HandleActionRequest argument Message=test {Device([Outside Detector].description)} <0x2d777680>
08 08/16/14 18:46:47.466 JobHandler_LuaUPnP::HandleActionRequest argument Recipients=Syslog <0x2d777680>
08 08/16/14 18:46:47.467 JobHandler_LuaUPnP::HandleActionRequest argument rand=0.09976965418271655 <0x2d777680>
50 08/16/14 18:46:47.472 luup_log:25: VeraAlert:25:SendAlert:Msg:test {Device([Outside Detector].description)} <0x2b043000>
01 08/16/14 18:46:47.473 LuaInterface::CallFunction_Job device 25 function SVeraAlert_VeraAlert1_SendAlert_job failed [string "module("veraTemplateDevice", package.seeall..."]:76: attempt to index field '?' (a nil value) <0x2b043000>
01 08/16/14 18:46:47.473 Lua_Job::Run job#20 : dev:25 (0xdec588) P:50 S:0 failed <0x2b043000>
04 08/16/14 18:46:47.479 <0x2b043000>
02 08/16/14 18:46:47.490 JobHandler::PurgeCompletedJobs purge job#20 : dev:25 (0xdec588) P:50 S:2  status 2 <0x2b043000>
02 08/16/14 18:46:52.102 ZW_Send_Data node 17 USING ROUTE 255.136.0.0 <0x2bb77680>
04 08/16/14 18:46:52.240 <0x2b977680>
08 08/16/14 18:46:59.958 JobHandler_LuaUPnP::HandleActionRequest device: 25 service: urn:richardgreen:serviceId:VeraAlert1 action: SendAlert <0x2db77680>
08 08/16/14 18:46:59.958 JobHandler_LuaUPnP::HandleActionRequest argument DeviceNum=25 <0x2db77680>
08 08/16/14 18:46:59.958 JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:richardgreen:serviceId:VeraAlert1 <0x2db77680>
08 08/16/14 18:46:59.959 JobHandler_LuaUPnP::HandleActionRequest argument action=SendAlert <0x2db77680>
08 08/16/14 18:46:59.959 JobHandler_LuaUPnP::HandleActionRequest argument Message=test {Device([17].LightSensor.CurrentLevel)} <0x2db77680>
08 08/16/14 18:46:59.959 JobHandler_LuaUPnP::HandleActionRequest argument Recipients=Syslog <0x2db77680>
08 08/16/14 18:46:59.959 JobHandler_LuaUPnP::HandleActionRequest argument rand=0.9567450929162962 <0x2db77680>
50 08/16/14 18:46:59.961 luup_log:25: VeraAlert:25:SendAlert:Msg:test {Device([17].LightSensor.CurrentLevel)} <0x2b043000>
50 08/16/14 18:46:59.963 luup_log:25: VeraAlert:25:ExpandRecipients:Checking:Syslog <0x2b043000>
50 08/16/14 18:46:59.963 luup_log:25: VeraAlert:25:ExpandRecipients:Adding Requested Profile <0x2b043000>
50 08/16/14 18:46:59.963 luup_log:25: VeraAlert:25:SendAlert:Sending to:Syslog <0x2b043000>
50 08/16/14 18:46:59.965 luup_log:25: VeraAlert:25:SyslogSend:To:192.168.1.61:514 Msg:<14>Aug 16 18:46:59 ha VeraAlert: test {Device([17].LightSensor.CurrentLevel)}
<0x2b043000>
06 08/16/14 18:46:59.966 Device_Variable::m_szValue_set device: 25 service: urn:richardgreen:serviceId:VeraAlert1 variable: LastMsgSent was: 18:46:31 Sat Aug 16 now: 18:46:59 Sat Aug 16 #hooks: 0 upnp: 0 v:0xcb4f78/NONE duplicate:0 <0x2b043000>
50 08/16/14 18:46:59.982 luup_log:25: VeraAlert:25:SendAlert:Memory:288833 <0x2b043000>
04 08/16/14 18:46:59.983 <0x2b043000>
08 08/16/14 18:47:14.093 JobHandler_LuaUPnP::HandleActionRequest device: 25 service: urn:richardgreen:serviceId:VeraAlert1 action: SendAlert <0x2d777680>
08 08/16/14 18:47:14.093 JobHandler_LuaUPnP::HandleActionRequest argument DeviceNum=25 <0x2d777680>
08 08/16/14 18:47:14.094 JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:richardgreen:serviceId:VeraAlert1 <0x2d777680>
08 08/16/14 18:47:14.094 JobHandler_LuaUPnP::HandleActionRequest argument action=SendAlert <0x2d777680>
08 08/16/14 18:47:14.094 JobHandler_LuaUPnP::HandleActionRequest argument Message=test {Device([17].description)} <0x2d777680>
08 08/16/14 18:47:14.094 JobHandler_LuaUPnP::HandleActionRequest argument Recipients=Syslog <0x2d777680>
08 08/16/14 18:47:14.094 JobHandler_LuaUPnP::HandleActionRequest argument rand=0.8307708071662102 <0x2d777680>
50 08/16/14 18:47:14.097 luup_log:25: VeraAlert:25:SendAlert:Msg:test {Device([17].description)} <0x2b043000>
50 08/16/14 18:47:14.098 luup_log:25: VeraAlert:25:ExpandRecipients:Checking:Syslog <0x2b043000>
50 08/16/14 18:47:14.100 luup_log:25: VeraAlert:25:ExpandRecipients:Adding Requested Profile <0x2b043000>
50 08/16/14 18:47:14.101 luup_log:25: VeraAlert:25:SendAlert:Sending to:Syslog <0x2b043000>
50 08/16/14 18:47:14.102 luup_log:25: VeraAlert:25:SyslogSend:To:192.168.1.61:514 Msg:<14>Aug 16 18:47:14 ha VeraAlert: test Outside Detector
<0x2b043000>

And here's an excerpt from the XML for the Vera's devices

Code: [Select]
<device name="Outside Detector" altid="18" id="17" category="4" subcategory="3" room="3" parent="1" armed="0" humidity="90" status="0" batterylevel="
35" temperature="16" light="351" state="-1" comment="" tripped="0" lasttrip="1408106931"></device>
<device name="Outside Humidity" altid="e5" id="20" category="16" subcategory="0" room="3" parent="17" humidity="90"></device>
<device name="Outside Light Level" altid="e3" id="19" category="18" subcategory="0" room="3" parent="17" light="351"></device>
<device name="Outside Temperature" altid="e1" id="18" category="17" subcategory="0" room="3" parent="17" temperature="16"></device>

All advice gratefully received!

Thanks,
Jonathan.