Hi everyone, I need your help for a configuration.
I have a device that sends some data to Thingspeak and I would like to read this data and display it on Home Assistant.
The best way to do this is to create a sensor on the REST platform.
But in this way each request feeds 1 sensor at a time, and to supply the 4 sensors (temp, humidity, pressure and volt) I need to make 4 requests. I wanted to find a more efficient way
I think your best bet is to createe the single sensor with multiple attributes, you will then need a template sensor to pull out the individual attributes into their standalone sensors
- platform: rest
name: Thingspeak
json_attributes:
- field1
- field2
- field3
- field4
resource: https://api.thingspeak.com/channels/xxxxxx/feeds/last.json?api_key=myapikey
value_template: I have no idea what to put on
- platform: template
sensors:
temperature:
friendly_name: 'Temperatura'
value_template: '{{ states.sensor.thingspeak.attributes.field1 | round }}
device_class: temperature
unit_of_measurement: 'Ā°C'
other sensor:
etc
but I am not sure how to do this or even if it is possibleā¦ I would suggest reading up on the docs and then using the template tool in developer tools section:
Thanks to the guide and tips here on the forum I created the sensor. A single http request feeds a sensor (last reading time) with 4 arguments (temp, humidity, etc.). With a templete I take the data from the arguments and create individual sensors.
Im working on this same integration right now, EC, pH and Temperature. when i use the request https://api.thingspeak.com/channels/xxxxxx/feeds/last.json?api_key=myapikey i get {ācreated_atā:ā2020-06-10T00:54:13Zā,āentry_idā:299,āfield1ā:ā7.24ā,āfield2ā:ā294ā,āfield3ā:ā20.79ā}.
Translation Error: The intl string context variable āLevelā was not provided to the string āDetalhes do log ({Level})ā
Logger: homeassistant.config
Source: config.py:816
First occurred: 19:07:44 (1 occurrences)
Last logged: 19:07:44
Invalid config for [sensor.template]: value is not allowed for dictionary value @ data[āsensorsā][āecā][ādevice_classā]. Got āECā value is not allowed for dictionary value @ data[āsensorsā][āphā][ādevice_classā]. Got āpHā. (See /config/sensor.yaml, line 8). Please check the docs at https://www.home-assistant.io/integrations/template
Iām trying hard to make this work, but all I get is the time when set up as above. Perhaps I donāt understand the āSensor.sensore_thingspeakā part of the Value_Template. Where does sensore_thingspeak come from?
Anyone got recent working example? Or an example of code for MQTT subscribe to Thingspeak?
Hi Albert! I am also looking to accept data from an API key and I have four fields of data. Iāve tried recreating your code but it seems that only Sensor_ThingSpeak shows a change in time. The other sensors are not accepting any information. Can you maybe spot my mistake?
When you get into developer tools ā states, can u see all the necessary fields for the Sensor Thingsspeak under attributes? For me i can only see the last updated time and no attributes.