Infuxdb 2.0 sensor configuration

hi. I have sensor based on imap_email_content. AppDaemon script wich get some data from imap sensor and put it in template sensor. Work fine, untill reboot. After reboot my sensors equals 0. I can’t figure out how to strore my sensors to avoid 0 value after reboot. So i want to get last value from influxdb and set it to sensor at HA start. But i cat’t get right sintaxis of influxdb sensor. Can some one help me with advise or some example?

sensor:
  - platform: imap_email_content
    server: imap.gmail.com
    name: accounting_status
    port: 993
    senders:
      - [email protected]

  - platform: template
    sensors:
      data_shared:
        icon_template: mdi:piggy-bank
        friendly_name: "общий"
        value_template: 0
  - platform: influxdb
    host: 10.73.73.55
    api_version: 2
    ssl: false
    token: "_jyJg=="
    organization: testorg
    bucket: testbucket
    queries_flux:
      name: test_influx_sensor
      range_start: -7d
      query: "filter(fn: (r) => r._measurement == "RUB" and r._field == "value" and r.entity_id == "vtb_vika" and r.domain == "sensor")"

and here is my influx query:

from(bucket: "testbucket")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "RUB")
  |> filter(fn: (r) => r["_field"] == "value")
  |> filter(fn: (r) => r["entity_id"] == "vtb_vika")
  |> filter(fn: (r) => r["domain"] == "sensor")
  |> group(columns: ["value"])
  |> last()