Variables returning "none" - how to set anyway

I have a variable that returns “none” and in the automation it expects a “float” value:

  - variables:

      initialrv: "{{ state_attr('media_player.rv','volume_level') }}"

...THEN LATER, I TRY TO USE IT

  - data:
      volume_level: 0.6
    target:
      entity_id:
        - media_player.rv
    action: media_player.volume_set
  - data:
      message: "{{ message }}"
    action: notify.alexa_media_rv
  - data:
      volume_level: "{{initialrv}}". <----- FAILS 
    target:
      entity_id:
        - media_player.rv
    action: media_player.volume_set

is there a way to just set the variable to a value like 0.3 if it fails to get set or is unavailable initially?

Use the default filter.

  - variables:
      initialrv: "{{ state_attr('media_player.rv','volume_level') | default(0.3, true) }}"

FWIW, there is a . at the end of the line volume_level: "{{initialrv}}". that should not be there.

Nice! thanks!