mirror of
https://github.com/esphome/esphome.git
synced 2026-09-17 01:58:39 +00:00
[sprinkler] Use TemplatableValue for valve_to_start (set from C++ with raw value)
valve_to_start is set from both codegen (lambdas) and C++ code (raw size_t in sprinkler.cpp:387). Use TemplatableValue directly instead of the TEMPLATABLE_VALUE macro since TemplatableFn doesn't accept raw runtime values.
This commit is contained in:
@@ -108,7 +108,9 @@ template<typename... Ts> class StartSingleValveAction : public Action<Ts...> {
|
||||
public:
|
||||
explicit StartSingleValveAction(Sprinkler *a_sprinkler) : sprinkler_(a_sprinkler) {}
|
||||
|
||||
TEMPLATABLE_VALUE(size_t, valve_to_start)
|
||||
// valve_to_start uses TemplatableValue (not TemplatableFn) because it is set
|
||||
// from both codegen (lambdas) and C++ (raw values in sprinkler.cpp).
|
||||
template<typename V> void set_valve_to_start(V valve_to_start) { this->valve_to_start_ = valve_to_start; }
|
||||
TEMPLATABLE_VALUE(uint32_t, valve_run_duration)
|
||||
|
||||
void play(const Ts &...x) override {
|
||||
@@ -118,6 +120,7 @@ template<typename... Ts> class StartSingleValveAction : public Action<Ts...> {
|
||||
|
||||
protected:
|
||||
Sprinkler *sprinkler_;
|
||||
TemplatableValue<size_t, Ts...> valve_to_start_{};
|
||||
};
|
||||
|
||||
template<typename... Ts> class ShutdownAction : public Action<Ts...> {
|
||||
|
||||
Reference in New Issue
Block a user