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:

  • platform: rest
    resource: Price Forecast Region Api ā€“ Django REST framework
    scan_interval: 3600
    name: Agile Predict
    value_template: ā€œ{{ value_json[0][ā€˜nameā€™]}}ā€
    json_attributes_path: ā€œ$[0]ā€
    json_attributes:
    • ā€œcreated_atā€
    • ā€œpricesā€

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.