Automation template help needed => check if attribute have a value , only after 30 secs

Hi, i have a sensor, with a scan interval of 30 secs, the first 30 secs after a HA restart it contains no data, the next loop 30 secs it contains data… now i want an automation that checks the attributes, if there is totally no data anymore in the attributes, that means my sensor polling failed, then i need todo an service action… how can i do this with an automation? its also important that it ignores the first 30 secs since there is no data then … si think some kind of FROM xxx to None check also?

The automation below doesnt work :slight_smile:

- alias: Hikconnect Relogin
  initial_state: 'on'
  trigger:
  - platform: state
    entity_id: sensor.hikconnect_callstatus
  condition:
  - condition: template
    value_template: >
      {% if not state_attr('sensor.hikconnect_callstatus', 'data') %}{% endif %}
  action:
  - service: input_boolean.turn_on
    entity_id: input_boolean.test1

You can make an automation that is triggered on startup and calls the homeassistant.update_entity service to force the sensor to be updated immediately.

Although I’m surprised it doesn’t poll automatically on startup.

If sensor polling fails, why would the sensor’s attributes no longer contain any data? Wouldn’t they simply contain the previous data they received?

Or do you mean a situation where sensor polling fails completely, from startup, and the sensor’s attributes never receive any data?

the data is json data, its a rest sensor, i send somekind of token to create that rest sensor, if there is no json attribute data anymore, i know the token is expired, and i need to start another service to extend the service