Lock code by time of day

We have some people doing construction on our house. I'd like to give them access during the day on weekdays.

It looks like lock code manager can enable and disable by day, but not recurringly by time of day.

Has anyone written a lock app that has features like this?

Can I do this in rule machine? (IE, if someone enters 1234 on front door and it is between 6 am and 6 pm M-F, unlock front door)

Other ideas?

Thank you.

You can set an expiration time in LCM if that helps.


This could be done with Rule Machine. You can use a Custom Action to create a lock code, or to remove one. So you could do some scheduling to create the code you want at the time you want, and remove it at some other time.


Like this:

Note: the first parameter to setCode is a number, and the last two are strings.

If there is going to be a day off, you could pause the rule. When it's all over, you could delete the rule, or just leave it paused for the next time.

This can also be done from a Dashboard. See the last part of this post:


My bookmark folder for Hubitat is getting YUUUUUUGE for future references as I integrate things!


Could this functionality easily be built into the existing lock code manager? I've seen a few people request this feature on the forums and I also would really benefit from the feature. We have a house cleaner that comes every 2nd Friday and it would be nice to have her code only work when we're expecting her. I see this can be done in Rule Machine, but for newbies, and in the interest in just having user lock codes all in one spot, in lock code manager, I think it would we a welcomed addition.


Hi Bravanel,
I want the setCode() functionality but it seems not available in RM 4.0?
I want to send Code at a specific time only, then deactivate the Code after 3 hours.

It is definitely available in Rule Machine 4.0. Choose the action Run Custom Action, and then choose your lock as the device. Here's a screenshot that should help you ...

Thank you aaiyar, I got it! I'm still beginning to explore HE functionality.

I am trying to do a similar thing here. I want to disable one code in every lock at sleep and then turn it back on when sleep is off. Sleep is a variable that I turn on and off. It appears that I cannot "disable" the lock code, I can only delete it and re-add it? Is that correct? Thanks.

Correct. AFAIK, locks don't have the ability to "disable" a code. At least my Yale Zigbee locks do not.

1 Like

It's a complicated discussion.

On many zwave locks you can indeed enable/disable codes programmatically. The zwave user code command class supports it, as do many zwave locks (but not all!!! - Some will respect changing the status bit, but not actually disable it in the keypad...).

That said, I'm not aware of any UI in hubitat that exposes/uses the user code status enable/disable, so if one wanted to do that it would take custom zwave commands or an intermediate app.

1 Like

I didn't know that.

So supporting the "least common denominator" would still suggest that lock-code enable/disable is best done by delete/re-add?

As a general statement - I think so.

If someone has a lock that supports enable/disable they likely need a custom driver or app, as that functionality would be outside of anything built-in to the hub currently.

1 Like

Doesn't Lock Share in HPM do exactly what @simon4 is asking?

This does look interesting. But the lack of IOS support makes it a bit of a non-starter here.

Originally I was controlling all of the locks in Homeseer. I had one code set aside for people coming to the house - cleaners, etc. I "disabled" that lock code while sleeping. In homeseer this was an event that deleted the code from the locks and then added them back in when sleep was off.

I don't see a way to do this in Rule Machine?

I see another older post on this - so might jump on that one as well.

I usually just change one of the lock codes from one set of digits to another set. That way you only give one of the codes to the third party. Then swap the code around dependent on conditions.

I did this due to this appearing to work more reliably. And worst case if the code doesn't change properly, then if they can't get in I can just let the third party know the other code over the phone.

1 Like

I would vote for this feature. It was a basic functionality in Vera for the last 10 years.

Download the Hubitat app