Get iPhone battery state while locked


I've been getting into home automation for the last year or so, and just discovered the wonders of HA and Node Red!

I'm currently trying to make a flow where if the battery state of my phone changes to Charging and my wife's phone's battery state is also set to Charging (and vice versa), then all the lights in the house turn off/doors lock etc...

The flow works fine, but it only works if the phones are unlocked with the Home Assistant Companion app open...

Is there any way to make this work without having the app open/phone unlocked?

I've had a look online but can't seem to find anyone having the same problem...

Any help would be greatly appreciated!


What you want to do is not impossible.

But you will really have to explain more how these things are connected.

There is a huge disconnect with the phone's battery being changed and all the lights being tured on/off (what ever)

How about you start with a simple bit of flow/code that simply looks at the phone's battery level and when that is working, you can go onto the rest.

But you will have to expand on how you are getting this information.

(I have flows that detect the mobile phone's battery levels - kind of - but my use is a lot LOT less overpowering than yours and I probably use a whole different system for communications)

If the Node-RED flow works fine as you say, the issue is not with that.

Why do you not ask at the Home Assistant forum why their app is only working when it is open and the phone is unlocked? It's actually a typical phone behaviour. You can experience the same also with other apps, the phones operating system is controlling, one reason is it is tryin to save power. I have seen the same type of behaviour on my iphone

1 Like

I'm just using a state node with "sensor.myphone_battery_state" as the entity ID that then checks if my wife's battery state is also charging and then calls the service to turn off the lights etc

Like krambriw said, it is most likely a HA/Iphone problem rather than a Node red problem, I don't know why I decided to post my problem on here :smiley:

Thanks for the quick reply! :wink:

Hmmmmmm, that's a very good point... :smiley: I'll just go paste my original message in the HA forum :slight_smile:

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.