Need help with Zwave js

I am trying to get my inovelli red series dimmer to turn off my tp link switch off when I hit the switch 3 times . Here is what I have that is not working currently:


alias: Goodnight

trigger:
  platform: event
  event_type: zwave_js_value_notification
  event_data:
    {domain: "zwave_js",
        "node_id": 3,
        "home_id": 4050476604,
        "endpoint": 0,
        "device_id": "e8f256767cb756cc360ea21c571a3e59",
        "command_class": 91,
        "command_class_name": "Central Scene",
        "label": "Scene 001",
        "property": "scene",
        "property_name": "scene",
        "property_key": "001",
        "property_key_name": "001",
        "value": "KeyPressed3x",
        "value_raw": 4}
action: 
  -service: switch.turn_off
  target:
    entity_id: switch.hallway_lamp

There are a couple of things wrong there -

  • You’ve put raw JSON in the event_data rather than YAML
  • You’ve specified far more fields than are typically needed there. Focus on the things that make the event unique, and it just looks for the fields you specify.
  • Your indentation and spacing in the action: section is incorrect

Try this:

trigger:
  - platform: event
    event_type: zwave_js_value_notification
    event_data:
      node_id: 3
      property_key_name: "001"
      value: "KeyPressed3x"
action: 
  - service: switch.turn_off
    target:
      entity_id: switch.hallway_lamp

I tried this and it did not work. I just want to make sure it is correct that I am inputting this into visual studio code under a new file I have named goodnight.yaml. Is that part correct on my end?

Are you using something from here to include that YAML file into the automation list? Have you run a config check?

You are the man! Thank you very much

FYI raw json works in place of yaml. However, his raw json was wrong as the first key (domain) did not have quotes around it. That would cause it to fail.

So in regards to the solution you posted, this would also work:

trigger:
  - platform: event
    event_type: zwave_js_value_notification
    event_data: { "node_id": 3, "property_key_name": "001", "value": "KeyPressed3x" }
action: 
  - service: switch.turn_off
    target:
      entity_id: switch.hallway_lamp

This is why templates need to have quotes around them because the yaml will see the { and assume it’s a json dict.

That’s fair and correct, but it’s far more cumbersome and easier for humans to screw up. I think it’s better for folks to manually add the tags and values they need in YAML, as they’ll see in all the docs and most or all posts, rather then just copying/pasting from the Events output, even if it ends up being valid.

I wasn’t trying to say what I was writing is better than yours. I was simply pointing out that you can use JSON. If you didn’t say this:

I wouldn’t have responded.

And yes I agree, everything should be written as yaml. But I’m not going around telling everyone that you can’t use json. I honestly thought you didn’t think it was possible, hence my reply.