REST Sensor

Morning,

I currently am using a device which publishes data via a Webhook which updates a Rest sensor in HA. The device is battery powered so sleeps for an hour, before waking at which point a Webhook is updated. The device seems to regularly unavailable in HA. Is there anyway to set the device to update purely when it receives Webhook updates? I’ve increased the polling interval, however that doesn’t seem to change anything.


  - platform: rest
    resource: !secret iparcelbox_rest_api
    name: iParcelBox
    json_attributes:
      - webhook
      - licence
      - message
      - result
      - data
    value_template: "{{ value_json['data']['boxStatus'] }}"
    username: !secret iparcelbox_username
    password: !secret iparcelbox_password
    authentication: digest
    verify_ssl: False
    scan_interval: 25900 #7 hours

Not sure you’re doing it right.

You can use the HA rest api to create/update a sensor directly, no need to declare it beforehand.

curl example from the doc REST API | Home Assistant Developer Docs (home-assistant.io)

curl -X POST -H "Authorization: Bearer ABCDEFGH" \
  -H "Content-Type: application/json" \
  -d '{"state": "25", "attributes": {"unit_of_measurement": "°C"}}' \
  http://my_ha_instance:8123/api/states/sensor.kitchen_temperature´´´

Thanks Chris,

I’m using a automation and script designed by someone else, not a expert in HA. The device works correctly, however it seems to go unavailable when the device sleeps, even if the device isn’t set to pole.