Simple z-wave configuration, button that turn light on / off

Hello.

Im a total newbie in the HA world. My HA works fine with my z-wave switches and sensors.
But now I would like to configure som magic!

My use case is a button (Fibaro button) that I would like to use in order to turn lights on / off.
But dear! I the world of declarative yaml files, my Google skill leaves much to be wanted.

Can anybody point me to som nice examples, guide och blog or anything usefull?

Please please :slight_smile:

I don’t have exactly what you want in my setup but I have something similar which you could use as an example or starting point. I use a split config so the following is in an ‘automations’ directory.
doorbell_light_control.yaml

alias: Doorbell Light Control
initial_state: 'on'
trigger:
  - platform: event
    event_type: click
    event_data:
      entity_id: binary_sensor.switch_158d00018b3ede
      click_type: long_click_press
condition:
  condition: or
  conditions:
  - condition: sun
    after: sunset
    after_offset: '00:00:00'
  - condition: sun
    before: sunrise
    before_offset: '00:00:00'
action:
  - service: homeassistant.turn_on
    entity_id: light.front_door_light
  - delay: '00:01:00'
  - service: homeassistant.turn_off
    entity_id: light.front_door_light

The above will turn on a light if the doorbell button is held for a second, then turn it off after 1 minute. You could remove the automated ‘off’ and change the trigger to a general state change for the Fibaro button however that device operates (might be a single click). Using a condition to check if the light is already ‘on’, you should be able to make it turn ‘off’ with a second click. There was this thread I read on here a week or so ago that had code for doing something similar although its a bit more complex because he is doing dimming as well.

1 Like

Super tnx :slight_smile:

Ill try it first thing tomorrow.