New to HA, help with z-wave automations / scripts

Hi fantastic people!

I’m very new to HA, and home automation in general.
I’m an experienced control systems engineer and automate I/O and routine tasks (usually Visual Basic so others can easily understand it, don’t judge, I haven’t needed to learn Python much yet) for a living.

I’ve got a bunch of Fibaro dimmers (and a single quibino dimmer), some multi sensors of various brands, and some Aeotec Wallmotes.

When I first set up some motion sensors, I started experimenting, and tried making an automation of:
When motion detected, if dark, turn light on.
Simple enough. Cool.

Next I wanted to make it so that when motion was detected again, or by a different sensor, that it would turn the light back off, but only if it had been turned on by the first automation, not manually.
There was no option for “if this automation ran recently” in the conditions, so I made an input boolean that I can turn on to flag when the first automation had been the one to turn the light on (adding a condition that if the light was already on, it wouldn’t fire).
I went looking for the ‘turn on my new input boolean’ in the actions, nope, not there.
So, I made a scene where the boolean was on, and a scene where the boolean was off. Now I don’t even need the booleans, I can see when the scenes are on and off?
No, it seems that scenes being active. not booleans, are available in the conditions… hmmmmmm.

Giving up on that, I’ve taken a look at the WallMotes.
I can see the button pressed, button held, and button released events, I can select those events under ‘device’ in an automation, and I can toggle a light on and off based on them. Cool, so far so good.
I want to change the dimming level of a fibaro light based on sliding along the wall mote. Hmmm. No value for position of the finger… Fine, let’s do some digging.
Found that with some config changes, the wallmote will change the values of configuration parameters 9 and 10 based on where you tap and / or slide. Awesome!

So now I’m trying to get the value of a configuration parameter, manipulate (scale) that, and write that to the brightness of the dimmer. Should be easy!
Nope… Seems you can’t ‘get’ a value of a config parameter as an action. You can check it as a condition, but if there’s 100 possible values, I don’t want to explicitly write an automation for each… that’s realllllly dumb.
OK, fine, maybe a script will help. I’m fine with picking up new languages, let’s see how scripts work!
Clicked on new script, and look! more drop down boxes, with the same selections available as were in automations… this is going nowhere.
I tried clicking the “…” and selecting to edit in ymal. Seems the ymal editor for it is a bunch of ‘commands’, not really variables. How do I begin to get a value, manipulate it, and write it somewhere else?
I skipped over that and looked into writing a value into the brightness. So far, I’ve been unable to find any ‘command’ to set a specific brightness. There’s ‘brightness up’ and ‘brightness down’ actions, but nothing about setting a value. Yet in the HA gui, there certainly is a 0-100% value. How do I get access to this value in an automation or script?

All I want is to be able to see all my inputs, all my outputs, and then write code to do what I want with them. Usually there’s at least a list of all members/values/whatever-you-want-to-call-them for a given device/structure/whatever-HA-uses. This is going to be very painful if I need to spend hours googling each device to find the specific thing I have to add to the config file to make those things show up in HA, but if there’s a repository for that or it’s fairy easy to find, I’m willing. So far I’m drawing a blank though.

Where am I going wrong?

Sound like you had quite the day. I think NodeRed is something that you should look into it will help you do alot of things you have mentioned. Here is a good introduction video:

NodeRed will allow you to filter out the values that you are looking, and then use them as you like. Things with NodeRed can be very basic, or extremely complicated. You also talked about setting a specific brightness. This and be done like so:


- service: light.turn_on
  data:
    brightness: 255
    color_temp: 332
    transition: 2
  target:
    entity_id: 
      - light.upstairs_hallway

There are a lot of different ways to get things done in HomeAssistant. I’m sure you will find your way, Happy Trails.

Thanks @TinyDoT.
I did see Node-Red in passing, but wanted to try to keep the layers to a minimum.

After posting, I did see the service call for light.turn_on has brightness, colour, timing, etc.
Just not sure how to get a z-wave parameter as a value to use, natively at least.

I’ll start playing with Node-Red, and if it works for now, it works for now. If I find or am informed of an elegant (subjective) solution that works natively, I’ll migrate things.

Thank you again :smiley:

Hi @TinyDoT

I am not sure if you have experience specifically with Z-wave and Node-Red, but I am again struggling hard.

I’ve played around, and found that since the Aeotech Wallmotes don’t have events for the button presses (and even if they did, querying the config still needs device), I tried using the HA Device node.
This is said to be in alpha, and so far, nothing (even devices that are working 100% in HA) triggers from this node (writing into debug to test).

I’ve then gone and installed node-red-contrib-zwave-js into Node-Red, and it says to configure the Z-Wave controller first.
I’ve put in the controller node, and there should be the serial port where the stick is, in the drop down list. It is not there. I have tried putting in what should be the serial port for the usb port I have it in (manually entered into ‘custom port’, but deploying that makes Node-Red fail.
I needed to edit the flows.json and disable that flow in order to get Node-Red to start again.

If I’m only able to communicate with the stick through one interface, that would mean I would have to abandon all HA z-wave integrations and use Node-Red exclusively. This is all a hell of a lot of hoop jumping merely to get the current value of a z-wave device’s config parameter into a variable…

[quote=“Squigz4, post:1, topic:430227, full:true”]Next I wanted to make it so that when motion was detected again, or by a different sensor, that it would turn the light back off, but only if it had been turned on by the first automation, not manually.
[/quote]

So you’ll obviously have an automation to do the turn on - let’s call that automation.turn_on_thingy.

In your second automation the trigger will be your motion sensor, but use a “Template” condition with say:

{{ (now().timestamp() - state_attr('automation.turn_on_thingy', 'last_triggered').timestamp()) < 60 }}

That condition will mean it will react only if your “turn on” audition ran in the last 60 seconds - then you can do your turn off.

Hope this helps get you started :slight_smile:

Not much experience with Z-Wave in Node Red, but the Z-Wave stick would be connected to your HomeAssistant, and in NodeRed you connect it to your HomeAssistant. Then you would pull in the Node for the Z-Wave device, and manipulate with filters for the json data you would like. I know, I know, this isn’t a howto but a general way to do it. I’m not a Master NodeRed guy, but there are a lot of those guys in the forum, and I’m sure they could help.