mirror of
https://github.com/esphome/esphome.git
synced 2024-11-23 23:48:11 +01:00
formatting
This commit is contained in:
parent
c908cfc9cd
commit
2c148246fb
2 changed files with 34 additions and 6 deletions
|
@ -364,12 +364,14 @@ CONFIG_SCHEMA = (
|
||||||
FREQUENCY_SCHEMA = automation.maybe_simple_id(
|
FREQUENCY_SCHEMA = automation.maybe_simple_id(
|
||||||
{
|
{
|
||||||
cv.GenerateID(): cv.use_id(KT0803Component),
|
cv.GenerateID(): cv.use_id(KT0803Component),
|
||||||
cv.Required(CONF_FREQUENCY): cv.float_range(min = 70, max = 108),
|
cv.Required(CONF_FREQUENCY): cv.float_range(min=70, max=108),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action("kt0803.set_frequency", SetFrequencyAction, FREQUENCY_SCHEMA)
|
@automation.register_action(
|
||||||
|
"kt0803.set_frequency", SetFrequencyAction, FREQUENCY_SCHEMA
|
||||||
|
)
|
||||||
async def tune_frequency_action_to_code(config, action_id, template_arg, args):
|
async def tune_frequency_action_to_code(config, action_id, template_arg, args):
|
||||||
var = cg.new_Pvariable(action_id, template_arg)
|
var = cg.new_Pvariable(action_id, template_arg)
|
||||||
await cg.register_parented(var, config[CONF_ID])
|
await cg.register_parented(var, config[CONF_ID])
|
||||||
|
@ -378,7 +380,7 @@ async def tune_frequency_action_to_code(config, action_id, template_arg, args):
|
||||||
cg.add(var.set_frequency(template_))
|
cg.add(var.set_frequency(template_))
|
||||||
return var
|
return var
|
||||||
|
|
||||||
|
|
||||||
async def set_var(config, id, setter):
|
async def set_var(config, id, setter):
|
||||||
if c := config.get(id):
|
if c := config.get(id):
|
||||||
cg.add(setter(c))
|
cg.add(setter(c))
|
||||||
|
|
|
@ -25,6 +25,34 @@ namespace kt0803 {
|
||||||
void set_##name##_text(text::Text *text) { this->name##_text_ = text; }
|
void set_##name##_text(text::Text *text) { this->name##_text_ = text; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define SUB_NUMBER_EX(name) \
|
||||||
|
SUB_NUMBER(name) \
|
||||||
|
void publish_##name() { this->publish(this->name##_number_, (float) this->get_##name()); }
|
||||||
|
|
||||||
|
#define SUB_SWITCH_EX(name) \
|
||||||
|
SUB_SWITCH(name) \
|
||||||
|
void publish_##name() { this->publish_switch(this->name##_switch_, this->get_##name()); }
|
||||||
|
|
||||||
|
#define SUB_SELECT_EX(name) \
|
||||||
|
SUB_SELECT(name) \
|
||||||
|
void publish_##name() { this->publish_select(this->name##_select_, (size_t) this->get_##name()); }
|
||||||
|
|
||||||
|
#define SUB_TEXT_EX(name) \
|
||||||
|
SUB_TEXT(name) \
|
||||||
|
void publish_##name() { this->publish(this->name##_text_, this->get_##name()); }
|
||||||
|
|
||||||
|
#define SUB_SENSOR_EX(name) \
|
||||||
|
SUB_SENSOR(name) \
|
||||||
|
void publish_##name() { this->publish(this->name##_sensor_, (float) this->get_##name()); }
|
||||||
|
|
||||||
|
#define SUB_BINARY_SENSOR_EX(name) \
|
||||||
|
SUB_BINARY_SENSOR(name) \
|
||||||
|
void publish_##name() { this->publish(this->name##_binary_sensor_, this->get_##name()); }
|
||||||
|
|
||||||
|
#define SUB_TEXT_SENSOR_EX(name) \
|
||||||
|
SUB_TEXT_SENSOR(name) \
|
||||||
|
void publish_##name() { this->publish(this->name##_text_sensor_, this->get_##name()); }
|
||||||
|
|
||||||
class KT0803Component : public PollingComponent, public i2c::I2CDevice {
|
class KT0803Component : public PollingComponent, public i2c::I2CDevice {
|
||||||
ChipId chip_id_; // no way to detect it
|
ChipId chip_id_; // no way to detect it
|
||||||
bool reset_;
|
bool reset_;
|
||||||
|
@ -200,9 +228,7 @@ class KT0803Component : public PollingComponent, public i2c::I2CDevice {
|
||||||
|
|
||||||
template<typename... Ts> class SetFrequencyAction : public Action<Ts...>, public Parented<KT0803Component> {
|
template<typename... Ts> class SetFrequencyAction : public Action<Ts...>, public Parented<KT0803Component> {
|
||||||
TEMPLATABLE_VALUE(float, frequency)
|
TEMPLATABLE_VALUE(float, frequency)
|
||||||
void play(Ts... x) override {
|
void play(Ts... x) override { this->parent_->set_frequency(this->frequency_.value(x...)); }
|
||||||
this->parent_->set_frequency(this->frequency_.value(x...));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace kt0803
|
} // namespace kt0803
|
||||||
|
|
Loading…
Reference in a new issue