KeyMaster Z-Wave lock manager and scheduler

You should have left the id in so you can use the automation trace to see why it doesn’t seem to work.
Full disclosure, I’ve never used logbook.log before @tykeal may have better insight into that.

Here’s an automation I just slapped together using yours as a base

alias: 0 - Lock Logging
description: ''
trigger:
  - platform: event
    event_type: keymaster_lock_state_changed
    variables:
      sn: >-
        {%- if trigger.event.data.code_slot_name == "" -%} Manual {%-
        else -%}{{ trigger.event.data.code_slot_name }}{%- endif -%}
condition: []
action:
  - service: logbook.log
    data:
      name: '{{ trigger.event.data.lockname }}'
      entity_id: '{{ trigger.event.data.entity_id }}'
      message: >-
        name "{{ sn }}" state "{{
        trigger.event.data.state }}" the door
mode: single

I double quoted the state and slot name information in the log message to make it stand out for you better. This also does an interpretation to know if it was a manual event or one executed by a named code slot. It’s not super intelligent enough to know if the event was due to an automated locking or not (the lock I’m testing on is set in hardware to relock after 30 seconds as it isn’t a deadbolt)

Here’s what it looks like in my logbook with the lock I was testing

All of the lines that have “0 - Lock Logging” are from this automation. All of the lines that have “keymaster_office_door User Notifications” in them are coming from my keymaster_office_door_manual_notify script that does logging as well as sending a notification to my notification group, which consists of my phone, email, and desktop computer.

@firstof9 an ID isn’t needed for tracing if entering the automation by the UI. The reason is that one get’s automatically assigned to it by the UI, you just don’t see it in the editor. If you specifically specify one, then you would see it :wink:

Maybe you’re probably doing too much with file grown automations to have realized that :joy:

I’m not a fan of the UI for doing my automations :wink:

1 Like

@firstof9 and @tykeal

You guys are so next level compared to me when it comes to knowledge of HA. I feel like I’m drinking a lake through a straw every time I go to do anything in HA. It’s like my wants far outweigh my abilities at this point with HA.

@firstof9
I swear, think I’m doing something smart and it’s dumbbbbb. When I get home this evening, I’ll post a new one in totality. I’ll be honest, I wouldn’t know how to track anything down even if I get ahold of the ID for you/ us.

@wtstreetglow that’s just because we’ve been using HA longer than you. It will come with time.

I’ve personally been dealing with home automation for nearly 5 years now. First with Samsung SmartThings and now with Home Assistant. I felt a bit out of water myself at first, but I’m also a systems administrator and programmer by trade so it admittedly comes a little easier to me as I have a good idea of the programming concepts behind what is happening and what I’m trying to do.

It just takes practice :smiley:

Thank you for doing this @tykeal. It is very helpful, I will give this one a go this evening when I get home and see if I can get some results popping out into the log. I was unsuccessful this morning before I left for work. (spoken about in screenshot/ post from earlier today)

Thank you for this, I go cross-eyed looking in the logs sometimes. haha.

This is great also. I am almost exclusively after code usages (unlocks). My end goal will be to get this information into a “notify.notify” (push notification) with something of the nature (based on the code that was used):

“Weston unlocked the front door”

(entity “front_door” (name: “front door”) being the door that the entity “front_door_lock” (name: “front door lock”) is associated to)

I understand, I’m just thankful that you all have helped me this far. I feel like such a bother sometimes. I see the power of HA, but you almost have to be really talented with scripting/ coding to do the really useful stuff.

This is where I would like to go (once the actual “content” is working properly), is this something you could safely share? I really like the idea of the notification group and getting what we are working on incorporated to notifications (most important would be the push, but I currently do some TV notifications on an Android TV and a few others), but if I can’t figure out how to get the actual data/ “content” that is getting pushed to look proper than its all for nothing. haha.

@wtstreetglow I’ll DM you with some of the information. First because it’s not fully relevant to the topic thread, and second because we’re getting more into customization territory outside of KeyMaster :wink:

For those that come here and read all of this, the core of adding the notification bits is just adding another action step to send to the notify service of choice ala:

service: notify.tykes_notices
data:
  title: '{{ title }}'
  message: '{{ message }}'
  data:
    tag: '{{ message }}'

tykes_notices in my case is a notification group. That snippet is from one of my keymaster_[lockname]_manual_notify scripts and would be different given our discussion about using writing something against the event.

Ahh, I sure hope. Maybe I’ll be able to help some people at some point rather than whining for help myself all the time. haha.

Yeah, I was on smartthings for a while, but never got into webcore side so I really only touched the “mass appeal” stuff- that in itself took away alot of the smarts smartthings at the same time. HA is so ridiculously powerful but with that comes a massive learning curve to really get the benefit out of it. You can really make a mess out of things if you try hard enough :slight_smile:

Haha, completely unfair. I’ve got no chance, I’m an engineer by trade but just don’t ask me how I did in my programming classes and everything will be fine. This is all bringing back flashbacks.

Thank you so much!

