Dynamic Deep Sleep in the Night on ESP32-C3

Hello guys, I wrote this code to make my ESP32-C3 go into deep sleep for a much longer time during the night (9 hours) compared to the daytime (1 hour).

time:
  - platform: homeassistant
    id: esptime
    on_time:
      # Deep sleep between 22:00 and 7:00 every day of the week
      - hours: 22-7
        days_of_week: MON-SUN
        then:
          - delay: 2s
          - lambda: |-
              int sleep_time_int = static_cast<int>(id(sensor_tempo_deepsleep).state);
              id(deep_sleep_1).set_run_duration(10000);
              id(deep_sleep_1).set_sleep_duration(sleep_time_int);

          - deep_sleep.enter:
              id: deep_sleep_1
              # Leave run_duration and sleep_duration configured via lambda

deep_sleep:
  id: deep_sleep_1
  run_duration: 10s  # Default run duration (10 seconds)
  sleep_duration: 60min  # Default deep sleep duration (1 hour)

The problem is that I receive this error from the compiler:

/config/esphome/esphome-web-f84c34.yaml:140:63: error: request for member 'c_str' in 'sensor_tempo_deepsleep->esphome::homeassistant::HomeassistantSensor::<anonymous>.esphome::sensor::Sensor::state', which is of non-class type 'float'

Where am I going wrong??