mirror of
https://github.com/esphome/esphome.git
synced 2025-09-09 23:02:23 +01:00
fix: update set_available_outputs method to accept a list of FloatOutput for improved output handling
This commit is contained in:
@@ -6,6 +6,11 @@
|
|||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <list>
|
||||||
|
#include <optional>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace dynamic_lamp {
|
namespace dynamic_lamp {
|
||||||
|
|
||||||
@@ -88,8 +93,9 @@ void DynamicLamp::set_save_mode(uint8_t save_mode) {
|
|||||||
this->save_mode_ = save_mode;
|
this->save_mode_ = save_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicLamp::set_available_outputs(std::string output_list) {
|
void DynamicLamp::set_available_outputs(std::list<FloatOutput> output_list) {
|
||||||
uint8_t counter = 0;
|
uint8_t counter = 0;
|
||||||
|
/*
|
||||||
std::vector<std::string> v;
|
std::vector<std::string> v;
|
||||||
|
|
||||||
char * token = strtok (&output_list[0],",");
|
char * token = strtok (&output_list[0],",");
|
||||||
@@ -108,6 +114,17 @@ void DynamicLamp::set_available_outputs(std::string output_list) {
|
|||||||
};
|
};
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
std::list<FloatOutput>::iterator output_it;
|
||||||
|
for (output_it = data.begin(); output_it != data.end(); ++output_it){
|
||||||
|
this->available_outputs_[counter] = LinkedOutput{
|
||||||
|
true,
|
||||||
|
static_cast<std::string>(this->trim_(output_it.id)),
|
||||||
|
counter,
|
||||||
|
0, 0, 1.0, false
|
||||||
|
};
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t DynamicLamp::add_lamp() {
|
uint8_t DynamicLamp::add_lamp() {
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "esphome/core/component.h"
|
#include "esphome/core/component.h"
|
||||||
|
#include "esphome/components/output/float_output.h"
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace dynamic_lamp {
|
namespace dynamic_lamp {
|
||||||
@@ -37,7 +38,7 @@ class DynamicLamp : public Component {
|
|||||||
void setup() override;
|
void setup() override;
|
||||||
void loop() override;
|
void loop() override;
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
void set_available_outputs(std::string output_list);
|
void set_available_outputs(std::list output_list);
|
||||||
void set_save_mode(uint8_t save_mode);
|
void set_save_mode(uint8_t save_mode);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Reference in New Issue
Block a user