nielsfaber / alarmo

Easy to use alarm system integration for Home Assistant
1.32k stars 120 forks source link

YAML code in Actions (f.e. triggered alarm) does not work properly #675

Closed HayaminiNL closed 1 year ago

HayaminiNL commented 1 year ago

Alarmo Version

v1.9.7

HA Version

2023.3.1

Bug description

Within the 'triggered' action a task can be defined.

When this task is altered to YAML code and custom code is inserted, it can be tested and works great. When the 'action' is saved, reopened, it defaults to 'entity' and cannot be tested.

Next when the alarm gets triggered, the YAML code is not executed and so no Siren is 'enabled' with high volume. It only works when the task is set up with an entity/device and not with YAML code.

Steps to reproduce

Create an action, set it to trigger on alarm.

Change ACTION to Yaml and include the yaml to call a service with some extra input to get the Zwave Siren activated with the correct settings.

Save the action, open de the newly created action and it shows an empty entity field and does not fall back to the custom Yaml code.

Relevant log output

No response

nielsfaber commented 1 year ago

I did some test with the following action: image

If I save it and edit it again, the code is still there.

Can you share your action configuration (YAML code) so I could try the same as you do?

HayaminiNL commented 1 year ago

Hi Niels,

When I open the action it first displays: image

Next when I switch it to YAML code i do see my service-call: image

This service call works perfectly when being called from the 'Developer Tools' -> 'Services' tab. It changes the volume, the duration time and next switches the alarm on.

The script that is called via this service call is: image

Thanks in advance.

nielsfaber commented 1 year ago

I'm still having trouble reproducing the issue. I set up an action like this:

And configured the action to run when the alarm is armed.

I configured the script like this:

sequence:
  - service: notify.persistent_notification
    data:
      title: Notification title
      message: >-
        Script was triggered with entity '{{ entity }}' and duration '{{ duration }}'
alias: Send notification
mode: single

When arming the alarm, the notification is triggered with the correct parameters:

Perhaps you could try clicking the 'try it' button to see if the action is performed? If that works, maybe the action is not triggered correctly. For completeness, these are the conditions I configured for the action:

Could you troubleshoot if this is maybe the problem?

HayaminiNL commented 1 year ago

Good morning Niels,

When 'try it' is used, it works flawlessly, just like it can be executed from the DEV-tools->Services part of HASS. When I replace the with the action to just turn on the siren, without YAML call to the script, it does make a lot of noice in the garage when the PIR or door-contacts are triggered in any armed mode.

This is the standard entity call with standard action: image

nielsfaber commented 1 year ago

When 'try it' is used, it works flawlessly, just like it can be executed from the DEV-tools->Services part of HASS.

The 'try it' button is intended exactly for the purpose of testing whether the configuration is OK. Alarmo will (should) execute the action in the same way as when clicking that button. If it works OK when clicking the test button, this suggests that the action is configured correctly.

Could you check whether the script is executed when it should? You can see this under Settings -> Automations and Scenes -> Scripts

image

There should be the the time displayed when the script was last executed. If you click the dots you can check the traces and see the parameters which were sent by alarmo: image

In my testing, all looks as it should. At this point I have no clue what is happing on your side. Did you also try to delete the action and create it again?

HayaminiNL commented 1 year ago

I have too checked it over and over and still nothing happens at the Siren object.

I have done a test by activating the PIRs once more and I get the following feedback from the 'Automations & Scenes' script debug: image

The device itself shows this: image

But when I trigger is manually by 'Try it' I get the following: image

image

HayaminiNL commented 1 year ago

Good evening Niels, have you looked at it? I went through the code but have not found anything useful that links to a valuable error during the 'trigger'.

nielsfaber commented 1 year ago

I don't really know how to help at this point. In both the screenshots you shared, you can find in the variables section:

entity: switch.sirene_garage
duration: 3

So I would expect the script to run OK.

I think it's good to check if this data is also present when the alarm is triggered and the automation is executed from HA. As said in https://github.com/nielsfaber/alarmo/issues/675#issuecomment-1475108656, in my testing this worked properly. You could try to perform this test on your own configuration as well.

github-actions[bot] commented 1 year 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