Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
AzonInc committed Jun 7, 2024
1 parent 6507929 commit 15109ef
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ namespace esphome
class TCSIntercomBinarySensor : public binary_sensor::BinarySensor, public TCSIntercomListener
{
public:
void set_command_template(std::function<uint32_t()> command_template) { command_template_ = command_template; }
void turn_on(uint32_t *timer, uint16_t auto_off) override;
void turn_off(uint32_t *timer) override;
std::function<uint32_t()> command_template_;

protected:
binary_sensor::BinarySensor *incoming_command_sensor_{nullptr};
uint32_t command_;
uint32_t command_value_{0};
};

} // namespace tcs_intercom
Expand Down
2 changes: 2 additions & 0 deletions components/tcs_intercom/tcs_intercom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ namespace esphome
uint32_t now_millis = millis();
for (auto &listener : listeners_)
{
listener->command_value_ = listener->command_template_();

if (listener->timer_ && now_millis > listener->timer_)
{
listener->turn_off(&listener->timer_);
Expand Down
6 changes: 2 additions & 4 deletions components/tcs_intercom/tcs_intercom.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ namespace esphome
class TCSIntercomListener
{
public:
void set_command_template(std::function<uint32_t()> command_template) { command_template_ = command_template; }
void set_command(uint32_t command) { command_ = command; }
void set_auto_off(uint16_t auto_off) { this->auto_off_ = auto_off; }

virtual void turn_on(uint32_t *timer, uint16_t auto_off) {};
virtual void turn_off(uint32_t *timer) {};

std::function<uint32_t()> command_template_;
uint32_t command_value_{0};

uint32_t command_;
uint32_t timer_;
uint16_t auto_off_;
};
Expand Down

0 comments on commit 15109ef

Please sign in to comment.