Z-Wave+ switch weird behaviour

Description of problem:
I have a RaZberry Z-Wave controller mounted on a RPI 2 Model B and a Wenzhou TKB Control System TZ68 On/Off Switch Socket. It works fine most of the times except when i power it off and then i power it on in the next 1,2 or 3 seconds, the switch and power LED turns on for 1 second then it turns off by itself. This happens from the web ui and from the psychical button on the socket.

I could not reproduce this when the socket is connected to the open-zwave-control-panel, when using that, it works fine from the ozcp web ui and from the psychical button.

I think it has something to do with the fact that i am not pulling the z-wave socket nor the z-wave controller, so after hass sends the command via the z-wave controller, it takes a second or two before the socket reports back to the z-wave controller its state and hass processes that.

Expected:
Turn socket on, wait a second or two, turn socket off, wait one second, turn socket on again, socket remains on until turned off again.

I’ve got the same setup (well, I’m using a Pi3, but I’m also using the Razberry controller and a TZ68 units), and I don’t (quite) see that happen.

What I do see is that the change in switch state isn’t always immediately reflected in the UI. That’s because the response from the socket isn’t always received (or the command isn’t) and it needs to retransmit. That’s just the nature of wireless communications however. Sometimes running a Heal or Test on the Z-Wave network solves that.

Certainly, using the button on the switch always behaves as expected. If you’re not seeing that then the chances are you’ve got a faulty unit.

I’m having issues with random turn ons/offs since switching to hass.io. Not sure what’s up or how to go about fixing it.

I run a heal and a soft reset every night

I am not polling the devices, so yes, there is a delay in the UI, i understand how it works and that the device has to report the new state back to the controller and only then the UI gets updated. But that is not the issue.

At first i thought that myself, but the device works as expected with the ozwcp, i only get this strange behaviour with home assistant, so i guess that rules out a faulty switch.

Maybe you can tell me more about your configuration, do you also have as i have notifications when it turns on and off ? I also have a timer that switches it off after a couple of minutes after the on event, maybe there is something there, i will dig further and post back if i get to the bottom of it.

Not sure what you mean by “notifications”.

It could be that you’re seeing a side effect of your turning it off automatically. If you disable that automation (and potentially other automations) does the problem go away? None of my automations turn the lights off at a fixed time after they’re turned on.

I got my issue figured out. I looked in the OZW (z-wave) log (on the config page) and saw that this error

2017-08-01 16:01:24.374 Warning, Failed - Network Key Not Set

that was repeating. It’s talked about here. So I just reset every z-wave device and it seems to work fine now.

I mean automation that notify various services.

I turned off the automation that triggers on power on and poweres the switch off after a couple of minutes and the problem went away. I am guessing i have to find i way to also cancel that automation if for some reason i power the switch off earlier and manually.

Thanks for the input, i will come back with the solution or workaround maybe somebody has the same issues and would like to hear about it.

I’m glad you found a solution to your problem, but i am afraid mine was not related to yours. Good job getting to the bottom of it! :ok_man:

Ah, I don’t use notifications to tell me about automations working. For things like lights going on and off, it’s pretty obvious :wink:

If you’re using a delay, then instead try using a second automation that turns off the lights if they’ve been on for a given length of time:

alias: 'Light left on'
initial_state: 'on'
trigger:
  platform: state
  entity_id: switch.yourlight
  to: 'on'
  for: 
    minutes: 5
action:
  - service: switch.turn_off
    data:
      entity_id: switch.yourlight

That will then turn it off when it’s been on for 5 minutes. If you want that to only happen when the automation turned it on, then you’ll need to add an input_boolean, that you turn on in the initial automation, and then off with this one. Add this to your on automation’s actions:

  - service: input_boolean.turn_on
    entity_id: input_boolean.yourlight_auto

Change the above off automation to:

alias: 'Light left on'
initial_state: 'on'
trigger:
  platform: state
  entity_id: switch.yourlight
  to: 'on'
  for: 
    minutes: 5
condition:
  condition: state
  state: 'on'
  entity_id: input_boolean.yourlight_auto
action:
  - service: switch.turn_off
    data:
      entity_id: switch.yourlight

Then another automation to turn off the boolean when the light is turned off (regardless of how):

alias: 'Light turned off'
initial_state: 'on'
trigger:
  platform: state
  entity_id: switch.yourlight
  to: 'off'
action:
  - service: input_boolean.turn_off
    entity_id: input_boolean.yourlight_auto

Then create your input boolean by adding the following to your configuration.yaml

input_boolean:
  yourlight_auto:
    name: Light on automatically
    initial: off

I use it for a switch which has a UV steriliser plugged in, i put things in it that i want to sterilise every 2 days, and it turns on automatically, then turns off after 40 minutes (sufficient time for a UV sterilisation session and keeping the lamp last longer) so i get notified when it turns on and off, and if by any chance it does not turn off (it’s a bit far from the z-wave controller, rarely it happens to miss a command) i do it manually (because i got notified when it turned on and can tell if it has been on for too long) because i don’t want to waste my UV lamp.

I will try your suggestions, thank you.