Skip to content

Instantly share code, notes, and snippets.

@dannyrandall
Last active February 20, 2021 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dannyrandall/8f9a4f5645c192a192b9f832a4253a7d to your computer and use it in GitHub Desktop.
Save dannyrandall/8f9a4f5645c192a192b9f832a4253a7d to your computer and use it in GitHub Desktop.
ruleset sensor_profile {
meta {
name "Sensor Profile"
author "Daniel Randall"
provides profile, temperature_threshold, notification_to
shares profile, temperature_threshold, notification_to
}
global {
profile = function() {
{
"name": ent:name.defaultsTo(""),
"location": ent:location.defaultsTo(""),
"temperature_threshold": temperature_threshold(),
"notification_to": notification_to()
}
}
notification_to = function() {
ent:notification_to.defaultsTo(meta:rulesetConfig{"default_notification_to"})
}
temperature_threshold = function() {
ent:temperature_threshold.defaultsTo(100)
}
}
rule updated {
select when sensor profile_updated
always {
ent:name := event:attrs{"name"}
ent:location := event:attrs{"location"}
ent:temperature_threshold := event:attrs{"temperature_threshold"}
ent:notification_to := event:attrs{"notification_to"}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment