Number template ( float) assignment

Sorry for my question, but if I simply try this simple assigment there is a “cast” mistake:

globals:
  - id: my_global
    type: float
    restore_value: no
    initial_value: '0'  
number:
  - platform: template
    id: my_number
    name: My Number
    min_value: 0
    max_value: 100
    step: 1
    optimistic: true
    on_value:
      then:
        - lambda: |-
            my_global = x;

Don’t know much about ESPHome, but initial_value: '0'is a string, not a float. Try initial_value: 0.

No, it must be with quote as reported in Esphome description

ok, wrong assignment without id()
BUT as soon as I compile and install a number action like on_value… esphome won’t boot at all, sop I have to recover with serial upload the old firmware.

number:
  - platform: template
    id: my_number
    name: My Number
    min_value: 0
    max_value: 100
    step: 1
    optimistic: true
    on_value:
      then:
        - lambda: |-
            id(my_global) = float(x);

Thanks, i’ll try this solution