I’ve been quite impressed with the amount of JSON experts on this huge forum who are willing to give advice…
I know I don’t do nuclear plant management with HA, but maybe there is a subforum section for simple beginner questions like this?
Btw LoRa has nothing to do with this, in this case it is a data source, but it would be the same if I had a central heating system (or anything else) with a serial output (or any other) and messages about temperature, humidity,… in 10 rooms based on room_id names… The principle is the same…
Different devices (hardware/software) have similar output formats, unified names (eg from_device, device_status,…) with corresponding values.
Considering that HA and similar software are multifunctional, I thought there was some kind of addon, integration or something to handle this type of input data…
For MQTT there is, for ZIGBEE there is, for JSON there is apparently no message parser…
In NodeRED this is piece of cake, one node, and done!
JSON messages are filtered by “from_address” to corresponding outputs. Simple.
What do you mean by “handle”? Is this data coming into HA already? What do you have, and what do you want to do with it?
It’s easy to set up e.g. a template binary sensor that only reads from_address: 35 inputs, but to help further we need to know what form the “input” into HA is. Example rest sensor if the JSON is coming from a URL:
I have a device (DIY) that communicates with several other devices.
Let’s call it a transceiver (gateway). Other devices are: EndNode1, EndNode2 and EndNode3.
Communication between the mentioned devices is LoRa and that is not important in this case.
What is important is that the transceiver (gateway) is connected to the serial port (/dev/USB0) and that it sends and receives data to EndNode1/2/3.
The message that comes to the serial port is one of the examples in the first post (depending on which EndNode corresponds).
I want to make 3 entities, each for one EndNode device, so that each one receives the data “device_type” and “device_state” depending on whether the “from_address” in the message is 10, 25 or 35.
No entities are created, I need to create them for EndNode1/2/3/n so that each shows “device_type” and “device_state” depending on whether “from_address” is 10, 25 or 35.
The serial port is configured and that part works OK (I have the data).
Okay, I managed to steal 5 minutes and make some progress:
icon: >
{% set from = (states('sensor.loramagic')|from_json)['from_address'] %}
{% set state = (states('sensor.loramagic')|from_json)['device_state'] %}
{% if from == "35" and state == "OPEN" %}
mdi:garage-open
{% elif from == "35" and state == "CLOSED" %}
mdi:garage
{% else %}
mdi:help
{% endif %}
Icon for OPEN and CLOSED work OK(“from” = 35), but problem is in
{% else %}
If there is nothing(empty), dashboard return mdi:eye , for above mentionedif/elif conditions.
Is there something like {{ this.state }} but for icon(s) or some other method to keep previous icon value?