Locked/Unlocked status becomes Open/Closed in Google Assistant

I have a NodeMCU with an ESPHome program monitoring push buttons. One of the buttons is activated when the lock is operated. This comes through Home Assistant fine (ESPHome program has the device_class set to ‘lock’) and shows in the entity as locked/unlocked (complete with the padlock icon). However, I have to ask Google Assistant “is the workshop door closed”. “Is the workshop door locked?” gives me the generic “Sorry, I can’t help you with that”.
Is this something I can change within the settings?

hello
i have a sonoff for lock a door
in my configuration.yaml i did:

lock:
  - platform: template
    name: thefuckingdoor
    value_template: "{{ is_state('switch.sonoff', 'on') }}"
    lock:
      service: switch.turn_on
      target:
        entity_id: switch.sonoff
    unlock:
      service: switch.turn_off
      target:
        entity_id: switch.sonoff
google_assistant:
  project_id: home-ass-xxxxxx
  service_account: !include 'Home Ass-cxxxxxxx.json'
  exposed_domains:
    - lock

and google respond me as you wish.
hope it can help you

Tom,

Thank you for that, however that appears you have a sonoff as a door lock. I want to read the status of a switch (that comes through ESPHome) that in Home Assistant shows as a lock (locked/unlocked) but appears in Google Assistant as a door (open/closed). How could your code be modified to give Google the correct info?

I must note that Google Assistant is connected via Nabu Casa.

The icon in HA does not matter. To have a “lock/unlock” status in GA, the entity should actually be a lock.

Bottom-line: do as tomdudu38 suggested, and ask “Is the thefuckingdoor door locked?” (you can “rename” entities in the google_assistant:configuration, though :wink: )

maybe it should look like this:

lock:
  - platform: template
    name: thedummyfuckingdoor
    value_template: "{{ states('sensor.thedoorfromesp') }}"
    lock:
      service: switch.turn_on
      target:
        entity_id: switch.thedoorfromesp
    unlock:
      service: switch.turn_off
      target:
        entity_id: switch.thedoorfromesp
google_assistant:
  blablabla.....

Sorry for the late response - didn’t get any time to look at it!

Does this require the manual Google Assistant?

no, but
you will create a new door named " thedummyfuckingdoor" in my code.
and you will have your door from esp.
that mean two doors.
with manual config of google you can show the door you want or not.
And it’s better to configure your projet id and servcie account to synchronize all devices

I’ve added the template code as follows:

lock:
  - platform: template
    name: Workshop Door
    value_template: "{{ states('binary_sensor.lock') }}"
    lock:
      service: switch.turn_on
      target:
        entity_id: binary_sensor.lock
    unlock:
      service: switch.turn_off
      target:
        entity_id: binary_sensor.lock

and exposed the entity to Google assistant. However, the exposed entity stays in an unlocked state. I reversed the on/off statements in the template, saved and rebooted but it remains the same. I’ll have another go at it tomorrow after sleep!

try :

optimistic: true

Hi guys, I have a tiny problem, and I am not sure if it even can be solved. I have a electrolock controlled with switch device, and also a reed switch so I know the actual state of the door.

I would like the google to differentiate between door locked/unlocked and closed/opened - as door can be unlocked but still closed for example.

Right now my config is:

# Cover.door giving me door status from reed switch - open/closed
cover:
  - platform: template
    covers:
      front_door:
        friendly_name: "Front door"
        device_class: door
        unique_id: "front_door"
        open_cover:
        close_cover:
        value_template: "{{is_state('binary_sensor.front_door', 'on')}}"
# Actual lock locking and unlocking the door
lock:
  - platform: template
    name: Front door
    unique_id: lock_front_door
    value_template: "{{ is_state('switch.1000d8feca', 'off') }}"
    lock:
      - condition: state
        entity_id: switch.1000d8feca
        state: "on"
      - service: switch.turn_off
        target:
          entity_id: switch.1000d8feca
    unlock:
      - condition: state
        entity_id: switch.1000d8feca
        state: "off"
      - service: switch.turn_on
        target:
          entity_id: switch.1000d8feca
# Google export
google_assistant:
  secure_devices_pin: ";)"
  project_id: ha-integration-e356
  service_account: !include /ssl/ha-integration-e356-1a536463645dd.json
  report_state: true
  expose_by_default: false
  entity_config:
    cover.front_door:
      name: "Front door"
    lock.front_door:
      name: "Front door"

Query if the front door is open - google responds that it’s locked/unlocked but not considering the sensor (If I command to unlock, it attempts unlocking using empty action and then claims it’s unlocked permanently(. It’s also unable to actually unlock it using the lock.

If I rename the lock for example - then locking and unlocking the lock works, and same with real status of the door (opened and closed) from the reed switch sensor, google is then suddenly aware of that.

Can you advise how (and if ) I can combine such setup, reed switch with lock to have the door lockable/unlockable and open/closed? (i.e. unlocked but still closed - make google notice these are different states)
I can workaround it by renaming the lock - then