KeyMaster Z-Wave lock manager and scheduler

Well what is complex scheduling? In KeyMaster a slot is either active or inactive based upon its slots settings and the environment. Like when the clock hits midnight, the date changes and a slot’s status may change because the environment changed. Heck, we could add a setting for the current temperature to be between 60 and 70 degrees if we wanted too. It’s immaterial though, as I think we have virtually every option one could need, and then some. Yes, one could create an external scheduling service and add/remove codes using this new proposed webhook. Both methods would work.

Manual interventions. Cancellations. Various back end anomalies. Multiple room bookings.
Booking today for yesterday. (Because they are made after midnight for immediate accommodation)
Here’s a fun one:
It’s easy to assume a booking starts (for example) 3pm and ends at 11am the next day, but when a guest decides to stay longer and books the room again for tomorrow, you’re probably going to lock them out of the room unexpectedly.

All I’m saying is that people are already using an external scheduling service. That’s what booking engines are. For example, the one I use sources reservations from 400 different channels, each with their own little quirks. (A single channel would be something like hotels.com, .or airbnb).

These outside systems know what the current state of all the doors should be… maybe. Lynn has an iCal feed. How this feed translates to door codes must be a custom thing because I’m pretty sure there’s no iCal standard for it. The booking engine I use only communicates in json feeds, and I have to impute what the codes are from there.

Long story short, translating any of this data into the scheduling variables inside keymaster seems like a waste of time when we can already easily set the codes with standard home assistant API calls with the existing variables. Calling the input_* services for the keymaster entities is trivial now as is and works fine.

I think its great if you want to add that in a more generalized way, but if it comes with a bunch of new entities it would compound the only complaint people ever have.

Either way, its your software, and its good software, do what you want. To me the kind of things the tiny minority of us are talking about seem way outside the scope of what I’d want to deal with.

Whie this is working great for my simple needs of ocasionally setting up a guest pin, I am thinking about removing it due to the amount of clutter it left in my automations and scriptds UI. Before I do is there a way to hide them?

I can only speculate how booking systems operate in conjunction with keycard systems. If they have the ability to activate/invalidate a specific keycard (or in our case a lock/slot combination) when a time-range is entered/exited then you wouldn’t need any of KeyMaster’s scheduling features. I suspect the booking system also generates new keycards, so it should also be responsible for generating lock/slot/PIN values.

So it (the booking system) might generate a “key” for room 1, slot 3 (R1S3) with PIN 1776 at the time of booking. And then when the occupancy period starts it enables R1S3. Likewise it would be responsible for disabling R1S3. If the booking system is sophisticated enough to trigger on start/end occupancy events, then by all means harness that.

I agree that the most useful feature to add for many folks would be an option for removal of some of the scheduling functions. For instance. I got the date range advanced schedule extended to support start and stop times (it didn’t originally) because I need it for my Rental Control integration that I’m working on. I don’t, however need all the custom weekdays schedules (at least for my use case). Having an option to have the advanced scheduling minus the custom weekdays would definitely reduce the number of entities in my instance(s)

Again, not in Keymaster, that’s why I’m working on a separate integration to drive getting codes into Keymaster without Keymaster having to worry about the logic of dealing with a rental and the silly things people do around extending their stay.

All of the systems I’ve dealt with that provide an iCal provide the following information (at a minimum): reservation identifier, start and end day (not even check-in / check-out time). Several of the ones I’ve gotten access to (thanks to beta testers) provide the last 4 digits of a phone number as well in the event description (which is useful for setting lock codes), otherwise we’ll be computing a lock code based up start / stop dates.

I don’t have access to any booking systems that provide only a JSON feed but I’m willing to work on that in the rental control system as well if people want to work with me (see the above announcement link which will get you to the GitHub repository where issues and PRs can be made).

Leave Keymaster to doing what it does well, managing locks. Move advanced meta-management logic elsewhere. This makes everything plugable, and tickles my fancy of the *nix way of development :wink:

@tykeal

Thanks for the consideration.

All of our units are in different locations. I’d have to run individual HA networks installs in each place. I can’t imaging any other solution. So really what I’d be talking about is an install of KM that controls 1 lock on each HA host.

