Need help pulling in json data from mqtt

hi, I’m new to home assistant and really just trying to learn the basics. i have a RPi sending a json string through mqtt. I have mqtt working though this same set up if i send a single value (no json) but if i send a json string i can see the data at the mqtt configurator ( image below) but i can’t get a real value from the “sensor” on the dashboard.

im sure its user error, if anyone can help i would be very grateful.

it would not let me put both photos in the original post. here is the second one showing my yaml file. im only trying to pull in the first key pair for testing purposes.

Please do not post pictures of text. Post the actual text correctly formatted for the forum. See section 11 of the FAQ. How to help us help you - or How to ask a good question

hey thanks for commenting, and I am guilty in not reading the posting guidelines, thank you for suggesting it, it was a good read.

in this configuration it is the last “name” that is in question. i am trying to pull out the first key value pair in the JSON string. in this case the first key is “first” and its static value is 100. i can see this data come in in the photo above and i dont get any errors but i never see any data at the sensor level. hoping its something simple i have wrong with my syntax.

# Example configuration.yaml entry
mqtt:
  sensor:
    - name: "pico_device_1"
      state_topic: "pico/testOUT"
      unique_id: pico_output
      unit_of_measurement: °F
      device_class: temperature
    - name: "pico_device_2"
      state_topic: "pico/testOUT_2"
      unique_id: pico_output_2
      unit_of_measurement: °F
      device_class: temperature
      #- name: "sheep_feed"
      #state_topic: "outside/sheep/lora_feed"
      #unique_id: sheep_feed
      #unit_of_measurement: °F
      #device_class: temperature
    - name: "first_sheep"
      state_topic: "outside/sheep/lora_feed_2"
      unit_of_measurement: °F
      device_class: temperature
      value_template: "{{ value_json.first }}"
      unique_id: first_sheep

i am thinking the issue may be that the whole JSON sting is just that a string. and so the value to the key is a string and not an int. do i need to convert the str to an int or float, if so i cant find an example of this

What do you see when you go to Developer Tools, States for that sensor?

hi, just tested and it shows “unknown”. image below. interesting thing. it seems to know i started to send the MQTT message as the “last seen” corresponds to when i start the service, which make me think it is a conversion type error. is there another place to see errors?

Hi so if anyone looks back at this with a similar issue i now have it working by using a different mechanism to convert the dictionary to a JSON format on the publishing client ( RPI in this case) . I am now using json.dumps(dictionary to be sent). there must had been some extra or incorrect characters in my old manual way. What made me think to try this is i saw a image of someone else’s MQTT config page and the json was formatted differently in the live print out. now when i toggle JSON format it folds the keys vertically where before it would not even though the strings look identical. lesson here is if it is formatted correctly from the publishing client then the JSON will fold vertically.

image below shows print out with the JSON switch both on and off.