Using Alarm Service as an Automation Trigger

HI , I am using the Alarm service which works well , but I would like to have some automations based on that service and use as a trigger. In my example I have automations that turn on lights between sunset and sunrise , but I want a couple of these not to be triggered if the Alarm status is set in night mode. I have done it using a helper at present but that fails from time to time… So how do I use a service as an automation trigger … Amany thanks Andy

Could we see your code?

That’s not using the alarm as a trigger, but a condition.

Either add a state condition listing all other possible states, or a template condition that is true if the alarm is not in night mode.

If you want further help, we need to see the automation you have (as correctly-formatted YAML) and the state and attributes for your alarm entity.

Sorry totally correct , it would be a condition. I haven’t written the actual automation yet , but this an example one I have ready to insert the condition when I know what to include.

alias: "TEST "
description: ""
trigger:
  - type: motion
    platform: device
    device_id: 090968feb3772e41f8234ccd7432336b
    entity_id: 806bab1d19a7b84d61a1559a12aab1dd
    domain: binary_sensor
condition:
  - condition: sun
    before: sunrise
    after: sunset
action:
  - type: turn_on
    device_id: 960d26b2856f1017b6750fb32144b98b
    entity_id: 28c8ee92ead677311ead3e1ea4dce1ea
    domain: switch
mode: single

And we can’t advise on that until you show us

As a side note, it’s easier to work with entities rather than devices:

This is the problem, using the built in HA Alarm feature which does not have devices or entities to use… Its a service (I believe) , so I cant include them . If there were I wouldn’t have asked the question as those are easy to include in conditions.

All I am asking is how can i set a condition in an automation based on a service ?

Which one?

We can’t assume any level of competency here. :slight_smile:

Marked as solution as no point continuing this conversation

:thinking:

Was doing my best to help here, trying to pinpoint what “the built in HA Alarm feature” is, as all the information I can find suggests that implemented alarms have queryable entities.

What happens if you filter the Entity column of Developer Tools / States with “alarm_”?

What is your alarm?

Can you explain this a bit more? Services perform things, so I struggle to follow what you mean here. Is there some state you’d like to check?

If it’s this you’re referring to, then you need to use a state condition and check the state of your alarm entity. You don’t need a device to do that. Troon’s advice to avoid devices is good advice.

condition: state
entity_id: alarm_control_panel.my_alarm
state: armed_night

Also, rather not set a solution as the answer that isn’t the actual solution, because if will create problems for search results and confuse other users.