Hey everyone,
I’m not really a developer, but I’d still like to understand how to create the following, maybe I’ll be able to pull it off anyway:
At the moment I have 2-3 RESTful sensors set up, which provide both sensor values pulled from certain fields in the JSON result sets from public APIs, and are then the base for notifications.
example code:
- platform: rest
name: "mywellness this month"
unique_id: "mywellness this month"
scan_interval: 3600
resource_template: https://buchen.mywellness.de/api/customer-app/v1/suite-availability-days?month={{ now().strftime('%Y-%m') }}&day_time=09%3A00-01%3A00&capacity=2&duration=02%3A00&outlet_ids[]=7&suite_type[]=1&suite_type[]=2&suite_type[]=4&suite_type[]=5&suite_type[]=6&suite_type[]=7
value_template: "{% for days in value_json.availability_days if days.availability_status == 1 %}{% if loop.index == 1 %}Number of days: {{ loop.length }}
Earliest date: {{ days.availability_date }}{% endif %}
{% else %}no dates available
{% endfor %}"
This is so far a completely manual process, and I was wondering how to turn this setup process into a generic blueprint, or an integration, which I can use to add/manage REST endpoints and the derived sensors.
Idea for the userflow so far:
- enter REST endpoint URL
- list/define datafields to pull in as sensor values (without having to write the template code from scratch)
- nice to have: directly define notification(s) or other automation triggers based on potential values from those sensor values
Examples for where I’m using this, or an planning to use it:
- the local wellness place has an API which they use to show newly freed-up slots that become available to book
- a yearly lottery ticket provider has a public endpoint where you can check if your ticket has one something
- a chain of vaccination centers provides open slots via public API
All of these API endpoints are used by their websites to provide their UI components with the needed data, so they are not necessarily “user-friendly”. Also: some of those (and other potential usecases) I only need for a short amount of time, not as a long-term setup where it’s worth to spend tons of time once to do a manual setup.
Any hints would be helpful, thanks in advance!