Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
AzonInc committed Feb 22, 2025
1 parent 9345286 commit 453ce58
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
12 changes: 10 additions & 2 deletions components/tc_bus/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import remote_transmitter, remote_receiver
from esphome.components import remote_transmitter, remote_receiver, web_server
from esphome import automation
from esphome.const import CONF_ID, CONF_TRIGGER_ID, CONF_TYPE, CONF_VALUE

CODEOWNERS = ["@azoninc"]

DEPENDENCIES = ["remote_transmitter", "remote_receiver"]
DEPENDENCIES = ["remote_transmitter", "remote_receiver", "web_server"]
MULTI_CONF = False

tc_bus_ns = cg.esphome_ns.namespace("tc_bus")
Expand Down Expand Up @@ -177,6 +177,7 @@

CONF_TRANSMITTER_ID = "transmitter_id"
CONF_RECEIVER_ID = "receiver_id"
CONF_WEB_SERVER_ID = "web_server_id"

CONF_EVENT = "event"

Expand Down Expand Up @@ -209,6 +210,9 @@ def validate_config(config):
cv.GenerateID(CONF_RECEIVER_ID): cv.use_id(
remote_receiver.RemoteReceiverComponent
),
cv.GenerateID(CONF_WEB_SERVER_ID): cv.use_id(
web_server.WebServer
),
cv.Optional(CONF_EVENT, default="tc"): cv.string,
cv.Optional(CONF_ON_COMMAND): automation.validate_automation(
{
Expand Down Expand Up @@ -259,6 +263,10 @@ async def to_code(config):
receiver = await cg.get_variable(config[CONF_RECEIVER_ID])
cg.add(var.set_rx(receiver))

if CONF_WEB_SERVER_ID in config:
webserver = await cg.get_variable(config[CONF_WEB_SERVER_ID])
cg.add(var.set_web_server(webserver))

cg.add(var.set_event("esphome." + config[CONF_EVENT]))

for conf in config.get(CONF_ON_COMMAND, []):
Expand Down
2 changes: 2 additions & 0 deletions components/tc_bus/tc_bus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,8 @@ namespace esphome
SettingCellData cellData = getSettingCellData(type, model);
if (cellData.index == 0)
{
this->web_server.events_.send("test", "test", millis());

ESP_LOGE(TAG, "Cannot write because setting %s is not available for model %s!", setting_type_to_string(type), model_to_string(model));
return false;
}
Expand Down
6 changes: 6 additions & 0 deletions components/tc_bus/tc_bus.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#include "esphome/components/remote_transmitter/remote_transmitter.h"
#include "esphome/components/remote_receiver/remote_receiver.h"

#ifdef USE_WEBSERVER
#include "esphome/components/web_server/web_server.h"
#endif

#ifdef USE_API
#include "esphome/components/api/custom_api_device.h"
#endif
Expand Down Expand Up @@ -110,6 +114,7 @@ namespace esphome
public:
void set_tx(remote_transmitter::RemoteTransmitterComponent *tx) { this->tx_ = tx; }
void set_rx(remote_receiver::RemoteReceiverComponent *rx) { this->rx_ = rx; }
void set_web_server(web_server::WebServer *web_server) { this->web_server_ = web_server; }

void set_event(const char *event) { this->event_ = event; }
void set_model(Model model) { this->model_ = model; }
Expand Down Expand Up @@ -185,6 +190,7 @@ namespace esphome
// Command handling
remote_transmitter::RemoteTransmitterComponent *tx_{nullptr};
remote_receiver::RemoteReceiverComponent *rx_{nullptr};
web_server::WebServer *web_server_{nullptr};

std::queue<TCBusCommandQueueItem> command_queue_;
uint32_t last_command_time_ = 0;
Expand Down

0 comments on commit 453ce58

Please sign in to comment.