angelnu / home_assistant_thethingsnetwork

TheThingsNetwork v3 integration for Home Assistant
33 stars 8 forks source link

Extract nested JSON value #13

Open ELV-Elektronik-AG opened 1 year ago

ELV-Elektronik-AG commented 1 year ago

Hi, i want to extract a nested json value from my payload to show it on a dashboard view. The Payload-Json looks as the following:

"decoded_payload": { "battery_voltage": { "unit": "V", "value": 3.159 }, "temperature": { "room_temperature": { "unit": "°C", "value": "22.4" }, "set_point_temperature": { "unit": "°C", "value": "23.0" } }, "valve_position": { "current_position": { "unit": "%", "value": 28 } } },

Currently i can only acces the fields battery_voltage.unit and battery_voltage.value but not the other ones. I already tried to acces these fields with device temperature_room_temperature_value but it's not working

Any sugesstions are welcome and thanks in advance

Tammo

angelnu commented 1 year ago

Hi @ELV-Elektronik-AG ,

the adaptor currently expect the values in decoded_payload to be one of the following:

Supporting the values decoded by your Lora devices would require expanding the dictionary decoding part to distinct between GPS and your format. You have nested dictionaries so it would also need to expand them so they show up as temperature_room_temperatureand temperature_set_point_temperature

Of course the other option would be to adapt the decoder but I do not expect that to be practical.

If possible and to get this extension merged faster a PR would be appreciated as I have the next couple of weeks rather busy. I happen to have a couple of your ELV Lora devices at home for a future project so I am quite interested in this working :-)