mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 17:27:59 +01:00
formatting
This commit is contained in:
parent
c908cfc9cd
commit
2c148246fb
2 changed files with 34 additions and 6 deletions
|
@ -369,7 +369,9 @@ FREQUENCY_SCHEMA = automation.maybe_simple_id(
|
|||
)
|
||||
|
||||
|
||||
@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):
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
|
|
|
@ -25,6 +25,34 @@ namespace kt0803 {
|
|||
void set_##name##_text(text::Text *text) { this->name##_text_ = text; }
|
||||
#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 {
|
||||
ChipId chip_id_; // no way to detect it
|
||||
bool reset_;
|
||||
|
@ -200,9 +228,7 @@ class KT0803Component : public PollingComponent, public i2c::I2CDevice {
|
|||
|
||||
template<typename... Ts> class SetFrequencyAction : public Action<Ts...>, public Parented<KT0803Component> {
|
||||
TEMPLATABLE_VALUE(float, frequency)
|
||||
void play(Ts... x) override {
|
||||
this->parent_->set_frequency(this->frequency_.value(x...));
|
||||
}
|
||||
void play(Ts... x) override { this->parent_->set_frequency(this->frequency_.value(x...)); }
|
||||
};
|
||||
|
||||
} // namespace kt0803
|
||||
|
|
Loading…
Reference in a new issue