String length limit on attributes

From already established attribute sensor.spacex, this is the data:

mission_name: Es’hail 2
launch_site: {
  "site_id": "ccafs_slc_40",
  "site_name": "CCAFS SLC 40",
  "site_name_long": "Cape Canaveral Air Force Station Space Launch Complex 40"
}
rocket: {
  "rocket_id": "falcon9",
  "rocket_name": "Falcon 9",
  "rocket_type": "FT",
  "first_stage": {
    "cores": [
      {
        "core_serial": null,
        "flight": null,
        "block": 5,
        "reused": false,
        "land_success": null,
        "landing_intent": true,
        "landing_type": "ASDS",
        "landing_vehicle": "OCISLY"
      }
    ]
  },
  "second_stage": {
    "block": 5,
    "payloads": [
      {
        "payload_id": "Es’hail 2",
        "norad_id": [],
        "reused": false,
        "customers": [
          "Es’hailSat"
        ],
        "nationality": "Qatar",
        "manufacturer": "Mitsubishi Electric",
        "payload_type": "Satellite",
        "payload_mass_kg": 3000,
        "payload_mass_lbs": 6613.868,
        "orbit": "GTO",
        "orbit_params": {
          "reference_system": "geocentric",
          "regime": "geostationary",
          "longitude": 25.5,
          "semi_major_axis_km": null,
          "eccentricity": null,
          "periapsis_km": null,
          "apoapsis_km": null,
          "inclination_deg": null,
          "period_min": null,
          "lifespan_years": 15,
          "epoch": null,
          "mean_motion": null,
          "raan": null,
          "arg_of_pericenter": null,
          "mean_anomaly": null
        }
      }
    ]
  },
  "fairings": {
    "reused": false,
    "recovery_attempt": false,
    "recovered": false,
    "ship": null
  }
}
details: SpaceX's eighteenth flight of 2018 will be its first for Es'hailSat. Es'hail-2 is a communications satellite that will deliver television and internet to Qatar and the surrounding region. It will be launched into a geostationary transfer orbit from LC-39A at Kennedy Space Center. The booster is expected to land on OCISLY.
friendly_name: SpaceX

These templates work:

spacex_next_launch:
  value_template: "{{ states.sensor.spacex.state | int | timestamp_custom('%a, %b %d at %I:%M %p')}}"
spacex_next_rocket:
  value_template: "{{ states.sensor.spacex.attributes['rocket']['rocket_name'] }}"
spacex_next_launch_site:
  value_template: "{{ states.sensor.spacex.attributes['launch_site']['site_name_long'] }}"
spacex_next_mission_name:
  value_template: "{{ states.sensor.spacex.attributes['mission_name'] }}"

This one doesn’t:

spacex_next_text:
  value_template: "{{ states.sensor.spacex.attributes['details'] }}"

What am I missing here? Is there a string length limit?

There’s a limit of 255 characters on most strings. But you should still get 255 characters I believe.

That string is at 324.

Yep, 255 characters. From memory, you should see errors for your spacex_next_text sensor in the HA log.

You can use the truncate function to limit your length like this:

spacex_next_text:
  value_template: "{{ states.sensor.spacex.attributes['details'] | truncate(255) }}"
1 Like

Is there a method to trim it?

Also, I’m pretty sure you can use notify to send the full msg out. Your problem is trying to store the value in a template sensor.

1 Like

BRILLIANT!
Thank you both. I will be implementing both methods.