I’m battling to pass parameters to a script in esphome and would appreciate any assistance.
I have an LED configured with different pulse patterns:
effects:
- pulse:
name: "1"
- pulse:
name: "2"
transition_length:
on_length: 450ms
off_length: 450ms
update_interval: 900ms
- pulse:
name: "3"
transition_length:
on_length: 300ms
off_length: 300ms
update_interval: 600ms
- pulse:
name: "4"
transition_length:
on_length: 120ms
off_length: 120ms
update_interval: 240ms
- pulse:
name: "5"
transition_length:
on_length: 75ms
off_length: 75ms
update_interval: 150ms
I want to pass the names (1, 2, 3, 4 or 5) to the script so that the LED pulses differently for different conditions.
The script:
script:
- id: blink_led
parameters:
pulse_type: int
then:
- light.turn_on:
id: led_yellow
effect: !lambda return pulse_type;
The call I am trying is:
- script.execute:
id: blink_led
pulse_type: !lambda 'return (id(counter));'
counter is an integer global.
The error is:
/config/esphome/psu-hass.yaml: In lambda function:
/config/esphome/psu-hass.yaml:334:16: error: could not convert ‘pulse_type’ from ‘int’ to ‘std::string’ {aka ‘std::__cxx11::basic_string’}
334 |
| ^
| |
| int
*** [.pioenvs/psu-hass/src/main.cpp.o] Error 1
I suspect that the problem is the data type being passed but I can’t figure out the correct way to do it so any help would be greatly appreciated!