Those are some interesting ideas, the macro I haven’t seen before and will be good options if using the service is not possible.
However, I’m still looking to find if I can use the service call to validate my code/password as it gives me a lot more flexibility than hard coding passwords in my scripts.
Tryting to call the service from the template was approaching the problem the wrong way but given that documentation it seems like this should be possible:
If I got it right, response_variable goes together with the new stop verb/action, and that would be set in my_service.check_secret as the variable returned, i.e. True/False in this case.
Not sure why you point to Dev documentation, that’s definitely out of scope here.
Yeah I should have been more clear. Based on that dev documentation there’s some specifics I need to do on the service side in order for the service to properly respond into the response_variable. It seems like assuming my service is built correctly I can get the result into a varaible and then check the result in a condition
There are several ways to confirm the supplied password is correct (many have already been suggested in this topic) but none can do it the way you initially requested (call a service within a Template Condition).
A service can be a “yaml script”, as Tom pointed out. In that case, the doc is irrelevant.
A service can also be offered by an integration, coded in Python, and there the doc is relevant.
Are you planning to create a custom component in python that will implement your password logic?
My bad, I didn’t realize “service” could have multiple meanings. Yes, I’ve written a custom component that offers a service to do the checking logic.
I thought my problem was on the configuration side but it’s actually on the integration side which is out of scope here as you said.
The answers provided to my original question are right: No you can’t do it in a condition
But, if you have an integration with a service built to return results and are using HA >= 2023.7, you should be able to do something along the lines of:
Well, the value_template won’t be just {{ check_result }}, it’ll have to extract the key from the dictionary. response variables can only be dictionaries. So, it will be something like "{{ check_result.value }}"