I may be a naive but I think there could be a fairly simple solution. Keep in mind this is being said by someone that isn’t a programmer, but I think it’s possible to come up with something without getting into the weeds on many of different external platforms/apps.

I use a channel manager (Guesty) plus AirBnB, VRBO, Bookings.com +. That said, I have a master calendar. That master calendar can be exported. (.ics for AirBnb, I’m not sure what for Guesty but I’d guess the same or similar)

In both cases, the calendars have the dates of the reservation, and the last 4 digits of the guest’s phone number (among other things). In my situation (and I think most reservations in this business) the check-in and check-out time is the same for every reservation. I’d use the dates, a default time (different for check-in and check-out), and then set the code to the last 4 digits of the guest’s phone number. Since it’s predictable, it’s easy to use the platform or channel manager to auto-generate a message for the guest the day before check-in with the access code.

Early check-in and late check-out could (and it our case would) be managed manually. We have to do that anyway because it requires coordination with the cleaning crews to ensure the unit is ready.

If you and anyone on your team does want to take this on, feel free to DM me.

+1 It is really a bother when I have to interact with any set of menus or views that has all these devices visible It would be great if all this scheduling stuff could be removed as entities or at least made as device attributes so the number of entities would be greatly reduced. I would venture that most people don’t need anywhere near this number of scheduling options, and if there are already booking systems that deal with it, maybe get rid of these functions and streamline (since that’s one goal for 2022 in HA) the entities created.

Why is that an objective? An RPI should be powerful enough that they aren’t causing any problems. Are you experiencing otherwise?

Oh, my RPi isn’t having any issues… I am when I look at the entities and automations lists! So many of the keymaster entities don’t prefix keymaster into their name so they’re mixed all over the place with my other entities and automations. Given that there isn’t a “not” filter it can make it really difficult to look through what’s in my system when I’m trying to do certain things.

Which is one of the things that folks really seem to be complaining about. The over abundance of entities and automations that for folks just using keymaster on their personal home may not need!

Personally, if I could select an option to not include the weekday advanced scheduling from generating I would. I would keep the date range scheduling, but I could see some folks not wanting even that.

Secondly, I would probably do some work to combine all the various automations. For instance there is a synchronize_code_slot_<door_name>_<code_slot_number> and a turn_on_access_limit_<door_name>_code_slot_number> for every code slot defined. The thing is, that in both of these cases it looks like something that is conceivable to bring down to a single automation that uses the triggering entity name to drive changes. This is already being done with many of the basic lock automations (changes codes, sending notifications, etc)

I should probably just go open an enhancement request about this…

I can give an example of where it causes problems.
When creating a new lovelace dashboard the default is to add every entity. Each and every keymaster variable shows up and makes it almost impossible to load.
It also makes the history tab on the ios phone app completely unloadable.
My rough guess is the tipping point for this is probably only five keymaster locks with with five codes each.

@FutureTense - Thank you for making Keymaster available to all of us! I use it for my 3 Schlage locks and it has been rock solid. While I admit I did not read the many posts above, I did see a few asking for the entities and automations / etc to be reduced and I have to +1 that as the amount of stuff Keymaster adds to HA is overwhelming and I do not need the majority of it. I would rather have a simple lock management system and a way to do all the scheduling, enable/disable stuff externally via Node Red. I’m not complaining though, as I appreciate your work, just sharing my point of view.

On another note, you likely already know this, but there are System log entries pointing to defaults missing on time templates related to Keymaster. Is that on your radar? They will likely stop working with the next release.

1 Like

You need to regenerate your templates to get this fixed. Just open up each of your lock configuration definitions via the integrations menu and hit save. That should resolve this issue.

1 Like

Here’s random thought:
With all this talk of iCal, and most of the extraneous entities being related to scheduling, replacing all the current scheduling variables with an iCal feed would solve everybody’s problem.

That’s what I’m working on with my integration. It depends on the scheduling functionality that exists in keymaster now. Trying to move everything that currently exists for scheduling to using iCal is just shifting the problem somewhere it doesn’t actually belong.

The current design of Keymaster is what is making it possible to do more complex scheduling to something that doesn’t then also have to deal with the vagaries of having to deal with getting codes into and out of locks

