MQTT number: unit_of_measurement and max values from topic/JSON

Hi guys,

I completed an integration of Tasmota NeoPool based entirely on MQTT entities: https://community.home-assistant.io/t/ha-neopool-mqtt-integration-of-tasmota-neopool-for-sugar-valley-hayward-aquarite-bayrol-devices/632517

I have one issue I wasn’t able to solve: one of the mqtt entities (number) has a unit_of_measurement and max value that is dependent on the hardware, but the values are contained in the JSON I’m parsing to manage the sensor.

Here’s the sensor:

    - unique_id: "neopool_mqtt_hydrolysis_setpoint"
      name: "NeoPool MQTT Hydrolysis Setpoint"
      unit_of_measurement: "g/h"
      state_topic: "tele/SmartPool/SENSOR"
      min: 0
      max: 33
      step: 1
      mode: slider
      command_topic: "cmnd/SmartPool/NPHydrolysis"
      retain: true
      optimistic: false
      value_template: >-
        {{ value_json.NeoPool.Hydrolysis.Setpoint }}
      availability_topic: "tele/SmartPool/LWT"
      payload_available: "Online"
      payload_not_available: "Offline"

And here’s the json data that provides the Unit and Max values I need to configure the MQTT Number entity:

        "Hydrolysis": {
            "Data": 0,       // NUMBER - Cell Production Value (0-100)
            "Unit": "g/h",   // (unit % or g/h depending on device/manufacturer)
            "Setpoint": 18,  // SENSOR - Production Measurement
            "Max": 33,       // SENSOR - Max Cell Production Value
            "Runtime": {
                "Total": "44T23:55:26",  // SENSOR - Cell Total Runtime (format ???)
                "Part": "44T23:55:26",   // SENSOR - ???
                "Pol1": "22T18:44:42",   // SENSOR - Cell Total Runtime at Pol1
                "Pol2": "22T05:10:44",   // SENSOR - Cell Total Runtime at Pol2
                "Changes": 386           // SENSOR - Cell Total Polarity Switches (???)
            },

I didn’t find a way to map unit_of_measurement and max to values from json: Hydrolysis.Unit and Hydrolysis.Max.

Any idea is more than welcome. Thanks. :slight_smile: