Fetch multiple JSON values and present them as attributes UBIBOT

Ah! That’s a list.

See what this produces in the Template Editor:

{{ states.sensor.master_ubibot_test.attributes.channels[0] }}

If you replace the 0 with a 1 it should report the second channel’s data.

That returns just the first channel, and changing 0 to 1 returns the second channel.

This did it…

value_template: '{{ (states.sensor.master_ubibot_test.attributes.channels[0].last_values|from_json).field1.value|float }}'

Thanks for all your help! Where can I learn about formatting value templates more? I read some on the HA website…

The problem with the channels being represented in a list is that there may be no guarantee that the list’s first item (the zeroth item) always contains the data for channel 17577. It may sometimes contain the other channel’s data, it all depends on how the information is generated. In other words, it might always be consistent but the only way to know that would be to confirm it with the manufacturer or monitor the results over time and see if they ever swap positions in the list.

Makes sense… I have another sensor I will be setting up this weekend. I have no idea how UBIBOT assigns channel numbers… If the new sensor is numerically lower then 17577 then I guess they will reorder…

Thanks.

Wondering if you guys can help our this noob - never coded in YAML before so this is all very new to me but I have done some coding before - just not YAML. I like the other person have multiple Ubibot devices - so wanted to pull in all the data for all of them and then create sensor data entities for what I am looking for. Any help is GREATLY Appreciated. I was trying to follow your previous posts but I’m getting this error when I restart my HA:

The system cannot restart because the configuration is not valid: Invalid config for [sensor.template]: invalid template (TemplateSyntaxError: unexpected ‘)’) for dictionary value @ data[‘sensors’][‘greenhouse_humidity’][‘value_template’]. Got ‘{{ states.sensor.ubibot.attributes.channels[0].last_values|from_json).field2.value }}’ invalid template (TemplateSyntaxError: unexpected ‘)’) for dictionary value @ data[‘sensors’][‘greenhouse_temp’][‘value_template’]. Got ‘{{ states.sensor.ubibot.attributes.channels[0].last_values|from_json).field1.value|float }}’. (See ?, line ?).

Here is my Code:

The template has a closing parenthesis but is missing a matching opening parenthesis.

Add the missing opening parenthesis.

{{ (states.sensor.ubibot.attributes.channels[0].last_values|from_json).field2.value }}
   ^
   |
Add this 

Yep I noticed that JUST after I posted it - duh! Need more coffee…

OK now I see the sensors - but there is no data and says unavailable. I should be able to add the data to dashboards and use in automations correct?

what does is show in Developer Tools - States - Ubibot
Do you see all your sensors data?

Also change your API call to channels not channel for json attribute