Dear all,
I am new but invested a lot of time and read several days website and the home assistant support site to start with home assistant.
Most things working fine, but I’m not able to include a values (json) from a url into a sensor.
Could you please be so kind and give me some hints ?
I want to get the values “staus: open or closed”, tempature, chlor, ph, redox and time (published at).
I already tried several hours with different code inside the config file (/homeassistant/configuration.yaml).
No, temp and chlor worked on my machine even before I noticed the unit_of_measurement error. I suspect OP has made too many queries and may have to wait a bit…
The unit error is visible in the logs, too:
ValueError: Sensor sensor.status has device class 'None',
state class 'None' unit 'status' and suggested precision 'None'
thus indicating it has a numeric value; however,
it has the non-numeric value: 'closed' (<class 'str'>)
Thank you and all others very much. Oh dear… I invested several hours yesterday evening with getting crazy.
I updated the code as you mentioned. I think I’m still blocked and will wait some minutes/hours. Hope that afterwards everything is working without issues.
Otherwise I’ll come back
# Loads default set of integrations. Do not remove.
default_config:
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
api:
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
rest:
- resource: http://ospa.iot-center.de/api/123/
scan_interval: 600
sensor:
- name: "status"
value_template: "{{ value_json['status'] }}"
- name: "chlor"
value_template: "{{ value_json['data']['chlor'] }}"
If i try to use https I will not find any sensor. With http I will be able to see for instance the sensor “sensor.status”. But status is still unkown
Any idea ? Maybe anything in config file is missing or I’ve not made a specific setting in home assistant.
Can you access that resource URL from your web browser? Is that browser on the same LAN behind the same router as your HA installation? I wonder if your IP has been blocked.
There’s nothing wrong with your code, as per my working sensors in prior post. If I look at that URL from my HA shell (attached console via Portainer: HA is in a Docker container on my NAS):
NAS:/config# curl http://ospa.iot-center.de/api/sawoberbeerbach/
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://ospa.iot-center.de/api/sawoberbeerbach/">here</a>.</p>
<hr>
<address>Apache/2.4.41 (Ubuntu) Server at ospa.iot-center.de Port 80</address>
</body></html>
That’s the redirect to the HTTPS. Trying that in turn:
You are my hero !! Thank you very much !!!
I delete the raspberry with HO image in my router and restart router, because I had the feeling that anything inside the router was not ok or the website blocked my ip.
Not sure if a new IP or deleting settings of raspi in the router was the solution, but finally it works.