Automation based on phones wifi connection

I am trying to get an automation where lights turn on when on my phone connects to wifi. I have my router added as an integration. When I create the automation based on the state I cannot seem to get it to work.

Here is the yaml code:

Try using enter/leave zone home as a trigger.

I added that trigger and will see how it works tomorrow once I come back home.

That trigger still didn’t make the automation run after leaving and returning home. Any other tips?

It should work unless. Check if your mob is reporting entering leaving zone. In automation i prefer using building block and then choose trigger. Of course you have to add trigger id to do it. Something like this:

description: ""
trigger:
  - platform: zone
    entity_id: person.daniel
    zone: zone.home
    event: leave
    id: Leave home
  - platform: zone
    entity_id: person.daniel
    zone: zone.home
    event: enter
    id: Arrive home
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - Leave home
        sequence:
          - metadata: {}
            data: {}
            action: alarm_control_panel.alarm_arm_away
            target:
              entity_id: alarm_control_panel.x824_house_entrance_2
      - conditions:
          - condition: trigger
            id:
              - Arrive home
        sequence:
          - metadata: {}
            data: {}
            action: alarm_control_panel.alarm_disarm
            target:
              entity_id: alarm_control_panel.x824_house_entrance_2
mode: single

I use this to turn on or off alarm. It works with out any issue. The same concept is for your automation.

I know this is a year late but for anyone else that may want to use this type of automation triggered by wifi name, make sure you have added the wifi as a sensor from your phones home assistant app by going to: settings → companion app → sensors and activate it

after that the code is simple:


trigger: state
entity_id:
  - sensor.sm_s918b_wi_fi_connection  #your sensor name
to: your_wifi_name 
id: wifi #trigger id that could be used as condition if needed
condition: []
actions:
  - action: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id:
        - switch.light_hallway_1
        - switch.light_hallway_2
mode: single

Here is an example of my automation for when i connect to wifi and the gps has not had time to update me as home before i enter, or when my status changes to zone.home

alias: Turn on lights when enter home
description: >-
  Turns on hallway lamps when phone connects to Johan WiFi OR enters home
  zone.
triggers:
  - entity_id: person.johan
    zone: zone.home
    event: enter
    trigger: zone
    id: gps
  - trigger: state
    entity_id:
      - sensor.sm_s918b_wi_fi_connection
    to: Johan_Aoi
    id: wifi
conditions:
  - condition: or
    conditions:
      - condition: and
        conditions:
          - condition: trigger
            id:
              - wifi
          - condition: not
            conditions:
              - condition: state
                entity_id: person.johan
                state: home
            enabled: true
      - condition: trigger
        id:
          - gps
actions:
  - action: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id:
        - switch.light_hallway_1
        - switch.light_hallway_2
trigger_variables:
  wifi_trigger: 0
mode: single

Here’s a tip for you. You can set your companion app to go to high accuracy mode once you enter your home zone.

PS - your OR condition doesn’t seem to do anything. You only have 1 condition under that block and it’s set to AND. You should be able to safely remove that, unless I’m missing something obvious.

my or condition is for the diffrent trigger id conditions, so it can be triggered by wifi which have the condition of my person state to be anything but home as i have different zones that could be set. So if it has just been triggered by the gps trigger that changed my person.johan state to home then it will not be triggered again by the wifi trigger. Also meaning if i am home and turn off my wifi and then on again it will not trigger.

And the other trigger is my gps which have no conditions, but it needs to have the or block to bypass the other conditions as the trigger and conditions contradicts each other and will not be able to pass otherwise