OpenZWave - What happened to some services like lock.set_usercode?

I was using the standard Zwave configuration but it was always a bad experience. Recently I decided to try out OpenZWave (all in one docker container). General experience is much improved over the standard built-in module. But it wasn’t until I tried to use an existing service call for lock.set_usercode that I found it was missing.

Based on these, it appears this functionality should exist:

Am I missing something in my config or is this just missing as part of the beta nature of the integration?

The beta integration does not support usercodes yet.

1 Like

Thanks for the info! Does anyone know if there are plans in the roadmap to support this in the future? I’d like to try out the beta integration, but this is a must have for my setup, so I’ll hold off until then.

I’m looking into it :wink:

2 Likes

Thanks @firstof9. If you need anyone to help test anything, I’m up for it. Just moved to this and found that this is missing. I’m happy though as my locks seem to work much better under the new OZW setup.

1 Like

PR for this is in the pipe, it’ll be entity bound meaning you don’t need to know the node number, example call:

      - service: lock.set_usercode
        data_template:
         entity_id: lock.kwikset_touchpad_electronic_deadbolt_locked_frontdoor
          code_slot: 4
          usercode: '123456'
2 Likes

Awesome! Totally looking forward to it. Great call on not needing the node number as well. I’ve been playing with the OZW integration, and it’s been awesome otherwise.

1 Like

awesome, thanks for putting this together!!

I’m happy to test this out before it gets merged if someone can explain how

It should be in the 0.113dev build.

3 Likes

Update: it’s in the beta, should be in 0.113 release :slight_smile:

1 Like

Hi @firstof9 , thanks for making this feature work! I just tried it out and it works. It looks like the service name is a bit different than the one you mentioned in your post above, but it seems to be working as expected!!

  - alias: "Set the Guest Door Code"
    trigger:
      platform: state
      entity_id: input_text.guest_code
    action:
      service: ozw.set_usercode
      data_template:
        entity_id: lock.guest_deadbolt
        code_slot: 30
        usercode: '{{ states.input_text.guest_code.state }}'
1 Like

You can also add my repo to HACS to get a nice lock manager setup.
It’s a fork of FutureTense’s work, integration-ized.

      - service: lock.set_usercode
        data_template:
         entity_id: lock.kwikset_touchpad_electronic_deadbolt_locked_frontdoor
          code_slot: 4
          usercode: '123456'

I’m running openzwave 1.6 (latest docker allinone) on my Pi where RaZberry is. HA is 0.113.2 on my Debian box. I’m somewhat new to HA (6 weeks) and my front door lock (Vision 1702) is not fully functional since recently migrating Z-Wave from homeseer as there are no user codes on it anymore. It is visible in HA and I can lock/unlock it from HA but that’s it. How and where do I configure user codes? I’ll need somewhat specific instructions…
Thanks…Daniel.

1 Like

Problem solved!
HA Developer Tools, Services
Service
ozw.set_usercode
Service Data:

entity_id: lock.front_door_lock_locked
code_slot: 5
usercode: "3579"
1 Like

Hi @firstof9,

I’m trying to setup lock manager using HACS and your repo and don’t have any success.
This is what I did so far:

  1. Added Schlage BE469 lock to OZW.
  2. Renamed 5 entities that belong to BE469 by adding _frontdoor to all of them. BTW, there are also 10 disabled (by default) entities that also belong to BE469 lock. Not sure if I need to add _frontdoor to them as well.
  3. Added your repo GitHub - firstof9/lock-manager: Home Assistant Lock Manager to HACS.
  4. Installed lock-manager integration in HACS.
  5. In newly installed folder ‘custom_components\lock-manager’ edited file FrontDoor.ini and set

lockfactoryname=“be469_touchscreen_deadbolt”.

  1. Rebooted Home Assistant.

I don’t see generated frontdoor_lovelace and not sure whether I need to create folder ‘packages/lockmanager’ (as per instructions in your GitHub).

Could you please outline steps needed to install lock-manager to work with OZW?

Thanks in advance!

P.S:
My HA version is 0.114.3. Running in docker on RPi4.

Please use https://github.com/FutureTense/lock-manager instead.

You don’t have to edit any files when setting this new version up.

You’ll want to enable the sensor.blahblah_access_control and sensor.blahblah_user_code sensors as well. Renaming is optional, but it helps you figure out which lock is which if you have multiples.

After you change out to the latest version on FutureTense’s repo, you’ll need to add the integration to HA. Configure -> Integrations -> Hit F5 to refresh the page -> + all the setup is done in the integration now.

Great! Thank you for the hints!

I can now see the UI, but for some reason codes that I set in HA do not transfer to the lock.
HA log does not show anything when I Enable/Disable the code from the card UI.

I added this code to automations.yaml (according to instructions):

- alias: homeassistant start-up
  initial_state: true
  trigger:
    platform: homeassistant
    event: start
  action:
    - service: script.turn_on
      entity_id: script.customstartup

- alias: Zwave_loaded_Start_System
  initial_state: true
  trigger:
    - platform: event
      event_type: zwave.network_ready
    - platform: event
      event_type: zwave.network_complete
    - platform: event
      event_type: zwave.network_complete_some_dead
  action:
    - service: script.turn_on
      entity_id: script.system_cleanup

And this code to scripts.yaml (according to instructions):

