Where/How to start? Building blueprint/integration for REST-based sensors and notifications

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! :slight_smile:

Setting up sensors is manual one time per thing.
I don’t know another way around it because there is no set pattern to all ‘data’.
All blueprints are custom so there is no such thing as a generic blueprint, but blueprints aren’t much help creating sensors either.
If you write a custom integration or addon, you will still have to manually create the sensors to make them work as well.

Thanks for the feedback, bit of a bummer though :neutral_face:

I realised one thing though: the part that usually takes the most time is writing the correct template code to fill request parameters dynamically, and to extract the JSON datafield(s). Maybe I’ll focus on simplifying that part of the process first. Ideas could be a collection of template snippets for certain use-cases (first and last date of last month in a certain datetime format, …), or a chatGPT prompt that has proven to provide usable jinja2 code, or or or…

Will have a think :slight_smile: