Grohe Sense Guard - Fix offline issue and add Weekly water usage

I’ve spent quite some time to get my Grohe Sense Guard to work using the GROHE ONDUS Binding, so wanted to share how I got a pretty good setup working, mitigating some of the functions and adding a fix to get the setup stable. Earlier versions had issues with not updating the the channels but this seems to have been fixed with the latest releases.

Environment is:

  • openHABian v1.7.5 (OpenHAB 3.4)
  • GROHE ONDUS Binding

(I’m still using files to configure my openhab setup, but think the below can easily be translated to the new format)

The fix:
There is currently an issue with the binding that makes the Grohe Sense Guard thing go offline. To fix this I created a classic DSL rule according the the following receipe:

  1. Enable basic authentication: Settings → API Security → Allow basic authentication
  2. Add the rule below, but replace <your admin>,<your password> and <your IP> with your values (same admin user you are using when loggin in to the openhabian web interface)

The rule checks each fifth minute if the valve has gone offline and if so, it stops the account and then after 5 seconds, starts first the account, waits another 5 seconds and then starts the valve thing again.

rule "Restart Grohe ondus when valve offline"
when 
   Time cron "10 0/5 * 1/1 * ? *"
then
   // Get status of the Grohe Sense Guard Thing
   var thingStatusInfo2 = getThingStatusInfo("groheondus:senseguard:5eafb74748:199ff93d-4419-41ad-b83f-f32b0c0b0b5f")
   logInfo("myLog","Grohe Account, Status: " + thingStatusInfo2.getStatus().toString() )	
   logInfo("myLog","Grohe Sense Guard, Status: " + thingStatusInfo2.getStatus().toString() )	
   // If Grohe Sense Guard is offline, disable the Grohe account, then enable the account and finally the sense guard thing again.
   if ((thingStatusInfo2 !== null) && ((thingStatusInfo2.getStatus().toString() == "OFFLINE") || (thingStatusInfo2.getStatus().toString() == "UNINITIALIZED")))
   {
      logInfo("myLog", "Grohe Sense Guard is OFFLINE, disabling Grohe Account..")
      sendHttpPutRequest("http://<your admin>:<your password>@<your IP>:8080/rest/things/groheondus%3Aaccount%3A5eafb74748/enable","text/plain",'false',5000)

      createTimer(now.plusMinutes(1),  [|
         sendHttpPutRequest("http://<your admin>:<your password>@<your IP>:8080/rest/things/groheondus%3Aaccount%3A5eafb74748/enable","text/plain",'true',5000)
         logInfo("myLog", "Grohe Sense Guard, Account re-enabled")
      ] )
      createTimer(now.plusMinutes(2),  [|
         sendHttpPutRequest("http://<your admin>:<your password>@<your IP>:8080/rest/things/groheondus%3Asenseguard%3A5eafb74748%3A199ff93d-4419-41ad-b83f-f32b0c0b0b5f/enable","text/plain",'true',5000)
         logInfo("myLog", "Grohe Sense Guard Item re-enabled")
      ] )
   }
end

The function
I struggled with understanding what the differnt channels actually where delivering. “Valve Open”, “Pressure”, “Temperature” and “Water consumtion since midnight” are obvious but values coming from “Water consumtion” wasn’t making any sense. Eventually I figured out that it delivered the sum of todays and yesterdays water usage which wasn’t really useful, I rather wanted to graph the daily and a weekly consumption.
To fix this I added the below configuration. It uses two dummy items to just store values “Grohe_WaterUseBeforeChg” and “Grohe_WaterUseWeek”. With the below setup, you can graph Grohe_WaterUseToday and Grohe_WaterUseWeek (I’m not including the configuration for the graphing part).
Items

// Grohe Sense Guard Valve Items
Number Grohe_WaterUseToday      "Todays consumption [%.0f l]"                   <water>     (gWater)   {channel="groheondus:senseguard:5eafb74748:199ff93d-4419-41ad-b83f-f32b0c0b0b5f:waterconsumption_since_midnight"}
Number Grohe_WaterUse           "Todays + Yesterdays consumption"               <water>                {channel="groheondus:senseguard:5eafb74748:199ff93d-4419-41ad-b83f-f32b0c0b0b5f:waterconsumption"}
Number Grohe_WaterUseBeforeChg  "Water consumption before last change [%.0f l]" <water>     (gRestore)
Number Grohe_WaterUseWeek       "Weekly consumption [%.0f l]"                   <water>     (gWater)
Switch Grohe_Switch             "Water valve"                                   <switch>               {channel="groheondus:senseguard:5eafb74748:199ff93d-4419-41ad-b83f-f32b0c0b0b5f:valve_open"}

Rule

//-- Store yesterdays consumption at midnight when todays consumption is reset to graph the result.
rule "WaterUseStatistics"
when
   Item Grohe_WaterUseToday changed
then 
   logInfo("myLog", "(WaterUseStatistics) Water use today changed to: " + Grohe_WaterUseToday.state)

   // Reset Weekly statistics item to a value
   if (Grohe_WaterUseWeek.state==NULL) {
      Grohe_WaterUseWeek.postUpdate(0)
   }

   // Check if midnight
	if (Grohe_WaterUseToday.state==0) {
      logInfo("MyRule", "Today is " + now.dayOfWeek.toString)
      // On mondays, reset Weekly water consumption to 0
      if (now.dayOfWeek.toString == "MONDAY") {
         logInfo("MyRule", "The day of the week is " + now.dayOfWeek.toString + ", Resetting weekly consumption to 0")
         // Its Monday, weekly consumption item 
         Grohe_WaterUseWeek.postUpdate(0)
      }
      // Also reset variable holding previous consumption
      Grohe_WaterUseBeforeChg.postUpdate(0)
   }
   else {
      logInfo("MyRule", "The day of the week is " + now.dayOfWeek.toString + ", Adding delta to weekly consumption")
      // It not midnight and dayly usage has changed, add the delta since last time to weekly consumption
      Grohe_WaterUseWeek.postUpdate((Grohe_WaterUseWeek.state as Number)+((Grohe_WaterUseToday.state as Number)-(Grohe_WaterUseBeforeChg.state as Number)))
      Grohe_WaterUseBeforeChg.postUpdate(Grohe_WaterUseToday.state)
   }
end