How to get size of int array for use in lambda, pre-definded in globals

i tried following:

#
#
# Globals zur übergreifenden Verwendung in allen LAMBDAs
# --------------------------------------------------------
globals:
    # ------------
    # interne variablen  ->
    # ------------
  - id: my_global_array
    type: int[6]
    initial_value: '{1, 2, 13, 4, 15, 77}'

text_sensor:
  - platform: template
    name: outputstring
    id: string_output
    lambda: |-
      int ii ;
      ii = id(my_global_array).size ;
      return {"Hello World"};
    #

result in HA should be : 6 as int

but a compiling error like this

/config/esphome/wemos-01.yaml: In lambda function:
/config/esphome/wemos-01.yaml:87:37: error: request for member 'size' in 'my_global_array->esphome::globals::GlobalsComponent<int [6]>::value()', which is of non-class type 'int [6]'
   87 |       ii = id(my_global_array).size ;
      |                                     ^   
*** [.pioenvs/wemos-01/src/main.cpp.o] Error 1
    lambda: |-
      int ii ;
      ii = id(my_global_array).size() ;
      return {"Hello World"};
    #
    #

brackets after size gave the same error…

Try that way, hope it helps:

      ii = sizeof(id(my_global_array)) ;

Hi, yes tried your idea.

For a 1D-array like “my_1d_array[5]” it gives “4 * 5” = 20 as a result, as integers are 4 byte long (?).

For a 2D-array like “my_2d_array[5][3]” the result is “4 * 5 * 3” = 60.

This helps to proceed. Thx alot.

For float still trying… :grinning:

now also tried with FLOAT 1D-Array.

Same here my_float_array[10] gives output of 40 meaning also 4byte for a flat constant. don’t understand but it works…

Pls comment if needed