psf
February 10, 2022, 7:41pm
1
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;
m0wlheld
(Christoph Dahlen)
February 10, 2022, 7:45pm
2
Don’t know much about ESPHome, but initial_value: '0'
is a string, not a float. Try initial_value: 0
.
psf
February 10, 2022, 8:05pm
3
No, it must be with quote as reported in Esphome description
psf
February 11, 2022, 10:15am
4
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.
kiklhorn
(Martin Kiklhorn)
March 18, 2023, 5:16am
5
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);
psf
March 18, 2023, 5:03pm
6
Thanks, i’ll try this solution