nielsfaber / alarmo

Easy to use alarm system integration for Home Assistant
1.42k stars 119 forks source link

Configure actions on labels #949

Open jftanner opened 6 months ago

jftanner commented 6 months ago

Checklist

Proposal

I would like to be able to select labels (or areas, etc) when configuring actions, rather than only entities. Ideally, the actions should support any of the targeting modes for services.

Additional info

This works in an action to trigger a single light to turn on full red, then flash for a while:

# Turn on one light to full red.
- service: light.turn_on
  entity_id: light.back_downlight
  data:
    rgb_color:
      - 255
      - 0
      - 0
    brightness_pct: 100
    transition: 1

# Make it flash for a while
- service: light.turn_on
  entity_id: light.back_downlight
  data:
    flash: long

However, to do the same for multiple lights, I would need to a) create two more service calls for each one, or b) create a script and trigger that. Either option is excessively complicated.

Instead, it would be preferable to use something this:

# Turn all the lights to full red.
- service: light.turn_on
  target: # Note the target field.
    label_id: loft_alarm_lights # Note that this is label_id instead of entity_id (though that could be used as well)
  data:
    rgb_color:
      - 255
      - 0
      - 0
    brightness_pct: 100
    transition: 1

# Flash the two downlights for a while
- service: light.turn_on
  target:
    entity_id: # Note that entity_id can also be a list (as can the others)
      - light.front_downlight
      - light.back_downlight
  data:
    flash: long

These list items work as expected in the service dev tool, so presumably it's just a matter of having Alarmo pass along the target field (and not breaking the yaml when loading the UI view, which happens now.)

This would make Alarmo actions a lot easier to set up without making a bunch of extra scripts.

github-actions[bot] commented 5 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

jftanner commented 5 months ago

I'd still really like this feature. I hope it gets considered.

jftanner commented 5 months ago

There's a similar open request for sensors by label. Implementing both would be ideal.

github-actions[bot] commented 4 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

jftanner commented 4 months ago

I'd still like to see this.

github-actions[bot] commented 3 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

jftanner commented 3 months ago

@nielsfaber Would you mind pinning this or rejecting the request? Or should I just keep replying to the bot every month? :D

dannytrigo commented 3 months ago

This is probably simpler to implement than my request for the sensors. I might give a try implementing this one when I get some time

jftanner commented 2 months ago

I'll just go ahead and bump this now before the bot gets to it. :D

nielsfaber commented 1 month ago

Is this request specifically for being able to select labels/areas via the UI (dropdown menus)? Or are you experiencing errors if you edit the target section manually via YAML?

jftanner commented 1 month ago

I'm happy to use YAML, but I haven't found a way to successfully use target at all. Everything I try gives me this error when I click "TRY IT": image

Working baseline example

This works as expected:

- service: light.turn_on
  entity_id: light.front_downlight
  data:
    flash: long

Failed attempts using target

From the documentation, I'd have expected this to also work:

- service: light.turn_on
  target:
    entity_id: light.front_downlight
  data:
    flash: long

And also this:

- service: light.turn_on
  target:
    label_id: loft_alarm_lights
  data:
    flash: long

But both resulted in the error above.

Failed attempts using label_id

Following the error message, I tried these two:

- service: light.turn_on
  label_id: loft_alarm_lights
  data:
    flash: long

and

- service: light.turn_on
  label_id: 'Loft Alarm Lights'
  data:
    flash: long

Both failed with the same error.

Summary

I haven't been able to find any way to target a label instead of an entity. Or, for that matter, even a list of entities.

I know that this does work if I run it in developer tools:

action: light.turn_on
target:
  label_id: loft_alarm_lights
data:
  flash: long

Maybe the issue is actually in the UI, but I haven't found a workaround. I tried saving the YAML (without clicking "TRY IT") to see if it would work anyway, but no dice. And if I open the action again later, my custom YAML is gone.

github-actions[bot] commented 1 week ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

blackbird0589 commented 1 week ago

I would also be interested in trigger some automation or other entities and not only switch devices. It would be also helpful to change the "services" to "actions" (according to HA 2024.8)

And over all...thanks for this great tool!