In Home Assistant 2023.7 a feature was added to allow services to provide a response.

This release brings in a change to Home Assistant, which we consider to be one of the biggest game changers of the past years: Services can now respond with data! 🤯

It is such a fundamental change, which will allow for many new use cases and opens the gates for endless possibilities.

In this release the functionality has only been enabled for a couple of services, but I’m having trouble picturing what we can use this for now and in the future.

What are some use cases you can think of on how to use this new feature?

  • Qpernicus@lemmy.world
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    I think eventually it will lead to more call-answer automations. More granular control in automations that depend on data from the device… How high is temp? 40 degrees: turn on airco on position 5. 30? Turn on at position 4. And then more simple to write as an automation I guess. But granted I don’t fully see all the usecases yet compared to current ‘statuses ‘ of device or parameter

    • Deez@lemm.eeOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      Thanks for your reply. I’m sure I’m missing something, but in the scenario of a temperature sensor, wouldn’t that info already be available in the temperature entity’s state.

      So you could already write a script like this one:

      service: climate.set_fan_mode
      data:
        fan_mode: >
          {% if states(‘sensor.temperature’) > 40 %} 5
          {% elif 30 > states(‘sensor.temperature’) > 40 %} 4
          {% else %}  3
          {% endif %}
      target:
        entity_id: climate.bedroom_thermostat
      

      But again, I’m probably missing something.

      Thinking about the calendar service they added, maybe the response is useful for returning multiple pieces of data.

      Perhaps a use case is return a history of the previous states, so in your example, you could have a history service that could give you historical values from the temperature sensor. You call asking is the temperature trending up or down, it checks the history and provides a response. Then again, maybe you can already do that with derivative sensors.

      Sorry for the scattered response, I feel like I’m on the verge of understanding the feature, but not quite there yet.