How to discard/ignore REST sensor response

Is it possible to discard/ignore an API call result in the rest platform and keep the current sensor state? Sometimes the API returns no result and I don’t want the last non-null sensor state to be overridden.

1 Like

Hi,
as I am facing the same problem, did you find a solution?
Thanks
Frank

sensor:
  - platform: rest
    resource: http://IP_ADDRESS/ENDPOINT
    value_template: >
      {% if value_json is defined %}
        {{ value_json['response'] }}
      {% else %}
        {{ this.state }}
      {% endif %}
1 Like