How to add agilePredict

Hi All

New to Home Assistant. Trying to add the Agile predict sensor from Agile Predict
to the YAML file.
Its given on the site as:

sensor:
- platform: rest
    resource: https://prices.fly.dev/api/G
    scan_interval: 3600
    name: Agile Predict
    value_template:  "{{ value_json[0]['name']}}" 
    json_attributes_path: "$[0]"
    json_attributes:
    - "created_at"
    - "prices"  

I copy and paste to the YAML and although it states the configuration wont prevent start almost every line throws an error., usually not recognised.
Has anyone successfully added this sensor and if so how, Many thanks Pete

Welcome to the forum. Let’s see if I can be of any assistance.

Paste it into the YAML where?

I`m not exactly sure. Heres the site:
https://agilepredict.com/api_how_to

It says:
The GitHub repo includes the necessary yaml files to import the forecast into a sensor in Home Assistant. Alternatively you can simply copy the code from this page into your configuration.yaml file.

Regards Pete

You are not sure where you pasted it?

Those instructions state to paste it into configuration.yaml. What it doesn’t tell you is if you already have a sensor: section, you will get an error if you add a second one.
Did you paste it into configuration.yaml, and if you di was there already a section for sensor: in there.

1 Like

Mu current configuration.yaml is:

Loads default set of integrations. Do not remove.

default_config:

Load frontend themes from the themes folder

frontend:
themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

So I add in the sensor yaml

Loads default set of integrations. Do not remove.

default_config:

Load frontend themes from the themes folder

frontend:
themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
#Load sensor
sensor:

I then check with developer tools to config and get:
Configuration warnings

Integration error: resource - Integration ‘resource’ not found
Integration error: scan_interval - Integration ‘scan_interval’ not found.
Integration error: name - Integration ‘name’ not found.
Integration error: json_attributes - Integration ‘json_attributes’ not found.
Integration error: json_attributes_path - Integration ‘json_attributes_path’ not found.
Integration error: value_template - Integration ‘value_template’ not found.
Invalid config for ‘rest’ from integration ‘sensor’ at configuration.yaml, line 14: must contain at least one of resource, resource_template. ‘’, got {‘platform’: ‘rest’}

Can you format that so I can see if there is an indentation error?

How to help us help you - or How to ask a good question.

Hi
Your mention of indentation made me have a look at what was copied and pasted in.
I removed one space on the line - platform: rest after pasting in. I now get a green tick and the check configuration now doesn’t throw an error. Is there any info on indentation and formatting structure as it seems critical the number of spaces is correct

Did you get anywhere with this?

I’m in same situ, pasted it in but it’s not liking it and I hate having to deal with Yaml code as just don;t have a clue what I’m doing either

sensor:
- platform: rest
    resource: https://prices.fly.dev/api/G
    scan_interval: 3600
    name: Agile Predict
    value_template:  "{{ value_json[0]['name']}}" 
    json_attributes_path: "$[0]"
    json_attributes:
    - "created_at"
    - "prices"     

Likewise - having the same issue

I went to git hub and copied it directly from there - green tick.

1 Like

The whole thing drove me so mad I wrote a long “how to” on the HomeAssistant Discord. If you want to see it, it’s here: https://discord.com/channels/330944238910963714/1301192351074488381/1301192351074488381

But, in short, for those of us who aren’t experienced with YAML etc, it seems there’s multiple types of sensors. Those of us just muddling through are just using “template sensors” - but you can also create actual sensors - and they go at another level, and I think that’s the crux of where we’ve been getting stuck.