system_cleanup:
  sequence:
    #- service: homekit.start If you use homekit, uncomment this statement
    - service: input_boolean.turn_on
      entity_id: input_boolean.system_ready
    - service: input_boolean.turn_on
      data:
        entity_id: 'input_boolean.allow_automation_execution'

customstartup:
  sequence:
    - service: input_boolean.turn_off
      data:
        entity_id: 'input_boolean.allow_automation_execution'
      # You can add other "startup" code here if you wish

Any thoughts why codes are not getting set?

I tried with 2 different HACS versions:
v0.09
v0.0.9-ozw (beta)

ozw doesn’t have network_ready events (yet).

You can use this template sensor to signal the script.system_cleanup:

binary_sensor:
  - platform: mqtt
    name: ozw_network_status
    state_topic: OpenZWave/1/status/
    value_template: >
      {{ "ON" if value_json.Status in ["driverAwakeNodesQueried", "driverAllNodesQueriedSomeDead", "driverAllNodesQueried"] else "OFF" }}
    json_attributes_topic: OpenZWave/1/status/
    device_class: "connectivity"

Credit to steve28 and @freshcoast for the snippet.

Then you just adjust your trigger like so:

- alias: Zwave_loaded_Start_System
  initial_state: true
  trigger:
    - platform: state
      entity_id: binary_sensor.ozw_network_status
      to: "on"

  action:
    - service: script.turn_on
      entity_id: script.system_cleanup

Still no luck.

Added ‘ozw_network_status’ sensor - shows ‘Connected’.
Modified Zwave_loaded_Start_System automation to use this sensor.
Restarted HA.
Tried to setup from scratch.

How can I troubleshoot code adding? Are there supposed to be any log messages when I Enable/Disable the code?

By the way, what version of HACS addon should I use for OZW - v0.09 or 0.09-ozw(from Beta channel) ?

Thanks!

Edit:
Not sure if this could help. But if I execute ‘frontdoor Add Code’ manually, I get the following errors in the log:

2020-08-24 18:32:18 INFO (MainThread) [homeassistant.components.automation.frontdoor_add_code] Executing frontdoor Add Code
2020-08-24 18:32:18 INFO (MainThread) [homeassistant.components.automation.frontdoor_add_code] frontdoor Add Code: Running script
2020-08-24 18:32:18 INFO (MainThread) [homeassistant.components.automation.frontdoor_add_code] frontdoor Add Code: Executing step call service
2020-08-24 18:32:18 ERROR (MainThread) [homeassistant.components.automation.frontdoor_add_code] frontdoor Add Code: Error executing script. Unexpected error for call_service at pos 1: Error rendering data template: UndefinedError: 'trigger' is undefined
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 230, in async_render
    return compiled.render(kwargs).strip()
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/usr/local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 1, in top-level template code
  File "/usr/local/lib/python3.8/site-packages/jinja2/sandbox.py", line 407, in getattr
    value = getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'trigger' is undefined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 132, in async_prepare_call_from_config
    template.render_complex(config[CONF_SERVICE_DATA_TEMPLATE], variables)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 74, in render_complex
    return {key: render_complex(item, variables) for key, item in value.items()}
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 74, in <dictcomp>
    return {key: render_complex(item, variables) for key, item in value.items()}
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 76, in render_complex
    return value.async_render(variables)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 232, in async_render
    raise TemplateError(err)
homeassistant.exceptions.TemplateError: UndefinedError: 'trigger' is undefined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 191, in _async_step
    await getattr(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 352, in _async_call_service_step
    domain, service, service_data = async_prepare_call_from_config(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 135, in async_prepare_call_from_config
    raise HomeAssistantError(f"Error rendering data template: {ex}") from ex
homeassistant.exceptions.HomeAssistantError: Error rendering data template: UndefinedError: 'trigger' is undefined
2020-08-24 18:32:18 ERROR (MainThread) [homeassistant.components.automation.frontdoor_add_code] While executing automation automation.frontdoor_add_code
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 230, in async_render
    return compiled.render(kwargs).strip()
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/usr/local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 1, in top-level template code
  File "/usr/local/lib/python3.8/site-packages/jinja2/sandbox.py", line 407, in getattr
    value = getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'trigger' is undefined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 132, in async_prepare_call_from_config
    template.render_complex(config[CONF_SERVICE_DATA_TEMPLATE], variables)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 74, in render_complex
    return {key: render_complex(item, variables) for key, item in value.items()}
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 74, in <dictcomp>
    return {key: render_complex(item, variables) for key, item in value.items()}
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 76, in render_complex
    return value.async_render(variables)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 232, in async_render
    raise TemplateError(err)
homeassistant.exceptions.TemplateError: UndefinedError: 'trigger' is undefined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 430, in async_trigger
    await self.action_script.async_run(variables, trigger_context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 802, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 183, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 191, in _async_step
    await getattr(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 352, in _async_call_service_step
    domain, service, service_data = async_prepare_call_from_config(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 135, in async_prepare_call_from_config
    raise HomeAssistantError(f"Error rendering data template: {ex}") from ex
homeassistant.exceptions.HomeAssistantError: Error rendering data template: UndefinedError: 'trigger' is undefined

Use -ozw, the other is for zwave (non OZW Beta).

If the code adds your statusreport sensor should update.

Only if you have debugging enabled for ozw otherwise everything should go.