-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use rest api to get sensor data #83
Comments
Thanks for reporting an issue!
You can register a function to gpt, and it automatically decides what data or function to use. There are a few function types (including REST) you can use in this integration.
Are you trying to get sensor from another remote HA or local HA?
- spec:
name: get_state
description: Get state of entity
parameters:
type: object
properties:
entity_id:
type: string
description: The entity id.
function:
type: rest
resource_template: "https://YOUR_BASE_URL/api/states/{{entity_id}}"
value_template: "{{ value_json.state }}"
headers:
Authorization: "Bearer YOUR_TOKEN" You have to replace |
Hi Jekal, it worked!!!
|
Since - spec:
name: get_entities
description: Get entity list
parameters:
type: object
properties:
dummy:
type: string
description: Nothing
function:
type: rest
resource_template: "YOUR_BASE_URL/api/states"
headers:
Authorization: "Bearer YOUR_TOKEN"
value_template: >-
```csv
entity_id,name,state
{% for entity in value_json -%}
{% if loop.index < 3 -%}
{{ entity['entity_id'] }},"{{ entity['attributes']['friendly_name'] }}",{{ entity['state'] }}
{% endif -%}
{% endfor -%}
``` |
In the initial prompt I set to use REST api passing the bearer token adding
It calls a non existant generic function
Something went wrong: Service sensor.rest_command not found.
What I want to achieve is to get temperature from a particular sensor, in your docs I see that is possible to use REST .
Tried manually with Postman with url
{{base_url}}/states/sensor.temperatura_corridoio
and it gives me the correct json data
{"entity_id":"sensor.temperatura_corridoio","state":"16.57","attributes":{"source":"1.1.14","unit_of_measurement":"°C","device_class":"temperature","friendly_name":"Temperatura corridoio"},"last_changed":"2024-01-08T10:12:10.938297+00:00","last_updated":"2024-01-08T10:12:10.938297+00:00","context":{"id":"01HKM8XW1T3HAC2WHACT81M85H","parent_id":null,"user_id":null}}
How can I set bearer token?
How can I map a particular prompt to use REST function?
The text was updated successfully, but these errors were encountered: