Handling a string from json file

I am using the file platform to get information from a json file that is a scrape of my weatherstation.

The file looks like this:


`{"outHumi": "98", "RelPress": "1013.40", "uvi": "2", "avgwind": "0.0", "rainofyearly": "741.90", "windir": "258", "IndoorID": "0x--", "eventrain": "5.30", "solarrad": "143.75", "inTemp": "21.1", "Outdoor2ID": "0x--", "inHumi": "82", "pm25": "----", "rainofmonthly": "618.00", "rainofdaily": "0.00", "dailygust": "1.0", "Outdoor1ID": "0x61", "rainofweekly": "26.60", "AbsPress": "936.50", "rainofhourly": "0.00", "uv": "701", "outTemp": "20.4", "outBattSta2": "- -", "outBattSta1": "Normal", "inBattSta": "Normal", "gustspeed": "0.0"}`

My configuration is:

 - platform: file
     name: 'Outdoor Battery'
     file_path: /home/homeassistant/weatherStationData.json
     value_template: '{{ value_json.outBattSta }}'

to get the battery status which is currently “Normal”

In home Assistant I get something for this sensor, but not the “Normal” bit

Any ideas? Im sure its pretty simple, I just can’t find the missing bit.

Thanks
Ben

When posting JSON & YAML config please format properly.

But it looks to me like you’re trying to get the value of the outBattSta key, but there isn’t one. (There’s only outBattSta1 and outBattSta2.)

Thankyou. That was the case.

There’s outBattSta1 and inBattSta both of which I was after. I accidentally put the 1 on the end of inBattSta and not outBattSta so neither were working which had me looking for a bigger problem but not seeing the little one.

Now I get this:


Is something in the unit of measurement option the way to get rid of the graph? I searched, but I couldn’t find a list of available units.
There will be one of two values recorded: “Normal” and “Low”…?
It would be better if I could get HA to display this more like it does the UV index:

A bar like that
Apologies for the formatting, fixed?

add unit_of_measurement to it. It’s unitless, so try adding a space

unit_of_measurement: ' '

If a sensor has a unit_of_measurement attribute then it will attempt to display it in a graph. If you want a bar instead of a graph, then just remove the unit_of_measurement attribute from the sensor’s configuration. But even after you do that, there will be historical states of the sensor in the database that still contain a unit_of_measurement attribute, and those will be plotted on a graph. If you just wait long enough those state recordings will eventually be purged from the database and you won’t see a graph anymore.

Thanks, it all worked as you suggested it would