#First Automation - Pico switch controlling fan - Best practices

1 messages · Page 1 of 1 (latest)

alpine jasper
#

I have a Lutron Pico wireless switch (on/off/dimmer) that I want to control a Zooz z-wave 0-10v dimmer control (controlling a fan motor). I created two automations, one for "On" and another for "Off" and as I prepared to create a "Dimmer Up" Automation I thought: "This seems inefficient and that it would create a LOT of automations." I'm wondering if my approach is the best practice or is there a way to create a single Automation that controls multiple attributes? In other words, one automation for On, Off, Dim Up and Dim Down?

Here is the YAML for the On and the Off

description: ""
triggers:
  - device_id: bd9a01d389d8cf5c5b26897f6d64793b
    domain: lutron_caseta
    type: release
    subtype: "off"
    trigger: device
conditions: []
actions:
  - action: light.turn_off
    metadata: {}
    data: {}
    target:
      device_id: cd552b87f9295d4f77171e48ef913d59
mode: single```

```alias: "Pico Soffit Fan Control :: On"
description: ""
triggers:
  - device_id: bd9a01d389d8cf5c5b26897f6d64793b
    domain: lutron_caseta
    type: release
    subtype: "on"
    trigger: device
conditions: []
actions:
  - action: light.turn_on
    metadata: {}
    data: {}
    target:
      device_id: cd552b87f9295d4f77171e48ef913d59
mode: single```
fickle dawn
#

Separate automations is the most basic (thus newbie friendly) way to do it. But I also like to group stuff that's tightly related. This can simply be done by giving each trigger a trigger id and using that in a chooser. An example with your current automations:

alias: "Pico Soffit Fan Control"
description: ""
triggers:
  - device_id: bd9a01d389d8cf5c5b26897f6d64793b
    domain: lutron_caseta
    type: release
    subtype: "off"
    trigger: device
    id: "off"
  - device_id: bd9a01d389d8cf5c5b26897f6d64793b
    domain: lutron_caseta
    type: release
    subtype: "on"
    trigger: device
    id: "on"
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - "on"
        sequence:
          - action: light.turn_on
            metadata: {}
            data: {}
            target:
              device_id: cd552b87f9295d4f77171e48ef913d59
      - conditions:
          - condition: trigger
            id:
              - "off"
        sequence:
          - action: light.turn_off
            metadata: {}
            data: {}
            target:
              device_id: cd552b87f9295d4f77171e48ef913d59
mode: single

And yes, as with a lot of things in HA there are other ways. But trigger id's and chooser is the most common and UI friendly.

alpine jasper
#

Thanks for the reply. Your approach is how I would like to do it, much neater. I just found the "Choose" action which is what you used - awesome!

I noticed when I add Light as an Action target there aren't dimmer controls, only On, Off and Toggle.

fickle dawn
#

In my opinion the device triggers/conditions/actions are just confusing. Instead go for the normal action calls. In this case light.turn_on (under Light => Turn on in the UI). Then you also have more options like the brightness.

alpine jasper
#

Automation is working perfect, I'm so happy! Thanks again for the help. I ended up changing to the Z-wave device rather than the Light abstract device.

description: ""
triggers:
  - device_id: bd9a01d389d8cf5c5b26897f6d64793b
    domain: lutron_caseta
    type: release
    subtype: "off"
    trigger: device
    id: "off"
  - device_id: bd9a01d389d8cf5c5b26897f6d64793b
    domain: lutron_caseta
    type: release
    subtype: "on"
    trigger: device
    id: "on"
  - device_id: bd9a01d389d8cf5c5b26897f6d64793b
    domain: lutron_caseta
    type: press
    subtype: raise
    trigger: device
    id: up
  - device_id: bd9a01d389d8cf5c5b26897f6d64793b
    domain: lutron_caseta
    type: press
    subtype: lower
    trigger: device
    id: down
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - "on"
        sequence:
          - type: turn_on
            device_id: cd552b87f9295d4f77171e48ef913d59
            entity_id: d12ba064b29c818789e2e26ffc2313f6
            domain: light
      - conditions:
          - condition: trigger
            id:
              - "off"
        sequence:
          - type: turn_off
            device_id: cd552b87f9295d4f77171e48ef913d59
            entity_id: d12ba064b29c818789e2e26ffc2313f6
            domain: light
      - conditions:
          - condition: trigger
            id:
              - up
        sequence:
          - device_id: cd552b87f9295d4f77171e48ef913d59
            domain: light
            entity_id: d12ba064b29c818789e2e26ffc2313f6
            type: brightness_increase
      - conditions:
          - condition: trigger
            id:
              - down
        sequence:
          - device_id: cd552b87f9295d4f77171e48ef913d59
            domain: light
            entity_id: d12ba064b29c818789e2e26ffc2313f6
            type: brightness_decrease
mode: single