Ping sensor not working as I thought in automation

I have this automation that uses the Pi in the car to unlock the car when my phone comes within distance (by ESPresense). But it’s not supposed to do that when the car’s parked by the house (since it picks up on the phone when I’m inside the living room, close to that wall). Then only the beacon on the keys is supposed to unlock it, in another automation. Still, it reacts to my phone:

- id: '134629046235321422812'
  alias: Mastiff's phone comes to the car
  description: Unlock the car when Mastiff's phone comes within range
    condition: not
      - condition: state
        entity_id: sensor.mastiff_lock
        state: "0"
      - condition: state
        entity_id: binary_sensor.hjemme
        state: "off"
      entity_id: lock.mastiff_lock
    service: lock.unlock
    platform: state
    entity_id: sensor.mastiff
    from: 'not_home'

The way I define if the car is home is if the OpenWRT box (another Pi in the car) has connected to the house network (which is prioritized over the LTE modem connected to it). It pings (the pfSense box in the house), and sets the Ping sensor to “At home”, or “Hjemme” in Norwegian. As far as I have found out the sensor should show “on” when the ping works and “off” when it doesn’t. Which means that with a “not” condition the state of the binary sensor should be set to “off”. But still it won’t behave. Any idea what I’m doing wrong here?

It’s not obvious which entity is what in your automation.

Which is your phone and which is the openwrt between sensor.mastiff and binary_sensor.hjemme
I assume sensor.mastiff_lock is the lock status of the car? Does “0” means opened or closed?

For the car: 0 means unlocked, so it should not run the automation (try to unlock) if the car is already unlocked.
sensor.mastiff is my phone. I define my whereabouts from my phone, that almost never leaves my pocket or my hand… :wink:
binary_sensor.hjemme means “binary_sensor.home”, so that’s the ping sensor that designates if the car is at home or not at home.

Logical error in user’s brain. Of course when it’s “not” it has to be that ping is not ON, not OFF. Sorry…