All my mqtt sensor template wrong, hekp

Hi trying to understand how this works but can’t understand it
I have to setup a bunch of sensors from mqtt topic.
For example


      - unique_id: environment_depth_belowKee
        state_topic: "environment.depth.belowKee"
        name: "Depth below keel"
        device_class: distance
        value_template: '{{ value }}' 
        unit_of_measurement: "m"

that’s the format


{
  "context": "vessels.urn:mrn:imo:mmsi:2487388xxxxx,",
  "path": "environment.depth.belowKeel",
  "value": 1.871,
  "timestamp": "2024-01-18T08:00:40.131Z",
  "$source": "n2k-on-ve.can-socket.35"
}

but in developer tools state, I can see that the sensor is always unknown

Hints?

Tried also


      - unique_id: environment_depth_belowKee
        state_topic: "environment.depth.belowKee"
        name: "Depth below keel"
        device_class: distance
        value_template: '{{ value_json.value }}' 
        unit_of_measurement: "m"

same result unknown

That should work.
Look with , e.g., MQTT Explorer if you you show is indeed what’s in the MQTT topic.

Unless you have done a typo…

  "path": "environment.depth.belowKeel",

But you are looking for -

        state_topic: "environment.depth.belowKee"

missing the l at the end.

1 Like