Hi
Taking bits for other posts I’ve read, I’ve had a go at creating a function that will send an event to an alternate event server when a temperature value changes. (This all relates to @Quinten’s Event Server post)
Please could you let me know if I’m on the right track…
[code]local temp_device_to_watch = 137
luup.variable_watch(“updateTempLastUpdated”, “urn:micasaverde-com:serviceId:TemperatureSensor1”, “CurrentTemperature”, temp_device_to_watch)
–sets up the callback to the function pasted below
function updateTempLastUpdated(dev_id,service, variable, old_val, new_val)
– called when a temperature device changes
if new_val > old_val then
– send temp has increased notification to thealternative Vera event server MySQL db
https://192.168.1.111:8001/alert?PK_AccessPoint=35102036&HW_Key=BlahBlah&DeviceID=33&LocalDate=2013-08-21%2003:12:17&LocalTimestamp=1377051137&AlertType=3&SourceType=3&Argument=12&Format=&Code=CurrentTemperature&Value=18&Description=House%20Temp%20Increases%20From%20..old_val..%20to%20..new_val..%20&Users=157707
else
if old_val > new_val then
– send temp has decreased notification to the alternative Vera event server MySQL db
https://192.168.1.111:8001/alert?PK_AccessPoint=35102036&HW_Key=BlahBlah&DeviceID=33&LocalDate=2013-08-21%2003:12:17&LocalTimestamp=1377051137&AlertType=3&SourceType=3&Argument=12&Format=&Code=CurrentTemperature&Value=18&Description=House%20Temp%20Drops%20From%20..old_val..%20to%20..new_val..%20&Users=157707
else
end
end
end[/code]
I’m not sure how to address the date times values so they are taken fresh/dynamically every time, I assume it’s os.date() but not sure where to put it, or how to format it appropriately. Also I’d like as much of the event URL to be created dynamically so it can work for other variables too.
Many thanks for any help you people can give