Use Android device proximity sensor as switch

Hi,
I just started to join this community and already have some question for which I didn’t find any solution on the internet. I have several old and new Samsung Android cell phones, which I would like to put on wall in rooms and use them as switch.

Is it possible to use or configure device build in proximity sensor (sensor which turn off screen during call) to report state out of call? I can see that this sensor works while I have call, but I don’t see status change out of call.

Do you have some idea how to use proximity sensor as switch?

I would like to move hand in front of device and based on this call some action. Turning light for example

When you install the app on your device you can go into “App Configuration” and from there “Sensors”
The proximity sensor should be in the list, just enable it and it will show up in your HA entities

Depending on the device it wont switch to near until you actually almost touch the screen (ear detection)
Better would be to use:

And use the REST api to get the motion sensor state from the json data.
There are alot of guides around on how exactly everything works. Plus its free so you can check if everything works on your older phones

The proximity sensor is a poll based sensor so it may not work as you would expect. You can try enabling more sensors to get it to update more frequently

If that’s the case and you are willing to spend $4 on the Tasker app, the proximity sensor (not the entity in HA) could trigger the Android phone to send an http request that would give you instant update. There are probably other options to http request for an Action to achieve your goal.

I was only mentioning how the sensor worked, I use tasker but have no use case to have the proximity sensor constantly being monitored

I can see sensor in app but it doesnt change state. It change state only durring a call. I have been reading definitions in HA and also Android.

This Screenshot is taken durring call to fathers phone. I was moved hand in front of display.

I need to somehow simulate that phone is in call or activate proximity sensor to be used always. Even when screen is off.

I will try to do this direction and find some useful guide how to use REST in HA

I have activated all possible sensors but I never get update. Sensor state changing only durring a call. Maybe that is specific to Samsung devices or it’s hardcoded in Android it self.

Keep in mind that most proximity devices report either 5 or 0 and meaning you only have a small area to trigger the sensor. If you say it only happens when your on the phone then try waving your hand closer to the screen. Not all devices report the actual distance. It could be specific to samsung, hard to tell since they dont document it.

See the second note from the anchor link: