How to get last valid valir, bigher than x, from densor?

Hi.
I have a sensor that is an scale in my daughter bed. This sensor is always off and just turn on once a day, at 3am. Is its possible to get the last valid valie that is bigher than X using script?
I would like to run this script during the day ( when sensor is off) and get the last value, bit not when its smaller than 1kg, for example ( false value).
It is possible? How do i do this?
Tks

this is probably not the most elegant way, but you could create a ‘number’ helper entity and then use an automation to trigger whenever the scale measurement is >1kg to set the value of the number entity to the measured weight

Something like this:

alias: Last_Valid_Weight
description: ""
trigger:
  - platform: state
    entity_id: sensor.child_bed_weight
    id: child_bed_weight
condition:
  - condition: numeric_state
    entity_id: sensor.child_bed_weight
    above: 1.0
action:
  - service: input_number.set_value
    data:
      value: |
        {{states('sensor.child_bed_weight')}}
    target:
      entity_id: input_number.last_valid_weight
mode: queued
max: 10