#Door lock status check and lock door automation not meeting

75 messages · Page 1 of 1 (latest)

turbid path
#

I'm doing my first automation. All I want is check the door sensor and the lock, it's the door isn't locked or the door is open notify me. If the door is closed and it's unlocked, lock the door and notify me.

But when I run traces I get this. which makes me think it's just bypassing the whole automation.
I has some issues with the states being case sensitive and Traces called that out and fixed it but I don't know

#

`id: '12345'
alias: Front Door Security Check
trigger:

  • platform: time
    at: '21:45:00'
    condition: []
    action:
  • choose:
    • conditions:
      • condition: state
        entity_id: binary_sensor.door_switch_01_opening
        state: Open
      • condition: state
        entity_id: lock.kwikset_smartcode_convert_gen1_door_lock
        state: unlocked
        sequence:
      • data:
        message: >-
        The front door is open, and the lock is unlocked. Please close
        the door.
        action: notify.mobile_app_phreak_s21
    • conditions:
      • condition: state
        entity_id: binary_sensor.door_switch_01_opening
        state: Closed
      • condition: state
        entity_id: lock.kwikset_smartcode_convert_gen1_door_lock
        state: unlocked
        sequence:
      • data:
        entity_id: lock.kwikset_smartcode_convert_gen1_door_lock
        action: lock.lock
      • data:
        message: >-
        The front door was unlocked, but it's now locked. The front door
        is secure.
        action: notify.mobile_app_phreak_s21
    • conditions:
      • condition: state
        entity_id: binary_sensor.door_switch_01_opening
        state: Closed
      • condition: state
        entity_id: lock.kwikset_smartcode_convert_gen1_door_lock
        state: locked
        sequence:
      • data:
        message: The front door is locked and secure.
        action: notify.mobile_app_phreak_s21
        mode: single`
robust dove
#

Yes it is bypassing everything because none of the conditions in any of the choose options are met. Besides the error states of unknown and unavailable, a binary sensor can only be on or off. The front end will translate these states into something more user-friendly depending on the language used and the device_class of the sensor. If you use the UI to create the automation, it should allow you to select the translated state (e.g. Open) but if you look at the yaml you will see the code actually shows e.g. state: "on"

Note that in yaml the words on and off have special meaning and therefore they must be quoted.

turbid path
#

Ok i'll try quotes on each of the states

robust dove
#

Hopefully you didn’t miss the part of my message where I said the only correct states are on and off

turbid path
#

The Gui has drop down options for open and closed

robust dove
#

You might want to re-read what I wrote

turbid path
#

Hmm in the GUI the entity is just 'Door switch 01' and the state is either open or closed. But Yaml it's "on" or "off" I've rebooted several times. How would you suggest to clear it up?

robust dove
#

That is the expected and correct behavior. UI should allow you to choose open or closed, and that will create the yaml code off of or on. The problem you had with your automation is that your yaml used open and closed, which is incorrect.

turbid path
#

interesting. I'll note that. What do you suggest I check next

robust dove
#

If you go to developer tools -> states, you can look up any entity and see what the true state is. That is the state that needs to match your yaml code.

#

Does your automation still not work after changing the states in the yaml code from Closed to "off"?

turbid path
#

HMM there isn't one for closed

robust dove
#

Well if you go close the door you will see it change.

#

Here’s a list of how on and off will be displayed in the front end for every type of binary sensor:

turbid path
#

just verified that "on" = open door and "off" = closed door

robust dove
#

Yes, that link will tell you that also

#

Or you can use the automation GUI and select Open and then switch over to YAML mode and see what code it created

turbid path
#

in the GUI the state are
Open
Closed
Unavailable
Unknown

In Yaml
'on'
'off'

robust dove
#

Yes

turbid path
#

I just don't understand what i'm missing

robust dove
#

Now that you’ve got the states corrected, and it still isn’t working, can you post the trace to a code share site?

hard cairnBOT
#

Please use a code share site to share code or logs, for example:

Please don't use Pastebin, since it can randomly add spaces to the main view. Please also don't share text as images since it makes it harder for people to help you. Remember that others may have colour blindness, impaired vision, etc.

