[Labs] Rules

@AirmakZ Stay Awake option is required to be enabled for turn screen on/off rules to work, which would keep the screen on.

General flow of screen on/off rules is:

  • when turn-on-screen rule condition is true > turn on screen (if possible) or keep screen on
  • when turn-off-screen rule condition is true > do not keep screen on, and let Android system display timeout happen.

Both rules (screen-on/screen-off) and Stay Awake enabled are needed.

Oh!! So I misunderstood some previous comments on this feed. My understanding was that screen turn on action just send a trigger to turn on the screen but it keeps on just until android expires!
I will play with rules deeply…!
Thanks and congratulations for the application!

1 Like

@AirmakZ Sure, let me know if there are still troubles with getting it to work.

Does not work for me. Camera window opens on condition, but with a small orange text in the top left corner of the camera window with “Video format error”. Camera binding is exact the same like the Widget (copy & paste it), where it works fine if I click the Camera Widget manually. Any idea?

@anon34194377 Can you post your rule config JSON?

@igor Of course.

  "rules": {
    "camera-show": {
      "name": "Show camera",
      "condition": {
        "item": "1nxzl45wqj00j1boiubno8olid.input_boolean.garagentor#switch.state",
        "operator": "eq",
        "value": "on"
      },
      "action": {
        "type": "show-camera",
        "binding": "1nxzl45wqj00j1boiubno8olid.camera.garage#camera.video-uri",
        "value": null
      },
      "enabled": true
    },
    "camera-hide": {
      "name": "Hide camera",
      "condition": {
        "item": "1nxzl45wqj00j1boiubno8olid.input_boolean.garagentor#switch.state",
        "operator": "eq",
        "value": "off"
      },
      "action": {
        "type": "hide-camera",
        "binding": null,
        "value": null
      },
      "enabled": true
    }
  }

This is the camera widget:

              "properties": {
                "label": "",
                "video-uri": {
                  "binding": "1nxzl45wqj00j1boiubno8olid.camera.garage#camera.video-uri"
                },
                "snapshot": {
                  "binding": "1nxzl45wqj00j1boiubno8olid.camera.garage#camera.snapshot"
                },
                "snapshot-image": null,
                "snapshot-interval": "10s",
                "snapshot-timestamp": true,
                "scaling": "crop",
                "rotation": 0
              }

@anon34194377 is camera coming from Home Assistant integration?

@igor Yes, the camera is coming from Home Assistant integration (Frigate NVR).

@anon34194377 Can you check what is the state of Legacy camera streaming feature in HomeHabit Labs?

@igor Legacy camera streaming was disabled. I enabled it, but the same issue.

@anon34194377 I was actually asking if it is already enabled, because it does not apply to rule triggered camera popup (but it does apply to camera widget).
Not sure why would be any difference then, will need to check.

I also suggest disabling legacy camera streaming again, since it uses less-performant processing and will be removed in the future.

Hey @Igor, just testing out these rules to turn the screen on/off for a Lenovo tablet. I have setup a dummy light in HomeAssistant and if I add the light to a homehabit dashboard I can see it reflect the light state… Now I’m trying to turn the physical screen on/off. I think my rule looks good but not getting any result…

  "rules": {
    "screen-on": {
      "name": "Turn Screen ON",
      "condition": {
        "item": "1wlu8vob1rtcb10k8ex34u4d4t.light.dummy_light_01#light.state",
        "operator": "eq",
        "value": "on"
      },
      "action": {
        "type": "turn-on-screen"
      },
      "enabled": true
    },
    "screen-off": {
      "name": "Turn Screen OFF",
      "condition": {
        "item": "1wlu8vob1rtcb10k8ex34u4d4t.light.dummy_light_01#light.state",
        "operator": "eq",
        "value": "off"
      },
      "action": {
        "type": "turn-off-screen"
      },
      "enabled": true
    }
  }

@TommySharp For screen on/off to work, make sure that “keep awake” in Settings is enabled. Also check what is the display timeout in Android Settings, since that is the time it would take for screen to turn off after condition is satisfied.

I have now set HomeHabit to Keep Awake. But I still cannot turn the screen off by a rule. Although it does now work if I turn off the screen manually and then change the state of my HA light, the screen now turns on.

I can’t really think of a use case for turning off the screen as the tablet is set to also turn off after 2 minutes. But is it worth investigating why the rule to turn it off does not work?

EDIT : seems I can’t get the screen to turn on anymore… It definitely worked once…

EDIT : Okay so more testing shows that I can turn on the screen so long as my HA light switch that fires the rules is turned off before the tablet screen turns off.

Screen-on should only work if screen was turned off by corresponding rule as well. Manual screen off usually prevents screen-on rule from working (some Android limitations), since the app didn’t enter that special “sleep” mode. It might work differently on some devices, since some brands mess with the OS behavior.

General flow of screen on/off rules is:

  • when turn-on-screen rule condition is true > turn on screen (if possible) or keep screen on
  • when turn-off-screen rule condition is true > do not keep screen on, and let Android system display timeout happen.

Mot sure I understand the steps here, can expand on it?

Doesn’t appear to be possible but thought I’d ask… Can I set multiple actions in a single rule?

i.e. Turns screen on, say someone is at the door and show the camera stream?

Not possible currently. Multiple rules with the same condition should work though. Although, screen on might interfere with the other rules, since they would be run in parallel.

Hi.
Should the brightness change to a specific value when the motion sensor is triggered? It’s not working right now. Automatic brightness on the tablet is naturally disabled

"rules": {
  "change-screen-brightness-100": {
    "name": "Change Screen Brightness 100",
    "condition": {
      "item": "p3zsikjms10n1kssym7ivx4h5.device-74#switch.state",
      "operator": "eq",
      "value": "on"
    },
    "action": {
      "type": "set-screen-brightness",
      "binding": null,
      "value": "100"
    },
    "enabled": true
  },
  "change-screen-brightness-10": {
    "name": "Change Screen Brightness 10",
    "condition": {
      "item": "p3zsikjms10n1kssym7ivx4h5.device-74#switch.state",
      "operator": "eq",
      "value": "off"
    },
    "action": {
      "type": "set-screen-brightness",
      "binding": null,
      "value": "10"
    },
    "enabled": true
  }
},

@IvanB Action value should be a number in this case. For example:

    "action": {
      "type": "set-screen-brightness",
      "value": 100
    },

Hi,

I’ve got screen ON / OFF working and I have “Stay Awake” enabled on my Samsung Galaxy Tab A8, but there is an issue. When the screen turns off for a while (>1 minute) the screen will not turn on anymore unless I manually press the button on the tablet. Does this have to do with the Samsung bloatware that has been installed on the device and should I try a custom rom?

EDIT: Fixed the issue. I had to remove the “optimised battery” option from the HomeHabit app.

1 Like