Activate Android systems Night Mode - Companion App

Hello!

How can I turn Androids’ system wide Night Mode on or off through command notifications sent to home assistant companion app?

I can set the screen brightness and screen auto brightness through the command notifications. And from what I can tell, I could send out intents to other apps. The Night Mode however seems to be part of androids os, so not sure if this could be activated through an intent? Or, if the home assistant companion app would have to specifically support the API call.

The full story (motivation for why): The Night Mode on Android is the blue screen filter meant to be used before going to bed, or to minimize strain on the eyes from looking at the screen. I wanted to create a home automation for going to bed for my entire bedroom. This would cause home assistant to run through several settings like adjusting the lights of my room to a low level, enabling dim lights on motion detected for seeing the floor, etc… Specifically on my phones part, my android should do three things: turn screen brightness to 0, turn auto screen brightness off, and turn Night Mode on to minimize blue light emissions. The first two were easy and were supported using the command notifications (Notification Commands | Home Assistant Companion Docs), however, the Night Mode doesn’t appear to be supported.

Does anyone have an ideas?

you will need to submit a feature request for this as its not possible yet. Looks like we will need to use this API

https://developer.android.com/reference/android/app/UiModeManager#setNightMode(int)

Thank you. Just wrote one: Support "Night Mode" setting on/off - Android API call · Issue #3341 · home-assistant/android · GitHub

1 Like