Combining multiple sensor values into an object?

Hi all-

First post here, and I just want to say thank you to all of the devs working on this. Having used a variety of platforms with ESP’s/Arduino’s in the past, ESPHome is truly amazing.

So here’s my question, and it’s very possible I’m just thinking about this incorrectly as I’ve been using HASS.io and ESPHome for about a week.

I’m pulling data from an ESP using an SHT Temperature/Humidity sensor and using this in Node-Red, but the entity states appear to be coming in separately for humidity and temperature, and what I would like to do is send ONE single data object containing the humidity/temperature state from the ESP at a given interval.

I realize the vast majority of people want to use these separate values for different things and need them as separate entities/state changes, but I am actually logging this data into an influxDB table and I’d like to not deal with joining two asynchronous streams of data. (I’m looking to insert something like id: Sensor001, humidity: 56%, temperature: 35deg, time: Date.now().

Current code for pulling the data:

# SHT 35 Temp Humidity Sensor Monitoring
sensor:
  - platform: sht3xd
    temperature:
      name: "Living Room Temperature"
      id: "temperature"
    humidity:
      name: "Living Room Humidity"
      id: "humidity"
    address: 0x44
    update_interval: 10s

I really just want to do something like:

if (id(temperature).state and id(humidity).state) {
    return { id(temperature).state, id(humidity).state }
}

if that makes any sense.

Thank you!

An entity in home assistant has one state and any number of attributes. You could possibly make a template sensor to do what you want, but it makes no sense.

I don’t know why you would use node red to put an entity state into influxdb, when home assistant has influxdb support directly.

Your whole approach is very confused.

Bahah I appreciate the input. I actually had no idea this was a thing ha automatically did… Definitely will be useful in the future. My issue is I have an unknown quantity of the same type of ESP+sensor (with a different name) being added (though esp home), and I needed a simple way to automatically pull this data into influx in the data shape I want while adding a few custom tags along the way. I also feel much more comfortable with node-red :blush: … But I did figure out there is a way to watch all state changes and filter by the partial name of a home assistant entity name i.e. rather than hardcode sensorData_1, I can just watch for changes in ‘sensorData_’ .