solmoller
(Henrik Møller Jørgensen)
January 23, 2022, 12:55pm
1
How do I get medium-sized datasets into hass?
I am using REST from external sources, but as I don’t have a webserver I need some other way to get a few thousand numbers into hass.
I’ve spent two days fiddling with MQTT now, only to realize, that packages apparently are limited to 256 bytes:
I want to use text strings that are longer than 256 characters. I thought I could publish them to MQTT (I can) and then be able to do something with them in HA (I can’t).
The only way I can think of to get them into HA is using an MQTT Sensor but I have now found that that also has a size limit of 256 characters
Is there any way to ‘read’ a long payload? It doesn’t need to be stored, I can use it dynamically while it is in memory.
and
My configuration.yaml:
- platform: mqtt
name: "Prognoser"
state_topic: "homeassistant/prognoser"
unit_of_measurement: ""
value_template : "{{ value_json }}"
Without the last line I can get data into hass, with the last line, it drops the messages - and I’ll probably still have the 256 bytes limitation.
seems to be an option, but is there anything better?
cyn
January 23, 2022, 1:56pm
2
Attributes don’t have the size restriction
solmoller
(Henrik Møller Jørgensen)
January 23, 2022, 3:11pm
3
Thanks!
I’ve tried to add attributes to my communication, and it worked - after having found out that strings were a no-no
Here’s an example of using json_attributes_template.
If given this topic:
sensor/cpu
and this payload:
{
"used_space": 25,
"sys_clock_speed": 1500,
"data": {
"cpu_temp": 43.0,
"voltage": 0.8500,
"cpu_load": 1.25
},
"memory": "False",
"swap": "False"
}
This MQTT Sensor extracts values from the payload and assigns them to attributes using custom names.
- platform: mqtt
name: monitor
state_topic: sensor/cpu
value_template: "{{ value_json.used_space }}"
json_attr…
Case closed