home-assistant / android

:iphone: Home Assistant Companion for Android
https://companion.home-assistant.io/
Apache License 2.0
2.3k stars 636 forks source link

Add phone flash light/torch as light entity #1606

Open michamichamicha opened 3 years ago

michamichamicha commented 3 years ago

Is your feature request related to a problem? Please describe. Not related to a problem

Describe the solution you'd like I would like the Companion App to facilitate a light entity that controls the torch of mobile phones.

Describe alternatives you've considered, if any Maybe add a service to make the phone vibrate as well?

Additional context Could be used for notifications, automations (arriving at home in the middle of the night, scanning an NFC tag and automatically turn on just the torch) and a lot more in my opinion.

dshokouhi commented 3 years ago

I would like the Companion App to facilitate a light entity that controls the torch of mobile phones.

so currently the mobile_app integration only provides sensors for the companion apps to use. We would need to make controlling the flashlight a notification command and then represent its state as a binary sensor in the meantime. A developer with python experience would need to add support for the light/switch entity.

Maybe add a service to make the phone vibrate as well?

This could probably be its own feature request, probably can make some options configurable like pause and length of vibration

virtualJonesie commented 3 years ago

In general, I would love to see the phone controllable via the app. For instance, when I run my bed time routine, Home Assistant turns on Do Not Disturb mode.

Other interesting integration points could be: Ringer/Vibrate/Silent Wifi On/Off Bluetooth on/off Airplane mode on/off etc

dshokouhi commented 3 years ago

In general, I would love to see the phone controllable via the app. For instance, when I run my bed time routine, Home Assistant turns on Do Not Disturb mode.

Other interesting integration points could be: Ringer/Vibrate/Silent Wifi On/Off Bluetooth on/off Airplane mode on/off etc

Ringer, DND, Bluetooth already done. Airplane mode impossible lol, think about it for a sec. Wifi no longer possible via Android API, google put a stop to it. You should read the docs so you know what you can already control.

virtualJonesie commented 3 years ago

Fair point on Airplane Mode. Didn't think that one through. :)

I see that there are sensors for the items you listed, but I don't see any switches to control them.

For example, I would love to turn on WiFi automatically when I arrive to my home location, to ensure I don't run on cell data unnecessarily. Or turn off the ringer at night when I place it on the charger. Controlling some basic functions would be really nice.

If it's already possible, I may just be missing it. But when I search in the Developer Tools for my phone, all I see are sensors, binary_sensors, and device_tracker entities, no switch entities to control these settings.

dshokouhi commented 3 years ago

I see that there are sensors for the items you listed, but I don't see any switches to control them.

until an experienced python developer updates the mobile_app integration in HA core to include more than sensors, binary sensor and device tracker we have to use notification commands which are listed in the docs

https://companion.home-assistant.io/docs/notifications/notification-commands

virtualJonesie commented 3 years ago

Oh! Brilliant! I had not seen this previously! Thank you!

stale[bot] commented 2 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

DmytroMelnyk commented 2 years ago

I managed to toggle phone flashlight by using Broadcast Intent and the first app that I was able to find on the F-Droid store that supports flashlight toggle intent (I guess you could use official GooglePlay store but F-Droid allows you to navigate and investigate source code much more easier). To make long story short:

  1. Install F-Droid
  2. Install Torch
  3. To toggle flash you should send notification broadcast-intent:
    service: notify.mobile_app_<your_device_id_here>
    data:
    message: command_broadcast_intent
    data:
    intent_package_name: com.doomy.torch
    intent_action: com.doomy.torch.TOGGLE_FLASHLIGHT