Use voice command (Google Assistant and/or Alexa) to initiate Android phone finder feature
“Hey Google, turn on Jim’s Phone Finder”
“Alexa, turn on Bob’s Phone Finder”
Programmatically initiate phone finder feature
When you have multiple android phones, asking Google to find my phone results in it prompting about each phone one by one. It can get quite tedious. Sometimes it would just ring the first phone.
This solution lets you ring the specific phone using an openhab item.
Updates:
2024-01-07 fixed the page parsing again, and make it a self-contained script. It is no longer necessary to manually create the required items.
2023-03-22 fixed find_elements to find multiple phones
2023-03-21 Adapted to Google’s obfuscated class names
2022-12-30 Refactor and move cookie storage into metadata
2022-07-23 Google stopped showing the find my phone feature in the search result. Changed the find my phone url to google.com/android/find - the FindMyPhone#ring method is also updated accordingly
Nice work. Unfortunately I was not able to install selenium standalone docker on openHABian and I dont like JRuby. So I re-implemented the code using Node and used ChromeDriver directly.
How to use?
install app using ‘npm install’ in project’s root directory
Install ChromeDriver using ‘sudo apt-get install chromium-chromedriver’
copy path of chromedriver binary in constructor method of app.js
Support for multiple phones is missing. I invoked the node app like this
/*
This rule scrapes the google's 'find my phone' page to let the phone ring
*/
var Exec = Java.type("org.openhab.core.model.script.actions.Exec");
rules.JSRule({
name: "Ring My Phone",
description: "This rule scrapes the google 'find my phone' page to let the phone ring",
triggers: [triggers.ChannelEventTrigger("deconz:switch:homeserver:tdfr_shortcut_findphone:buttonevent", "1002")],
execute: data => {
console.log("Let your phone ring...");
Exec.executeCommandLine( 'node', '/home/openhabian/selenium-test-app/app.js', 'ring');
}
});
rules.JSRule({
name: "Refresh google cookies",
description: "This rule reloads the google cookies needed for authentification.",
triggers: [triggers.GenericCronTrigger("0 0 */3 ? * *")],
execute: data => {
console.log("Refresh google cookies...");
Exec.executeCommandLine( 'node', '/home/openhabian/selenium-test-app/app.js', 'refresh');
}
});
I’m trying to use your solution as well (the JS one in a dockerized environment). I’ve successfully deployed the selenium container and are able to debug the JS code. All seems fine, except the fact, that I’m not able to sign in to my google account. I’ve a feeling that the cookie string is not good I’m sending. My default cookie value looks like this:
UPDATE: I managed to set the correct cookies using the method from the original repo, so the issue was caused by the incorrect or insufficient cookies.