def remove_state(api, entity_id):
    try:
        req = api(METHOD_DELETE, URL_API_STATES_ENTITY.format(entity_id))

        if req.status_code in (200, 404):
            return True

        _LOGGER.error("Error removing state: %d - %s",
                      req.status_code, req.text)
        return False
    except HomeAssistantError:
        _LOGGER.exception("Error removing state")

        return False
Call API to remove state for entity_id.
dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/remote.py/remove_state