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

      - 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.

Thanks for quick responses. I truly appreciate it.

statusreport sensor does not change when I enable/disable the code in the card.
However it does update when I manipulate the lock manually (lock/code unlock/autolock, etc.).

I also checked OZW services ‘ozw.set_usercode’ and ‘ozw.clear_usercode’ from Developers Tools panel and they seems to work fine. I had OZW VNC open and can see codes added and removed when I call these services.

Any other advice?

Sorry to bother so much, but I’m excited to get it to work :slight_smile: and unfortunately don’t have much experience with Home Assistant and OZW - still learning.

Thanks!

Usually if the code isn’t updating it’s because the allow_automations sensor is off. You can toggle it on manually.

allow_automations sensor was off.
Codes started to work when I manually switched the sensor on.
Interesting… Now to find out why it is off :slight_smile:

This doesn’t seem to work when qt-openzwave 1.6 is on another box and is already up and running while HA is rebooting. I’ve implemented this automation instead:

- id: 712a904051494d49824430c4ff93a387
  alias: HA Startup - Set Door Lock Booleans
  trigger:
  - event: start
    platform: homeassistant
  condition: []
  action:
  - condition: state
    entity_id: binary_sensor.ozw_network_status
    state: 'on'
  - data:
      entity_id: input_boolean.allow_automation_execution
    service: input_boolean.turn_on
  - data:
      entity_id: input_boolean.system_ready
    service: input_boolean.turn_on
  - condition: state
    entity_id: binary_sensor.ozw_network_status
    state: 'off'
  - data:
      entity_id: input_boolean.allow_automation_execution
    service: input_boolean.turn_off
  - data:
      entity_id: input_boolean.system_ready
    service: input_boolean.turn_off
  initial_state: true
  mode: single

Plus I have this automation:

  alias: OpenZwave State Changed
  description: ''
  trigger:
  - entity_id: binary_sensor.ozw_network_status
    platform: state
  condition: []
  action:
  - condition: state
    entity_id: binary_sensor.ozw_network_status
    state: 'on'
  - entity_id: input_boolean.allow_automation_execution
    service: input_boolean.turn_on
  - entity_id: input_boolean.system_ready
    service: input_boolean.turn_on
  - condition: state
    entity_id: binary_sensor.ozw_network_status
    state: 'off'
  - entity_id: input_boolean.allow_automation_execution
    service: input_boolean.turn_off
  - entity_id: input_boolean.system_ready
    service: input_boolean.turn_off
  mode: single

@dbrunt,
thank you for the automation scripts! They have fixed the issue for me.

You were right - my OZW is running in a separate docker container and was up and running when HA was starting up. With your automation scripts ‘allow_automation_execution’ sensor is initialized correctly. I deleted ‘system_cleanup’ and ‘customstartup’ scripts as they are not needed anymore.

Thank you very much for your help @firstof9 and @dbrunt

My allow_automations sensor is off even after using the automations that dbrunt put together recently. I cannot figure out why it does not turn on during startup.

If I manually set it on then my codes changes work. It would be nice to figure out what is causing the disconnect.

If you’re using OZW, make sure you have the following binary sensor in your configuration.yaml
Don’t forget to reboot HA after adding it).

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.

1 Like

I do have that sensor configured along with the other two required.

- platform: template
  sensors:
    allow_automation:
      friendly_name: "Allow Automation"
      value_template: "{{ is_state('input_boolean.allow_automation_execution', 'on') }}"

- platform: template
  sensors:        
    system_ready:
      friendly_name: "System ready"
      value_template: "{{ is_state('input_boolean.system_ready', 'on') }}"
      device_class: moving    

- 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"   

What is the value of binary_sensor.ozw_network_status after HA reboot?

The status shows as it is connected (on).

This is what I have in my configuration.yaml

input_boolean:
  allow_automation_execution:
    name: 'Allow Automation'
    initial: off
  system_ready:
    name: 'System Ready'
    initial: off

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"
    
  - platform: template
    sensors:
      allow_automation:
        friendly_name: "Allow Automation"
        value_template: "{{ is_state('input_boolean.allow_automation_execution', 'on') }}"
      system_ready:
        friendly_name: "System ready"
        value_template: "{{ is_state('input_boolean.system_ready', 'on') }}"
        device_class: moving

in automations.yaml

- id: ha_startup_autom
  alias: HA Startup - Set Door Lock Booleans
  trigger:
  - event: start
    platform: homeassistant
  condition: []
  action:
  - condition: state
    entity_id: binary_sensor.ozw_network_status
    state: 'on'
  - data:
      entity_id: input_boolean.allow_automation_execution
    service: input_boolean.turn_on
  - data:
      entity_id: input_boolean.system_ready
    service: input_boolean.turn_on
  - condition: state
    entity_id: binary_sensor.ozw_network_status
    state: 'off'
  - data:
      entity_id: input_boolean.allow_automation_execution
    service: input_boolean.turn_off
  - data:
      entity_id: input_boolean.system_ready
    service: input_boolean.turn_off
  initial_state: true
  mode: single

- id: ozw_status_changed_autom
  alias: OpenZwave State Changed
  description: ''
  trigger:
  - entity_id: binary_sensor.ozw_network_status
    platform: state
  condition: []
  action:
  - condition: state
    entity_id: binary_sensor.ozw_network_status
    state: 'on'
  - entity_id: input_boolean.allow_automation_execution
    service: input_boolean.turn_on
  - entity_id: input_boolean.system_ready
    service: input_boolean.turn_on
  - condition: state
    entity_id: binary_sensor.ozw_network_status
    state: 'off'
  - entity_id: input_boolean.allow_automation_execution
    service: input_boolean.turn_off
  - entity_id: input_boolean.system_ready
    service: input_boolean.turn_off
  mode: single