[Labs] Rules

7.0 release has the new Rules in HomeHabit Labs (enable in Settings).
This is an early release for Rules feature, so it is currently only configurable with Remote Config Editor and it isn’t possible to configure in the app UI yet.

What is Rules feature?

Rules feature allow to perform some UI actions based on certain conditions.
For example: turn on device screen when motion sensor is triggered, or change screen brightness using external dimmer device.

Available actions

  • Turn screen on/off (turn-on-screen, turn-off-screen)
    • screen turn off is based on the Android display timeout. For example, if display timeout is set to “after 1 minute of inactivity”, screen will turn off 1 minute after the rule condition is triggered.
  • Start/stop screensaver (start-screensaver, stop-screensaver)
  • Set screen brightness (set-screen-brightness)
  • Set device volume (set-volume)
  • Launch an app (launch-app)
  • Open URL in browser (launch-browser)

How to enable Rules?

  • Go to Settings > HomeHabit Labs
  • Enable Rules feature
  • Restart the application

How to configure Rules

To configure Rule you need to enable Remote Config Editor in Settings and use any browser to open provided editor URL. The configuration is not streamlined yet, and requires editing JSON config.

Example configuration
{
  "id": "1m9pyl13vtgee1ljk8ollkbex4",
  "name": "Turn Screen ON",
  "condition": {
    "item": "y6e5q5u6vl921gamz284yt1gq.DemoSwitch#switch.state",
    "operator": "eq",
    "value": "on"
  },
  "action": {
    "type": "turn-on-screen",
    "binding": null,
    "value": null
  }
}
Properties
  • id - automatically generated identifier (skip when adding a new rule)
  • name - rule name
  • condition
    • item - reference to item attribute to use as a condition. Format is the same as for widget bindings, so it best to copy it from an existing widget if possible
    • operator - possible values eq (equals), changed (any change)
    • value - comparison value for equals operator
  • action
    • type - possible values listed above
    • binding - can be used as dynamic value for set brightness/volume actions
    • value - used as a value for launch app/browser actions
Notes
  • condition value for switches and binary sensors is currently on/off string

1 Like

Examples

Turn on screen based on switch state

{
  "name": "Turn Screen ON",
  "condition": {
    "item": "1iewvtk7t49mk1muoklesjfcx8.DemoSwitch#switch.state",
    "operator": "eq",
    "value": "on"
  },
  "action": {
    "type": "turn-on-screen"
  }
}

Turn off screen based on door sensor state

{
  "name": "Turn Screen OFF",
  "condition": {
    "item": "1iewvtk7t49mk1muoklesjfcx8.9#content-sensor.state",
    "operator": "eq",
    "value": "off"
  },
  "action": {
    "type": "turn-off-screen"
  }
}

Change screen brightness based on dimmer position

{
  "name": "Change Screen Brightness",
  "condition": {
    "item": "1iewvtk7t49mk1muoklesjfcx8.Dimmer#dimmer.position",
    "operator": "changed",
    "value": null
  },
  "action": {
    "type": "set-screen-brightness",
    "binding": "1iewvtk7t49mk1muoklesjfcx8.Dimmer#dimmer.position"
  }
}

Change device volume based on dimmer position

{
  "name": "Change Volume",
  "condition": {
    "item": "1iewvtk7t49mk1muoklesjfcx8.Dimmer#dimmer.position",
    "operator": "changed",
    "value": null
  },
  "action": {
    "type": "set-volume",
    "binding": "1iewvtk7t49mk1muoklesjfcx8.Dimmer#dimmer.position"
  }
}

Launch Netflix on the device

{
  "name": "Launch App",
  "condition": {
    "item": "1iewvtk7t49mk1muoklesjfcx8.Scene_General#number-value.state",
    "operator": "eq",
    "value": 2
  },
  "action": {
    "type": "launch-app",
    "value": "com.nest.android"
  }
}

Launch browser with URL

{
  "name": "Open URL",
  "condition": {
    "item": "1iewvtk7t49mk1muoklesjfcx8.Scene_General#number-value.state",
    "operator": "eq",
    "value": 3
  },
  "action": {
    "type": "launch-browser",
    "value": "http://example.com"
  }
}

The rules are great! I tried them and it works!
Do you plan add more actions?
e.g. the action that maximizes / minimize the camera widget with video stream. That would be very useful if motion on camera is detected.
Thank you

2 Likes

@sucharz That’s great!
Yes, camera widget action is planned.

1 Like

Any idea as to why I can’t access the remote config editor. I have it set-up, but the URL won’t work. I just get ERR_CONNECTION_TIMED_OUT.

I am almost certain I’ve accessed it previously.

@Connor_Thompson Can suggest trying few things:

  • try pinging device ip from command line (e.g. ping 192.168.x.x)
  • when you open the app, see if it shows a notification that it cannot start Remote Config
  • restarting the app completely (after closing from the recent apps screen)

I just tried to ping the device and apparently the host is unreachable, not quite sure why though.

both devices are on the same subnet?

Yup. I’ve tried to ping other devices such as my mobile, and they are responding. I am just gonna have to have a play around to see if I can fix it I think.

Just confusing.

Thank! Turning on, turning off the screen, this is the most anticipated function of the program! Now I will save money for the premium version, I admit, it is very expensive for me, but I will save!

This is great. I was able to get the sleep/wake process working well. However I wasn’t able to get the screen brightness to work at all (on my Lenovo Tab M8 running Android 9). It may be becaue I am using a Home Assistant .input_number.wall_panel_brightness#value.number and not a “dimmer”? If they aren’t already it’d be great if input_number entities can be supported.

I have one feature request for Rules: locking the app. I’d like to be able to have HomeHabit completely locked if a boolean is set to true. By locked I mean the entire app becomes a single non-responsive screen.

Similar to this it would be great to have the ability to lock all HomeHabit settings and dashboard customisation with a rule. When locked, you couldn’t modify dashboards/settings, and the config web server is switched off.

Down the track it’d be great if individual panels could be locked and unlocked with rules. This would make a great Premium feature. I could imagine this being useful, especially when tied to the homeowner’s presence. Perhaps I don’t want certain buttons to be available when I’m not there!

What is the value range for input_number?

The default for input_number is an integer between 0 to 100. I also tried customising it to be between 0 and 1 with a step of 0.01 but no luck there either.

You can generate an input_number very easily in Home Assistant. In settings, they’re called “helpers” for some reason. These are just raw entities which aren’t associated with any device, and don’t do anything on their own.

Oh, yeee! I have been waiting for it for about 3 years. But only the functions in rules work if HomeHabit is on top? Not in the background?

Yes, I was wondering if you have a non-default range set there. 0 to 100 is the supported range, so it should work. Will check on it.

Yes. The app does not keep connection to platforms when in the background.

Is there an Android system permission that HomeHabit is supposed to have in order to change screen brightness? I don’t think the app has asked for (or received) any special security permissions.

Permission is required only when changing system brightness (the same as through Android Settings). With rules, the app is changing brightness only while it is active, which doesn’t require extra permissions. Screen brightness will go back to its system setting when the app is closed.

Hmm, nice option for those who don’t have a rule system on their platform. For Domoticz users it is kind of an overkill as it has several rules options (Blocky, dzVents, Lua and Python scripts).

@waltervl The rules are not intended to replace automation that is done on a hub, like Domoticz. This is geared towards controlling UI behavior of the app itself based on the system state.
The rules will have a deliberately simple condition/action configuration, and users would rely on more powerful hub automations to do any complex logic to bring system into a desired state.