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 3d7d10f commit 273d839
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion components/tcs_intercom/binary_sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
await binary_sensor.register_binary_sensor(var, config)
cg.add(var.set_command(config[CONF_COMMAND]))

command_template = await cg.templatable(config[CONF_COMMAND], [(cg.uint32_t, "x")], cg.uint32_t)
cg.add(var.set_command_template(command_template))

cg.add(var.set_auto_off(config[CONF_AUTO_OFF]))
tcs_intercom = await cg.get_variable(config[CONF_TCS_ID])
cg.add(tcs_intercom.register_listener(var))
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace esphome

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

} // namespace tcs_intercom
Expand Down
2 changes: 1 addition & 1 deletion components/tcs_intercom/tcs_intercom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ namespace esphome
{
if (listener->command_ == command)
{
ESP_LOGD(TAG, "Binary sensor fired! %x", listener->command_);
ESP_LOGD(TAG, "Binary sensor fired! %x", listener->command_value_);
listener->turn_on(&listener->timer_, listener->auto_off_);
}
}
Expand Down
6 changes: 4 additions & 2 deletions components/tcs_intercom/tcs_intercom.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ namespace esphome
class TCSIntercomListener
{
public:
void set_command(uint32_t command) { this->command_ = command; }
void set_command_template(std::function<uint32_t()> command_template) { command_template_ = command_template; }
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 timer_;
uint32_t command_;
uint16_t auto_off_;
};

Expand Down

0 comments on commit 273d839

Please sign in to comment.