Advertisement
JLindvig

fuelfinder v. 0.1

Nov 6th, 2021
1,132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 0.64 KB | None | 0 0
  1. sensor:
  2.   - platform: rest
  3.     name: OK 95
  4.     resource: http://rest.apptoo.dk/fuelfinder.json
  5.     value_template: >
  6.      {# NAME OF THE FUEL COMPANY TO EXTRACT FROM #}
  7.       {% set company_name = "OK" %}
  8.       {# FUEL TYPE TO EXTRACT, "gas_95" OR "diesel" #}
  9.       {% set type = "gas_95" %}
  10.      
  11.       {# DO NOT TOUCH BELOW #}
  12.       {% set fuelcompany = value_json.fuelprices | selectattr('company_name', 'eq', company_name) | list | first %}
  13.       {{ fuelcompany[type] }}
  14.     json_attributes_path: "$.fuelprices[?(@.company_name == 'OK')]"
  15.     json_attributes:
  16.      - company_logo
  17.       - gas_95
  18.       - diesel
  19.       - last_update
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement