Multiple states in one entity - how to split into individual sensors

I am running CumulusMX software for my weather station and it sends out MQTT messages (“Data Update”) to my HA server. There are not many options for the MQTT message.

The Entity “sensor.cumulusmx_dataupdate” has multiple states combined in it (time, windspeed, winddir, wgust. etc.).

CumulusMX MQTT

I want to be able to split these out into individual sensors, but am unsure how to do this.

My sensor for “windspeed” right now is as follows (not working):

  - platform: template
    sensors:
      cumulusmx_windspeed:
        friendly_name: CumulusMX Wind Speed
        unit_of_measurement: 'mph'
        value_template: '{{ states.sensor.cumulusmx_dataupdate.attributes.windspeed|round }}'

Any ideas how I can do this?

I do it this way

- platform: mqtt
  state_topic: "rtl_433/Tower/14404"
  name: "Acurite Tower Humidity LR"
  unit_of_measurement: '%'
  icon: mdi:water-percent
  value_template: '{{ value_json.humidity }}'

Try this{{ state_attr('sensor.cumulusmx_dataupdate', 'windspeed') }}

Getting closer, I think… found this, not sure how to make this work yet:
https://community.home-assistant.io/t/multiple-splits-in-value-template-in-sensor/48556/5

Please post the configuration for sensor.cumulusmx_dataupdate (as text, not a screenshot) so we can examine how it processes a received payload. Also, please post a sample payload (as text).

Thanks to all for the quick replies! The sensor.cumulusmx.dataupdate is data from MQTT, and I didn’t need to configure anything in sensors. The solution by “cyn” worked!!! Below is are my sensors so far, if this helps anyone else:

  - platform: mqtt
    state_topic: "CumulusMX/DataUpdate"
    name: "Davis Windspeed"
    unit_of_measurement: 'mph'
    icon: mdi:weather-windy
    value_template: '{{ value_json.windspeed }}'
    
  - platform: mqtt
    state_topic: "CumulusMX/DataUpdate"
    name: "Davis Wind Direction"
    unit_of_measurement: ''
    icon: mdi:windsock
    value_template: '{{ value_json.winddir }}'
    
  - platform: mqtt
    state_topic: "CumulusMX/DataUpdate"
    name: "Davis Wind Gust"
    unit_of_measurement: 'mph'
    icon: mdi:tailwind
    value_template: '{{ value_json.wgust }}'

Thanks all, you saved me hours of trial and error and reverse engineering, and I already tried doing that.

Ugh. Too early, not enough coffee. Here WAS the original MQTT sensor (not needed anymore):

  - platform: mqtt
    name: "CumulusMX_DataUpdate"
    state_topic: "CumulusMX/DataUpdate"
1 Like

FWIW, the technique is found in the documentation for MQTT Sensor and includes at least two examples.

You also have the option to use json_attributes_template to import all parameters as separate attributes into a single sensor. It’s compact but its drawback is that there’s no automatically generated History Graph for each attribute.

Thanks for the link! I think I looked in there previously, but have only used MQTT for a few IoT devices in the distant past, and this was a little confusing. Saving the link for future reference. The sensors I am using now do exactly what I wanted… to display my weather station data in realtime in my HA. EPIC! Now I just need to add the rest of the sensors. There were 2 parts to solve to make this work, the HA side, and to find the Docker / CumulusMX MQTT string that needed modded to output everything I wanted to read. Thanks again to everyone!

Hi, I really want to integrate my Cumulus MX MQTT into Home Assistant, but it doesn’t work.

When I try to add “units_of_measurment” I get “Property of units_of_measurement is not allowed”
Sensor shows Davis windspeed off. Listening to topic on Mosquitto Broker only shows

{
“time”: “20:11:25”,
“windspeed”: 0,
“winddir”: 212
}


  - platform: mqtt
    state_topic: "CumulusMX/DataUpdate"
    name: "Davis windspeed"
    icon: mdi:weather-windy
    value_template: '{{ value_json.windspeed }}'```

It’s unit not units.

unit_of_measurement: 'mph'

Typo, sorry. Looks like this:

I dislike wasting my time fixing non-existent problems, don’t you?

Speaking of non-existent problems, compare this screenshot:

Screenshot from 2021-05-25 18-31-59

It passes Configuration > Server Controls > Check Configuration.

HOWEVER, you know how to make it fail the check? If you try to create it not as an MQTT Sensor but as an MQTT Binary Sensor. The unit_of_measurement option is not supported for binary_sensor.

Move your sensor configuration out of the binary_sensor: domain and into the sensor: domain and it should be fine.

1 Like

I’ve learned something today (again). Everything working like a charm right now!

Thanks for your help really appreciate it :pray: