Skip to main content

cookbook

Hivescript can be used for lots of useful things. Here are some examples.

Delete an object that has been tagged as a troublemaker:

when
object(troublemaker="true")
then
delete()

Delete objects tagged as temporary that haven't received an update in two seconds.

every 1 seconds
when
object(type="temporary", $lastUpdate<now().minus(seconds=2))
then
delete()

Set sensors to have a status of faulty if they haven't received an update in the last minute:

every 30 seconds
when
object(type="sensor", $lastUpdate < now().minus(minutes=1))
then
set("status","faulty")
until
set("status","ok")

Find areas that have more than 6 passengers being carried by a single aircraft, and log them:

when
area().containing(tag="plane", min[passengers]>6)
then
debug("more than 6 passengers being carried by a single aircraft")

Trigger a webhook if a person is within 10 meters of a danger:

when
object(type="personel").near(10, type="danger")
then
sendToUrl("https://webhook.site/look-out")

Trigger a webhook if a vehicle is within 100 meters of a bridge that is too low for the vehicle:

when
object(type="vehicle").near(100, type="bridge", minClearance < this().get("maxClearance"))
then
sendToUrl("http://localhost/low-bridge")

Set the status of a sensor object to "low" if it has a value lower than the value set on the dial object.

when 
object(type="sensor", value < object(tag="dial").get("value"))
then
set("status", "low")
until
set("status", "normal")