Detect if Android device is unlocked

Hey everyone, I’m new to home assistant and wondering if there’s a way to have home assistant see if an android device is unlocked and use it as a trigger for automation.

I’m not sure if HA can do it natively but with the Tasker app, you can trigger based on phone unlocking. Therefore, you could trigger an Http Request or MQTT message to HA. I am not deep into HA so there is probably an easier way natively.

If you have HA app installed there’s a sensor “device locked” (disabled by default) you can enable and it will appear in HA. Goto HA settings, ha app settings, sensors…

I knew there would be an easier way. :grinning:

Thank you.

I also needed to know when phone is unlocked, but this is really slow and unreliable if you don’t have the app open.

I want to send a automation when screen is unlocked, to start my charger again, but as said, sometimes it don’t even update the entity, maybe because I don’t us when phone more then 15min?

Don’t know but really frustrating :frowning:

Have you checked the update interval time of you companion app?
What I’m doing is to to send a refresh sensors.

I have “normal” on, and that is 1min during charging, and otherwise, update every 15min.

If I have fast update interval it will drain the battery eventually… What kind of refresh sensor do you have?

Action “command_update_sensors”