alarmo icon indicating copy to clipboard operation
alarmo copied to clipboard

Action for checking a code against the database

Open alistairg opened this issue 3 years ago • 3 comments

Checklist

  • [X] I checked for similar existing requests (both open and closed) before posting.
  • [X] My request is generic, other users may benefit from it too.

Proposal

I want to integrate external access control, and re-using the same user codes and RFID tags seems logical.

To do this, it'd be invaluable to have an action that can be called from an automation that will allow validating a given code against the code database, and returning details on validity and user (if appropriate)

Additional info

[some example of how the new functionality should look like]

alistairg avatar Aug 12 '22 06:08 alistairg

What do you mean by an action returning a result (details)? As far as I know, in HA you are limited to calling services. Services don't return any result. Therefore I wouldn't know how to add anything to Alarmo which may help you.

nielsfaber avatar Aug 12 '22 06:08 nielsfaber

Agreed, it'd be "icky" but the only way I can see to do it is to:

  • Implement a "check_user_code" service, which takes a code and transaction ID as a parameter
  • Alarmo fires an event for "check_user_code_result", which passes the transaction ID and a result

Then, an automation can simply wait for the event and determine how to proceed.

I can take a look at implementing this myself and submitting a PR, if you're not violently averse to the approach ;)

alistairg avatar Aug 12 '22 06:08 alistairg

I don't really like the ping-pong approach with calling a service and returning an event. But I don't see another way since services don't return anything. Between alarmo-card and alarmo the websocket API is used instead, which does provide bi-directional communication. However (as far as I know) this approach is not available for automations. Therefore I think your proposal is the only viable option.

Some thoughts:

  • I think we should rename transaction ID -> context_id (this would be more consistent with other functions in alarmo)
  • I think its better to rename 'check' to 'validate'. Perhaps validate_code is sufficient because the user is not relevant here.
  • Which result is expected in the event? A true/false boolean is sufficient? Or are additional parameters needed/useful?

nielsfaber avatar Sep 09 '22 06:09 nielsfaber

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

github-actions[bot] avatar Oct 10 '22 00:10 github-actions[bot]