PfisterDaniel / node-red-contrib-apple-find-me

Node to get the current locations and other metrics of connected Apple devices.
MIT License
23 stars 5 forks source link

Battery Level Homebridge #8

Closed theAnDrO40 closed 3 years ago

theAnDrO40 commented 3 years ago

Hey I've a question

My first question is there a possibility to readout the battery level from my iPad and trigger a power outlet for charging this iPad

I don't no how to build up such a Flow in Node RED because I'm not familiar enough with Node RED and I hope somebody can help me.

My next question is du have to filter the apple device before I ask for the battery level ?

PfisterDaniel commented 3 years ago

Hello,

  1. Yes you can trigger the charging level from your iPad. For example I need more Information about your configuration. Which sockets do you have e.g. TP-LINK HS110 ...

  2. I don't really know what you mean. If you use the node "Locate my Devices" you get a list of all your Apple Devices with ID. The ID is the unique identifier of your device. You can use this id to filter only your iPad.

theAnDrO40 commented 3 years ago

Okay thank you for your fast reply

I have the following situation. I have an raspberry pi with hoobs/homebridge in background there is an instance running of node red.

Your Node red plug-in is working well. Now my problem in my hoobs/homebridge I added the Shelly Plugin because I want to trigger the Shelly if the battery is below 10% and the same at 100%.

I have no idea how I cat realise this in node red. Sorry

Yes I found all these information in the debug msg.

image

theAnDrO40 commented 3 years ago

I don't know I had tested several functions with the additional node red Shelly plugin.

If functions and simple switch functions maybe I have to add a function if triggered then know idea

PfisterDaniel commented 3 years ago

You can use a simply Function: if(msg.payload.iPad[0].batterLevel < 10){ msg.payload = { "relay": 0, "on": true}; }else if(msg.payload.iPad[0].batterLevel = 100){ msg.payload = { "relay": 0, "on": false}; }else{ msg.payload = { "relay": 0, "on": false}; } return msg;

I think that works for you....

Unfortunately I don't have any Shellys to test it out. But I like the idea a lot :-)

Bildschirmfoto 2021-02-08 um 19 55 27 Bildschirmfoto 2021-02-08 um 19 56 04
PfisterDaniel commented 3 years ago

if you use the Node-Red Node node-red-contrib-shelly

then you must use following function:

if(msg.payload.iPad[0].batterLevel < 10){ msg = { "relay": 0, "on": true}; }else if(msg.payload.iPad[0].batterLevel = 100){ msg = { "relay": 0, "on": false}; }else{ msg = { "relay": 0, "on": false}; } return msg;

I hope I could help you

theAnDrO40 commented 3 years ago

Thanks a lot in this case I didn't see the wood for the trees

Thank works great have a nice evening.

PfisterDaniel commented 3 years ago

Nice that it works. You also have a nice evening. If you like my plugins or addons, then follow me on Github or give me a star.

Br Daniel

theAnDrO40 commented 3 years ago

One little thing I missed it must be msg.payload instead of only msg then it works.

Thank you