I’ll add that I presently use the scheduling functionality that presently exists on my home itself for when I have guests. There’s no iCal associated with something like that and you would end up creating a very different problem by pulling the current scheduling features out completely

SOLVED: Well I figured it out right after posting. When I first creating the Script in the UI I left the Entity ID field blank, which resulted in a numeric script name (vs the script alias).

I’ve successfully set up 3 locks in with keymaster but I’m not having any luck getting notifications working.

I have this script setup:

alias: keymaster_basment_patio_door_lock_manual_notify
mode: parallel
sequence:
  - service: notify.mobile_app_eric_s_phone
    data:
      title: '{{ title }}'
      message: '{{ message }}'
max: 10

I’ve verified that works, but when I trigger that lock I see in the logs:

2022-02-12 18:35:31 INFO (MainThread) [homeassistant.components.automation.keymaster_basment_patio_door_lock_locked] keymaster_basment_patio_door_lock_locked: Running automation actions
2022-02-12 18:35:31 INFO (MainThread) [homeassistant.components.automation.keymaster_basment_patio_door_lock_locked] keymaster_basment_patio_door_lock_locked: Executing step call service
2022-02-12 18:35:31 INFO (MainThread) [homeassistant.components.automation.keymaster_turn_off_retry_basment_patio_door_lock] keymaster_turn_off_retry_basment_patio_door_lock: Running automation actions
2022-02-12 18:35:31 INFO (MainThread) [homeassistant.components.automation.keymaster_turn_off_retry_basment_patio_door_lock] keymaster_turn_off_retry_basment_patio_door_lock: Executing step call service
2022-02-12 18:35:31 INFO (MainThread) [homeassistant.components.automation.keymaster_basment_patio_door_lock_lock_notifications] keymaster_basment_patio_door_lock Lock Notifications: Running automation actions
2022-02-12 18:35:31 INFO (MainThread) [homeassistant.components.automation.keymaster_basment_patio_door_lock_lock_notifications] keymaster_basment_patio_door_lock Lock Notifications: Executing step call service
2022-02-12 18:35:31 INFO (MainThread) [homeassistant.components.automation.keymaster_basment_patio_door_lock_timer_canceled] keymaster_basment_patio_door_lock_timer_canceled: Running automation actions
2022-02-12 18:35:31 INFO (MainThread) [homeassistant.components.automation.keymaster_basment_patio_door_lock_timer_canceled] keymaster_basment_patio_door_lock_timer_canceled: Executing step call service
2022-02-12 18:35:31 ERROR (MainThread) [homeassistant.components.automation.keymaster_basment_patio_door_lock_lock_notifications] keymaster_basment_patio_door_lock Lock Notifications: Error executing script. Service not found for call_service at pos 1: Unable to find service script.keymaster_basment_patio_door_lock_manual_notify
2022-02-12 18:35:31 ERROR (MainThread) [homeassistant.components.automation.keymaster_basment_patio_door_lock_lock_notifications] Error while executing automation automation.keymaster_basment_patio_door_lock_lock_notifications: Unable to find service script.keymaster_basment_patio_door_lock_manual_notify

This is on:
HA: 2022.2.6
KeyMaster: 0.77

Is there an ability to log which user pin/code opens the lock? I’d like to know who is unlocking the door and when. All I see are events pertaining to the change in status with a boolean value.

Yes. In your keymaster_<lock_name>_manual_notify script you add the the following action:

service: logbook.log
data:
  name: '{{ title }}'
  entity_id: <your_lock_entity>
  message: '{{ message }}'

You do have to make sure you’ve got the logger integration configured. I have the following in my configuration.yaml

logger: !include logger.yaml

and logger.yaml look like this to setup the logger integration and maintain the default logger configuration.

default: warning

Now, any slot you want you need to make sure it’s setup to do notifications.

What I’ve done for all of my locks is configure the corresponding manual_notify script to do that logging statement as the first thing it does, and then it sends a notification to my phone, and one to the notification service on my TV.

Thanks for the reply!

Is there a specific path/folder to create this script in? I’m still fairly new to the advanced/custom aspects of HA.

See the wiki documentation on the manual notification script.