Skip to content

openHAB: reset DateTime in rules

In one of my openHAB rules I'm using a timestamp to track when an Item went offline. This is used in my monitoring to let the user (me) know how long the Item is already offline.

Background: we have a couple ChromeCasts in our network. When they are connected to a 5GHz Wi-Fi they are quite unstable and often loose the network connection. Usually the openHAB binding reconnects the device quickly, but it happens that the device stays offline. It might have something to do with the router, but nevertheless I want to know when things go offline.

For this I defined a virtual Switch as DateTime:

DateTime	LivingRoom_OfflineSince		"Offline Since [%tY-%tm-%td%tH:%tM:%tS]"

When the ChromeCast goes offline, this Switch is updated in a rule with the current time:

LivingRoom_OfflineSince.postUpdate( new DateTimeType() )

 

However resetting the DateTime switch when the item comes back online proved to be a small challenge, the documentation is unclear. People write online about "UnDeftype", "UNDEF", "(unknown)", "UnDefType.UNDEF", "UnDefType.NULL" and a couple more.

In the end it's quite easy:

LivingRoom_OfflineSince.postUpdate(NULL)

Just update the Item with NULL. Don't use sendCommand() here, you only want to update the Item, not send a new command to a virtual switch.

  • Twitter
  • Bookmark openHAB: reset DateTime in rules at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg openHAB: reset DateTime in rules
  • Bloglines openHAB: reset DateTime in rules
  • Technorati openHAB: reset DateTime in rules
  • Fark this: openHAB: reset DateTime in rules
  • Bookmark openHAB: reset DateTime in rules at YahooMyWeb
  • Bookmark openHAB: reset DateTime in rules at Furl.net
  • Bookmark openHAB: reset DateTime in rules at reddit.com
  • Bookmark openHAB: reset DateTime in rules at blinklist.com
  • Bookmark openHAB: reset DateTime in rules at Spurl.net
  • Bookmark openHAB: reset DateTime in rules at Simpy.com
  • Bookmark openHAB: reset DateTime in rules at blogmarks
  • Bookmark openHAB: reset DateTime in rules with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.
Form options