I completely agree, I apologize for that. I forgot this wasn’t a post I started.

Suddenly out of the blue my Schlage be469 Lock is locking and unlocking itself. Both of the input_booleans for “Autolock” are set to off and I am having some trouble trying to nail down why this is occurring. Any ideas why suddenly this is happening or where I might look for troubleshooting? I assume it had something to do with the autolock feature but maybe not??

The Logbook should give you some ideas:

Actually that didn’t but I think I may have finally found it. My Life360 app has been having some connection issues and is quickly moving from ‘home’ to ‘away’. Turns out I have that in a group and the group is tied to an automation to lock and unlock the door. Those blips were just enough to trigger the lock automation. I kept looking at the keymaster automation but it wasn’t part of that.

Now I wonder why those locks and unlocks aren’t being shown in the logbook.

Thanks for the suggestion.

@PrayerfulDrop thank you for this post. I also use nodered and was hoping you can point me in the right direction. I don’t need anything a fancy as yours but just want to announce who use the code on my echo speakers. I noticed you use pushover but can you help me get this to work without pushover? I already have notifications that would announce when the door is open but want to add the user that unlocks. Any help would be greatly appreciated.

[{"id":"b446b7cab151f832","type":"api-call-service","z":"012527a548a30624","name":"Notify via Mancave, Living Room Echo","server":"6821cdda.fbbcd4","version":5,"debugenabled":false,"domain":"notify","service":"alexa_media","areaId":[],"deviceId":[],"entityId":[],"data":"{\t   \"message\": payload.new_state.attributes.friendly_name & \" opened\",\t   \"data\": {\t       \"type\": \"tts\"\t    },\t   \"target\": [\t       \"media_player.man_cave_echo\",\t       \"media_player.living_room\",\t       \"media_player.master_bedroom_echo\"\t   ]\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":330,"y":300,"wires":[[]]},{"id":"6821cdda.fbbcd4","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m"}]

I tried using some of your nodered script to handle this, but obviously didn’t work.

[{"id":"8f4034fbeb070758","type":"api-call-service","z":"96f2d1e869eeacad","name":"Notify via Mancave, Living Room Echo","server":"6821cdda.fbbcd4","version":5,"debugenabled":false,"domain":"notify","service":"alexa_media","areaId":[],"deviceId":[],"entityId":[],"data":"{\t   \"message\": payload.new_state.attributes.friendly_name & \" opened\",\t   \"data\": {\t       \"type\": \"tts\"\t    },\t   \"target\": [\t       \"media_player.man_cave_echo\",\t       \"media_player.living_room\",\t       \"media_player.master_bedroom_echo\"\t   ]\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":650,"y":320,"wires":[[]]},{"id":"6821cdda.fbbcd4","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m"}]

Could someone here tell me what the purpose of theinput boolean below is. It is in the file titled “…keymaster_common.yaml” and shows up at the top of the lovelace card. It doesn’t seem to be tied to anything??

  front_door_garageacess_notifications:
    name: front_door Garage Notifications

Hello tykeal, I got all of my stuff working again and have started back on trying to implement a few of these things.

Does this piece of code go into the script called “…_manual_notify” for the door in question but then on the entity id, I can use something other than the keymaster entity-- I believe that is why you are showing me I can direct this text output to another entity?

Additionally, I have the code below implemented now and am seeing the results in the log. Could you possibly show me an example of how I can customize the notifications that are coming to my notify.notify service? (Question is expanded on below the code post)

My slots are named after people’s names, for instance slot 2, Weston. Slot 3 Clarice, etc. I would really only care to have notifications about Unlock events. I noticed the unlock events come through as “action_text”: “Keypad unlock operation”.

I explored using the standard “…manual_notify” script but I realized I wanted something a bit more customizable where I could set the title and message to have variables inside of it to where it would automatically switch to the proper door name etc.-- maybe this would be too difficult and I have no clue how to do it anyway :frowning:

In a perfect world, it would be nice if a single automation could handle all 3 doors. My “locknames” are “front_door”, “back_door”, and “garage_entry”. Lock Entity IDs of “lock.front_door_lock”, “lock.back_door_lock”, “lock.garage_entry_door_lock”

"“Weston unlocked the Front Door” is what I would be going for.

I’ll be honest, i don’t even know where to begin on this, I feel like all of the pieces are here

Below is an example of my results from the event review:

1 Like

I have your example working. (It was working originally, I just didn’t realize, I was supposed to be looking in the log for the lock entity)–> I’m so new with all of this and I was looking in all kinds of stupid/ wrong places.

1 Like

Hey there! Yes my NodeRed is a bit complicated but I needed the announcement to cover everyone who was coming home. If you are just looking to announce when the keypad is unlocked by a pin you could use the event to watch for the unlock and then send a modified message using the pin event accordingly. Open the function I created and look at the top where the keypad name is captured.

Honestly I wasn’t sure myself, I’ve never used the logbook.log service.

I follow. Very appreciative of your alls help. Everything is working great!

1 Like