Intent command to enable wifi on phone?

So “someone” in the home found a glitch in my automation.
If this person does not have the wifi turned on then the phone can trigger multiple times to open door.
(kind of obvious now that I think about it.)

trigger:
  - platform: state
    entity_id: binary_sensor.petras_telefon  # BLE sensor
    id: petra
    to: 'on'
condition: null
action:
  - choose:
      - conditions:
          - condition: trigger
            id: petra
          - condition: template
            value_template: '{{ states(''sensor.petra_wifi_connection'')[0:9] != "Our_WIFI_SSID" }} '
        sequence:
          - service: esphome.ns_kitchen_play_rtttl
            data:
              song_str: siren:d=25,o=10,b=150:d,e,d,e,d,e
          - service: switch.turn_on
            target:
              entity_id: switch.porttelefon
            data: {}

So the condition is that if we are home, wifi connected, then it should not open the door again.
I can make sure it only triggers if the wifi state is on. But it would be nice if I could “force” on the wifi to make sure it doesn’t happen.

Is there any command that you can enable Wifi on the phone?

If it’s an android phone there is a setting to pretty much do that.

Network & Internet > Wi-Fi > Wi-Fi preferences > Toggle on Turn on Wi-Fi automatically

I prefer manual control. But thanks.

This used to be possible before Android 8 I believe but Google has since removed this ability from apps. I dont know if Tasker can still perform this functionality but that would be the only other option if it works.

In related news it seems in the upcoming Android 13 update the same thing is about to happen to Bluetooth :frowning:

1 Like

Don’t Google understand we buy Android because we don’t want the locked crap Apple makes.
Now Google is locking down their phones the same way :rage:

2 Likes

Tasker can still do it. I have an unrooted pixel 3 and I made my own notification command for this. I send a broadcast intent via the HA app that tasker listens for and then toggles the WiFi.

Although I am a bit confused by your setup. Isn’t there a risk of things not working if your phone connects to wifi while still just outside?

Just a thought, another alternative could be an input boolean. Set it off when everyone leaves the house, set it on when you’ve returned an opened the door. Then only open the door when your automation triggers and the input boolean is off.

1 Like

Yes there is.
It happens, but very rarely since we live on the second floor.

The idea is that it should open the door for us even if it’s only one of us going out with the trash for example. As I understand your automation it would work as a group of people, one home then the state is home/on.

I will have a look at the Tasker solution.
But I would have to install this on her phone.
Another solution I thought of was when she arrives home and wifi_state is not on, hammer with TTS messages every 5 seconds in every other speaker.