Thanks, I didn’t see that tip or it didn’t click because I was just trying to complete the simple exercise of learning how to use a single basic REST sensor. Doesn’t answer the my issue in the end.
The answer to my problem was not that I was doing anything wrong, but the documentation lacks a critical piece of information: You must FULLY restart HASS, not reload the config.
New sensors will only be picked up on HASS restart. Once it’s already up and running you can change some aspects of the sensor (I didn’t test how much, but some settings like scan_interval
worked) via a config reload.
This is not specific to the REST integration. See https://www.home-assistant.io/docs/configuration/#reloading-changes
Perhaps rethink how you communicate on the forum. You asked two questions, and I answered the one that I had an answer to. Getting annoyed isn’t going to get you far around here. If you didn’t want an answer to that question you shouldn’t have asked it — and especially not sound like you’re blaming the person trying to help.
That’s not exactly true. Now that you have the domain set up in configuration.yaml
, you can add new REST sensors and change or delete existing ones; and see the changes with a YAML reload rather than a restart.
You only needed to restart because you were adding a top-level domain into the configuration.
You mean switch off and on?
You don’t need to restart the computer, but you do need to “Restart Home Assistant”. As others have pointed out, only when adding that first REST sensor. After that a reload should be sufficient.
When using any integration for the first time.
Were you just doing a YAML reload? I’ve been successful in just executing a reload through Developer Tools->Services->RESTful: Reload without restarting.
Was it the first time you added the rest integration though?
You need to restart HASS if its the first time you’re adding any integration (in this case REST/RESTFUL). Once you’ve got that rest:
line in and restarted HASS once, then after that you can just do a reload.
Hi,
Can you assist with this code, if possible, i am having an issue trying to add this sensor code into HA, I try where sensor.yaml & configure.yaml but not able to see the see sensor for the airtag expose into HA
- platform: rest
name: airtag_*Backpack
value_template: “{{ value_json.results[0].formatted }}”
json_attributes_path: “$.results[0]”
json_attributes:- lon
- lat
- district
- city
- postcode
- street
- housenumber
- state
- country
- country_code
verify_ssl: true
scan_interval: 120 # every 15 min
resource_template: >
{% set address = states(‘input_text.airtag’).split(‘*Backpack’)[1].split(‘•’)[0] %}
{% if address == “Home” %}
{% set home = “Providenciales, Turks & Caicos Islands” %}
{{
“https://api.geoapify.com/v1/geocode/search?text=”- home | urlencode
- “&apiKey=aaf82a47336a41a0bb93a2c6ae372c56&format=json”
}}
{% else %}
{{
“https://api.geoapify.com/v1/geocode/search?text=” - address | urlencode
- “&apiKey=aaf82a47336a41a0bb93a2c6ae372c56&format=json”
}}
{% endif %}
You’re going to need to format that code correctly.
i am using notepad++ with the yaml language, is there anotherway?
There are many other ways to edit yaml, notepad++ is also fine. But please read the linked topic on how to properly post your yaml on the forum. If you don’t, we only see a jumbled mess.
sorry i know it’s not a helpdesk was just asking about the code.
CLICK ON THE LINK ABOVE AND READ IT. It’s not just about not being a helpdesk. Section 11 (the link) is about formatting code. The way you have posted it makes it unreadable and we cannot help you until you correct it.
I, and I’m sure others, would be more than happy to help once we have your code in a state that we can read.
We need it to look like this:
- platform: rest
name: airtag
and so on.
Do this by putting three backticks before and after the code:
```
CODE HERE
```
Is there a way of concatenating part of an IP address with the current year for the rest resource? It works as a template but is not picking up in the rest sensor. The resource is https://aa.usno.navy.mil/api/seasons?year=[current year], so https://aa.usno.navy.mil/api/seasons?year=2024 but I want to automatically update the year.
I tried below but no success.
https://aa.usno.navy.mil/api/seasons?year={{now().year}}
It would help if you included the sensor config that isn’t working.
If you are using a template, as per the docs, you must use resource_template:
not resource:
. My guess is that you haven’t done that, but without your code, it’s just a guess.
resource_template: "https://aa.usno.navy.mil/api/seasons?year={{ now().year }}"
Thank you. I was not using resource_template but the example you gave works. I appreciate the help.