Skip to content

Commit

Permalink
Streamline naming
Browse files Browse the repository at this point in the history
  • Loading branch information
AzonInc committed Oct 28, 2024
1 parent 75280cb commit d631b91
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 28 deletions.
12 changes: 6 additions & 6 deletions components/tc_bus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
CODEOWNERS = ["@azoninc"]

tc_bus_ns = cg.esphome_ns.namespace("tc_bus")
TCBus = tc_bus_ns.class_("TCBusComponent", cg.Component)
TCBusComponent = tc_bus_ns.class_("TCBusComponent", cg.Component)

TCBusSendAction = tc_bus_ns.class_(
"TCBusSendAction", automation.Action
Expand Down Expand Up @@ -129,7 +129,7 @@ def validate_config(config):

CONFIG_SCHEMA = cv.Schema(
{
cv.GenerateID(): cv.declare_id(TCBus),
cv.GenerateID(): cv.declare_id(TCBusComponent),
cv.Optional(CONF_RX_PIN, default=9): pins.internal_gpio_input_pin_schema,
cv.Optional(CONF_TX_PIN, default=8): pins.internal_gpio_output_pin_schema,
cv.Optional(CONF_EVENT, default="tc"): cv.string,
Expand Down Expand Up @@ -194,7 +194,7 @@ def validate(config):
TC_BUS_SEND_SCHEMA = cv.All(
cv.Schema(
{
cv.GenerateID(): cv.use_id(TCBus),
cv.GenerateID(): cv.use_id(TCBusComponent),
cv.Optional(CONF_COMMAND): cv.templatable(cv.hex_uint32_t),
cv.Optional(CONF_TYPE): cv.templatable(cv.enum(COMMAND_TYPES, upper=False)),
cv.Optional(CONF_ADDRESS, default="0"): cv.templatable(cv.hex_uint8_t),
Expand Down Expand Up @@ -240,7 +240,7 @@ async def tc_bus_send_to_code(config, action_id, template_args, args):
TC_BUS_UPDATE_SETTING_SCHEMA = cv.All(
cv.Schema(
{
cv.GenerateID(): cv.use_id(TCBus),
cv.GenerateID(): cv.use_id(TCBusComponent),
cv.Required(CONF_TYPE): cv.templatable(cv.enum(SETTING_TYPES, upper=False)),
cv.Required(CONF_VALUE): cv.templatable(cv.hex_uint8_t),
cv.Optional(CONF_SERIAL_NUMBER, default="0"): cv.templatable(cv.hex_uint32_t),
Expand Down Expand Up @@ -276,7 +276,7 @@ async def tc_bus_update_setting_to_code(config, action_id, template_args, args):
TCBusProgrammingModeAction,
automation.maybe_simple_id(
{
cv.GenerateID(): cv.use_id(TCBus),
cv.GenerateID(): cv.use_id(TCBusComponent),
cv.Required(CONF_PROGRAMMING_MODE): cv.templatable(cv.boolean)
}
),
Expand All @@ -296,7 +296,7 @@ async def tc_bus_set_programming_mode_to_code(config, action_id, template_args,
TCBusReadMemoryAction,
automation.maybe_simple_id(
{
cv.GenerateID(): cv.use_id(TCBus),
cv.GenerateID(): cv.use_id(TCBusComponent),
cv.Optional(CONF_SERIAL_NUMBER, default=0): cv.templatable(cv.hex_uint32_t)
}
),
Expand Down
14 changes: 5 additions & 9 deletions components/tc_bus/binary_sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
import esphome.config_validation as cv
from esphome.components import binary_sensor
from esphome.const import CONF_ID, CONF_ICON, CONF_TYPE
from .. import tc_bus_ns, TCBus, CONF_TC_ID, COMMAND_TYPES
from .. import tc_bus_ns, TCBusComponent, CONF_TC_ID, COMMAND_TYPES

TCBusBinarySensor = tc_bus_ns.class_(
"TCBusBinarySensor",
binary_sensor.BinarySensor,
cg.Component
)
CommandListenerBinarySensor = tc_bus_ns.class_("CommandListenerBinarySensor", binary_sensor.BinarySensor, cg.Component)

CONF_ADDRESS = "address"
CONF_ADDRESS_LAMBDA = "address_lambda"
Expand Down Expand Up @@ -68,10 +64,10 @@ def validate(config):
return config

CONFIG_SCHEMA = cv.All(
binary_sensor.binary_sensor_schema(TCBusBinarySensor).extend(
binary_sensor.binary_sensor_schema(CommandListenerBinarySensor).extend(
{
cv.GenerateID(): cv.declare_id(TCBusBinarySensor),
cv.GenerateID(CONF_TC_ID): cv.use_id(TCBus),
cv.GenerateID(): cv.declare_id(CommandListenerBinarySensor),
cv.GenerateID(CONF_TC_ID): cv.use_id(TCBusComponent),

cv.Optional(CONF_COMMAND): cv.hex_uint32_t,
cv.Optional(CONF_COMMAND_LAMBDA): cv.returning_lambda,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#include "binary_sensor.h"
#include "command_listener_binary_sensor.h"

namespace esphome
{
namespace tc_bus
{
void TCBusBinarySensor::turn_on(uint32_t *timer, uint16_t auto_off)
void CommandListenerBinarySensor::turn_on(uint32_t *timer, uint16_t auto_off)
{
this->publish_state(true);
if (auto_off > 0) *timer = millis() + auto_off;
}

void TCBusBinarySensor::turn_off(uint32_t *timer)
void CommandListenerBinarySensor::turn_off(uint32_t *timer)
{
this->publish_state(false);
*timer = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
#pragma once

#include "../tc_bus.h"

#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
#include "esphome/components/binary_sensor/binary_sensor.h"

namespace esphome
{
namespace tc_bus
{
class TCBusBinarySensor : public binary_sensor::BinarySensor, public TCBusListener
class CommandListenerBinarySensor : public binary_sensor::BinarySensor, public TCBusListener
{
public:
void turn_on(uint32_t *timer, uint16_t auto_off) override;
Expand Down
4 changes: 2 additions & 2 deletions components/tc_bus/number/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ENTITY_CATEGORY_CONFIG,
CONF_MODE,
)
from .. import CONF_TC_ID, TCBus, tc_bus_ns
from .. import CONF_TC_ID, TCBusComponent, tc_bus_ns

SerialNumberNumber = tc_bus_ns.class_("SerialNumberNumber", number.Number, cg.Component)
VolumeHandsetNumber = tc_bus_ns.class_("VolumeHandsetNumber", number.Number, cg.Component)
Expand All @@ -19,7 +19,7 @@

CONFIG_SCHEMA = cv.Schema(
{
cv.GenerateID(CONF_TC_ID): cv.use_id(TCBus),
cv.GenerateID(CONF_TC_ID): cv.use_id(TCBusComponent),
cv.Optional(CONF_SERIAL_NUMBER): number.number_schema(
SerialNumberNumber,
entity_category=ENTITY_CATEGORY_CONFIG,
Expand Down
4 changes: 2 additions & 2 deletions components/tc_bus/select/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
CONF_ID,
ENTITY_CATEGORY_CONFIG,
)
from .. import CONF_TC_ID, CONF_MODELS, CONF_RINGTONES, TCBus, tc_bus_ns
from .. import CONF_TC_ID, CONF_MODELS, CONF_RINGTONES, TCBusComponent, tc_bus_ns

ModelSelect = tc_bus_ns.class_("ModelSelect", select.Select, cg.Component)
RingtoneDoorCallSelect = tc_bus_ns.class_("RingtoneDoorCallSelect", select.Select, cg.Component)
Expand All @@ -19,7 +19,7 @@

CONFIG_SCHEMA = cv.Schema(
{
cv.GenerateID(CONF_TC_ID): cv.use_id(TCBus),
cv.GenerateID(CONF_TC_ID): cv.use_id(TCBusComponent),
cv.Optional(CONF_MODEL): select.select_schema(
ModelSelect,
entity_category=ENTITY_CATEGORY_CONFIG,
Expand Down
4 changes: 2 additions & 2 deletions components/tc_bus/text_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
from esphome.const import (
ENTITY_CATEGORY_DIAGNOSTIC,
)
from . import CONF_TC_ID, TCBus
from . import CONF_TC_ID, TCBusComponent

DEPENDENCIES = ["tc_bus"]

CONF_BUS_COMMAND = "bus_command"
CONF_HARDWARE_VERSION = "hardware_version"

CONFIG_SCHEMA = {
cv.GenerateID(CONF_TC_ID): cv.use_id(TCBus),
cv.GenerateID(CONF_TC_ID): cv.use_id(TCBusComponent),
cv.Optional(CONF_BUS_COMMAND): text_sensor.text_sensor_schema(
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
icon="mdi:console-network",
Expand Down

0 comments on commit d631b91

Please sign in to comment.