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