turbid path
#

how do I do a trace

#

?

robust dove
#

While in that view, there should be three vertical dots in the upper right that you can click and get a menu. One of the options is “download trace”

turbid path
robust dove
#

That is saying your door was open and the lock was locked. And you don’t have any conditions that match that scenario

turbid path
#

hmm that can't be, the door has been unlocked during all this testing.

robust dove
#

What does it show in developer tools-> states

turbid path
#

WEIRD!!!

#

this is on my overview

#

the door is locked. but the enity says it's unlocked.

#

I never noticed that.

robust dove
#

So both your overview and the dev tools agree it’s unlocked? But when the automation was ran for the trace you posted, it was locked. And you’re saying it is physically locked? I’m confused…

turbid path
#

Yea me too.

#

ok...

robust dove
#

And just to make sure the image of the overview isn’t confusing anything: the state of the lock is shown by the icon. The text is an action you can click if you want to perform that action. So the overview image you posted shows the lock in an unlocked state

turbid path
#

So
the Icon on the overview says locked
the words in the overview say unlocked
the Entity states says locked
the physical door is unlocked

robust dove
#

The words on the overview don’t end with “-ed”

turbid path
#

correct

robust dove
#

The words on the overview are not the status

turbid path
#

the words on the overview is the only one that show the actual correct status

robust dove
#

Does everything update when you physically change the lock state?

turbid path
#

I can click the word 'UNLOCK' on the overview dashboard and it will change the correct state

robust dove
#

If things are actually working correctly, you would see on the overview:

  • When the lock is physically locked: an icon of a locked lock, and the word “unlock” which you can click to unlock the lock
  • When the lock is physically unlocked: an icon of an unlocked lock, and the word “lock” which you can click to lock the lock
#

It sounds like the state of the lock is opposite between what HA thinks compared to the physical lock

turbid path
#

correct

#

it's a zigbee lock on ZHA

robust dove
#

And you confirmed it is changing? So when you physically lock it, dev tools will change to unlocked, and then when you physically unlock it dev tools will then show locked?

turbid path
#

correct

robust dove
#

Ok, so there is definitely something wrong with how the device is set up in ZHA.

turbid path
#

when I click the work, it shows the correct state. the Icon is opposite. weather I click the word UNLOCK or physically lock the bolt

robust dove
#

You’ll want to head over to #1284966617670881350 and make a post stating the model of lock and that you’re using ZHA and the status of the lock is updating but the state is always opposite of reality

#

I don’t use ZHA otherwise I’d continue to try to help you

#

At least your automation is correct now

turbid path
#

hmm do you think we can try to change the logic of the automation to see if the actual automation works

robust dove
#

Sure, you can change all the “locked” to “unlocked” and vice-versa

turbid path
#

yaml or gui?

robust dove
#

Either one, doesn’t matter

turbid path
#

so really all I'm doing is flipping the door switch 01's

robust dove
#

You want to change the lock entity states, not the door switch

turbid path
#

I changed it in the yaml and I'm rebooting now

robust dove
#

You don’t need to reboot after an automation change. It doesn’t hurt, but it’s not necessary

turbid path
#

good to know

robust dove
#

If it’s not an automation that is managed by the UI, you can go to developer tools-> yaml and scroll down to automations and click it. That will reload all your automations. But if it’s managed by the UI you don’t even need to do that.

turbid path
#

first time see that

robust dove
#

🎉

turbid path
#

but I didn't get a message from HA.

#

on my phone

robust dove
#

Edit the automation in the UI, find that action, then click the 3 dots next to that action and select “run”

#

For further debugging, go to developer tools-> actions, make sure you are in UI mode (button will be at the bottom if you are in YAML mode and need to switch). Then select or type in the action notify.mobile_app_phreak_s21 and type in a message to send and click “perform action”. If you get a notification on your phone, then switch to YAML mode on that page and see what the code looks like. It should be identical in your automation.

#

I’m signing off, if you still have questions hopefully someone else will step in