Skip to content

Commit

Permalink
Add Support for TASTA (TC60, VIVO) Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
AzonInc committed Jan 23, 2025
1 parent 6558b4f commit 38f4229
Show file tree
Hide file tree
Showing 18 changed files with 455 additions and 319 deletions.
14 changes: 8 additions & 6 deletions components/tc_bus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@
SETTING_TYPE = tc_bus_ns.enum("SettingType")
SETTING_TYPES = {
"ringtone_floor_call": SETTING_TYPE.SETTING_RINGTONE_FLOOR_CALL,
"ringtone_door_call": SETTING_TYPE.SETTING_RINGTONE_DOOR_CALL,
"ringtone_entrance_door_call": SETTING_TYPE.SETTING_RINGTONE_ENTRANCE_DOOR_CALL,
"ringtone_second_entrance_door_call": SETTING_TYPE.SETTING_RINGTONE_SECOND_ENTRANCE_DOOR_CALL,
"ringtone_internal_call": SETTING_TYPE.SETTING_RINGTONE_INTERNAL_CALL,
"volume_ringtone": SETTING_TYPE.SETTING_VOLUME_RINGTONE,
"volume_handset": SETTING_TYPE.SETTING_VOLUME_HANDSET
"volume_handset_door": SETTING_TYPE.SETTING_VOLUME_HANDSET_DOOR,
"volume_handset_internal": SETTING_TYPE.SETTING_VOLUME_HANDSET_INTERNAL
}

COMMAND_TYPE = tc_bus_ns.enum("CommandType")
Expand Down Expand Up @@ -136,9 +138,9 @@
"TCS IVW2221 / Koch Sky R1.00",
"TCS IVW3011 / Koch Skyline Plus",
"TCS IVW3012 / Koch Skyline/Aldup",
"VMH",
"VML",
"VMF",
"TCS VMH / Koch VMH",
"TCS VML / Koch VML",
"TCS VMF / Koch VMF",
"Jung TKIS",
"Jung TKISV",
"TCS CAIXXXX / Koch CAIXXXX",
Expand Down Expand Up @@ -405,7 +407,7 @@ async def tc_bus_read_memory_to_code(config, action_id, template_args, args):
}
),
)
async def tc_bus_read_version_to_code(config, action_id, template_args, args):
async def tc_bus_request_version_to_code(config, action_id, template_args, args):
parent = await cg.get_variable(config[CONF_ID])
var = cg.new_Pvariable(action_id, template_args, parent)

Expand Down
2 changes: 1 addition & 1 deletion components/tc_bus/automation.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace esphome
TCBusIdentifyAction(TCBusComponent *parent) : parent_(parent) {}
TEMPLATABLE_VALUE(uint32_t, serial_number)

void play(Ts... x) { this->parent_->read_version(this->serial_number_.value(x...)); }
void play(Ts... x) { this->parent_->request_version(this->serial_number_.value(x...)); }

protected:
TCBusComponent *parent_;
Expand Down
28 changes: 21 additions & 7 deletions components/tc_bus/number/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
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)
VolumeHandsetDoorCallNumber = tc_bus_ns.class_("VolumeHandsetDoorCallNumber", number.Number, cg.Component)
VolumeHandsetInternalCallNumber = tc_bus_ns.class_("VolumeHandsetInternalCallNumber", number.Number, cg.Component)
VolumeRingtoneNumber = tc_bus_ns.class_("VolumeRingtoneNumber", number.Number, cg.Component)

CONF_SERIAL_NUMBER = "serial_number"
CONF_VOLUME_HANDSET = "volume_handset"
CONF_VOLUME_HANDSET_DOOR_CALL = "volume_handset_door_call"
CONF_VOLUME_HANDSET_INTERNAL_CALL = "volume_handset_internal_call"
CONF_VOLUME_RINGTONE = "volume_ringtone"

CONFIG_SCHEMA = cv.Schema(
Expand All @@ -25,8 +27,13 @@
entity_category=ENTITY_CATEGORY_CONFIG,
icon="mdi:numeric"
).extend({ cv.Optional(CONF_MODE, default="BOX"): cv.enum(NUMBER_MODES, upper=True), }),
cv.Optional(CONF_VOLUME_HANDSET): number.number_schema(
VolumeHandsetNumber,
cv.Optional(CONF_VOLUME_HANDSET_DOOR_CALL): number.number_schema(
VolumeHandsetDoorCallNumber,
entity_category=ENTITY_CATEGORY_CONFIG,
icon="mdi:volume-high"
),
cv.Optional(CONF_VOLUME_HANDSET_INTERNAL_CALL): number.number_schema(
VolumeHandsetInternalCallNumber,
entity_category=ENTITY_CATEGORY_CONFIG,
icon="mdi:volume-high"
),
Expand All @@ -49,12 +56,19 @@ async def to_code(config):
await cg.register_parented(n, config[CONF_TC_ID])
cg.add(tc_bus_component.set_serial_number_number(n))

if volume_handset := config.get(CONF_VOLUME_HANDSET):
if volume_handset_door_call := config.get(CONF_VOLUME_HANDSET_DOOR_CALL):
n = await number.new_number(
volume_handset_door_call, min_value=0, max_value=7, step=1
)
await cg.register_parented(n, config[CONF_TC_ID])
cg.add(tc_bus_component.set_volume_handset_door_call_number(n))

if volume_handset_internal_call := config.get(CONF_VOLUME_HANDSET_INTERNAL_CALL):
n = await number.new_number(
volume_handset, min_value=0, max_value=7, step=1
volume_handset_internal_call, min_value=0, max_value=7, step=1
)
await cg.register_parented(n, config[CONF_TC_ID])
cg.add(tc_bus_component.set_volume_handset_number(n))
cg.add(tc_bus_component.set_volume_handset_internal_call_number(n))

if volume_ringtone := config.get(CONF_VOLUME_RINGTONE):
n = await number.new_number(
Expand Down
11 changes: 9 additions & 2 deletions components/tc_bus/number/volume_handset_number.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
namespace esphome {
namespace tc_bus {

void VolumeHandsetNumber::control(float value)
void VolumeHandsetDoorCallNumber::control(float value)
{
this->publish_state(value);
this->parent_->update_setting(SETTING_VOLUME_HANDSET, value, 0);
this->parent_->update_setting(SETTING_VOLUME_HANDSET_DOOR_CALL, value, 0);
}

void VolumeHandsetInternalCallNumber::control(float value)
{
this->publish_state(value);
this->parent_->update_setting(SETTING_VOLUME_HANDSET_INTERNAL_CALL, value, 0);
}


} // namespace tc_bus
} // namespace esphome
13 changes: 11 additions & 2 deletions components/tc_bus/number/volume_handset_number.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@
namespace esphome {
namespace tc_bus {

class VolumeHandsetNumber : public number::Number, public Parented<TCBusComponent> {
class VolumeHandsetDoorCallNumber : public number::Number, public Parented<TCBusComponent> {
public:
VolumeHandsetNumber() = default;
VolumeHandsetDoorCallNumber() = default;

protected:
void control(float value) override;
};


class VolumeHandsetInternalCallNumber : public number::Number, public Parented<TCBusComponent> {
public:
VolumeHandsetInternalCallNumber() = default;

protected:
void control(float value) override;
};

} // namespace tc_bus
} // namespace esphome
24 changes: 14 additions & 10 deletions components/tc_bus/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,12 @@ namespace esphome
std::transform(str.begin(), str.end(), str.begin(), ::toupper);

if (str == "RINGTONE_FLOOR_CALL") return SETTING_RINGTONE_FLOOR_CALL;
if (str == "RINGTONE_DOOR_CALL") return SETTING_RINGTONE_DOOR_CALL;
if (str == "RINGTONE_ENTRANCE_DOOR_CALL") return SETTING_RINGTONE_ENTRANCE_DOOR_CALL;
if (str == "RINGTONE_SECOND_ENTRANCE_DOOR_CALL") return SETTING_RINGTONE_SECOND_ENTRANCE_DOOR_CALL;
if (str == "RINGTONE_INTERNAL_CALL") return SETTING_RINGTONE_INTERNAL_CALL;
if (str == "VOLUME_RINGTONE") return SETTING_VOLUME_RINGTONE;
if (str == "VOLUME_HANDSET") return SETTING_VOLUME_HANDSET;
if (str == "VOLUME_HANDSET_DOOR_CALL") return SETTING_VOLUME_HANDSET_DOOR_CALL;
if (str == "VOLUME_HANDSET_INTERNAL_CALL") return SETTING_VOLUME_HANDSET_INTERNAL_CALL;

return SETTING_UNKNOWN;
}
Expand All @@ -423,10 +425,12 @@ namespace esphome
switch (type)
{
case SETTING_RINGTONE_FLOOR_CALL: return "RINGTONE_FLOOR_CALL";
case SETTING_RINGTONE_DOOR_CALL: return "RINGTONE_DOOR_CALL";
case SETTING_RINGTONE_ENTRANCE_DOOR_CALL: return "RINGTONE_ENTRANCE_DOOR_CALL";
case SETTING_RINGTONE_SECOND_ENTRANCE_DOOR_CALL: return "RINGTONE_SECOND_ENTRANCE_DOOR_CALL";
case SETTING_RINGTONE_INTERNAL_CALL: return "RINGTONE_INTERNAL_CALL";
case SETTING_VOLUME_RINGTONE: return "VOLUME_RINGTONE";
case SETTING_VOLUME_HANDSET: return "VOLUME_HANDSET";
case SETTING_VOLUME_HANDSET_DOOR_CALL: return "VOLUME_HANDSET_DOOR_CALL";
case SETTING_VOLUME_HANDSET_INTERNAL_CALL: return "VOLUME_HANDSET_INTERNAL_CALL";
default: return "UNKNOWN";
}
}
Expand Down Expand Up @@ -560,9 +564,9 @@ namespace esphome
if (str == "TCS IVW2221 / Koch Sky R1.00") return MODEL_IVW2221;
if (str == "TCS IVW3011 / Koch Skyline Plus") return MODEL_IVW3011;
if (str == "TCS IVW3012 / Koch Skyline/Aldup") return MODEL_IVW3012;
if (str == "VMH") return MODEL_VMH;
if (str == "VML") return MODEL_VML;
if (str == "VMF") return MODEL_VMF;
if (str == "TCS VMH / Koch VMH") return MODEL_VMH;
if (str == "TCS VML / Koch VML") return MODEL_VML;
if (str == "TCS VMF / Koch VMF") return MODEL_VMF;
if (str == "Jung TKIS") return MODEL_TKIS;
if (str == "Jung TKISV") return MODEL_TKISV;
if (str == "TCS CAIXXXX / Koch CAIXXXX") return MODEL_CAIXXXX;
Expand Down Expand Up @@ -732,9 +736,9 @@ namespace esphome
case MODEL_IVW2221: return "TCS IVW2221 / Koch Sky R1.00";
case MODEL_IVW3011: return "TCS IVW3011 / Koch Skyline Plus";
case MODEL_IVW3012: return "TCS IVW3012 / Koch Skyline/Aldup";
case MODEL_VMH: return "VMH";
case MODEL_VML: return "VML";
case MODEL_VMF: return "VMF";
case MODEL_VMH: return "TCS VMH / Koch VMH";
case MODEL_VML: return "TCS VML / Koch VML";
case MODEL_VMF: return "TCS VMF / Koch VMF";
case MODEL_TKIS: return "Jung TKIS";
case MODEL_TKISV: return "Jung TKISV";
case MODEL_CAIXXXX: return "TCS CAIXXXX / Koch CAIXXXX";
Expand Down
6 changes: 4 additions & 2 deletions components/tc_bus/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ namespace esphome
enum SettingType {
SETTING_UNKNOWN,
SETTING_RINGTONE_FLOOR_CALL,
SETTING_RINGTONE_DOOR_CALL,
SETTING_RINGTONE_ENTRANCE_DOOR_CALL,
SETTING_RINGTONE_SECOND_ENTRANCE_DOOR_CALL,
SETTING_RINGTONE_INTERNAL_CALL,
SETTING_VOLUME_RINGTONE,
SETTING_VOLUME_HANDSET
SETTING_VOLUME_HANDSET_DOOR_CALL,
SETTING_VOLUME_HANDSET_INTERNAL_CALL
};

enum CommandType {
Expand Down
29 changes: 22 additions & 7 deletions components/tc_bus/select/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
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)
RingtoneEntranceDoorCallSelect = tc_bus_ns.class_("RingtoneEntranceDoorCallSelect", select.Select, cg.Component)
RingtoneSecondEntranceDoorCallSelect = tc_bus_ns.class_("RingtoneSecondEntranceDoorCallSelect", select.Select, cg.Component)
RingtoneFloorCallSelect = tc_bus_ns.class_("RingtoneFloorCallSelect", select.Select, cg.Component)
RingtoneInternalCallSelect = tc_bus_ns.class_("RingtoneInternalCallSelect", select.Select, cg.Component)

CONF_MODEL = "model"
CONF_RINGTONE_DOOR_CALL = "ringtone_door_call"
CONF_RINGTONE_ENTRANCE_DOOR_CALL = "ringtone_entrance_door_call"
CONF_RINGTONE_SECOND_ENTRANCE_DOOR_CALL = "ringtone_second_entrance_door_call"
CONF_RINGTONE_FLOOR_CALL = "ringtone_floor_call"
CONF_RINGTONE_INTERNAL_CALL = "ringtone_internal_call"

Expand All @@ -25,8 +27,13 @@
entity_category=ENTITY_CATEGORY_CONFIG,
icon="mdi:doorbell-video"
),
cv.Optional(CONF_RINGTONE_DOOR_CALL): select.select_schema(
RingtoneDoorCallSelect,
cv.Optional(CONF_RINGTONE_ENTRANCE_DOOR_CALL): select.select_schema(
RingtoneEntranceDoorCallSelect,
entity_category=ENTITY_CATEGORY_CONFIG,
icon="mdi:music"
),
cv.Optional(CONF_RINGTONE_SECOND_ENTRANCE_DOOR_CALL): select.select_schema(
RingtoneSecondEntranceDoorCallSelect,
entity_category=ENTITY_CATEGORY_CONFIG,
icon="mdi:music"
),
Expand Down Expand Up @@ -55,13 +62,21 @@ async def to_code(config):
await cg.register_parented(sel, config[CONF_TC_ID])
cg.add(tc_bus_component.set_model_select(sel))

if ringtone_door_call := config.get(CONF_RINGTONE_DOOR_CALL):
if ringtone_entrance_door_call := config.get(CONF_RINGTONE_ENTRANCE_DOOR_CALL):
sel = await select.new_select(
ringtone_entrance_door_call,
options=[CONF_RINGTONES],
)
await cg.register_parented(sel, config[CONF_TC_ID])
cg.add(tc_bus_component.set_ringtone_entrance_door_call_select(sel))

if ringtone_second_entrance_door_call := config.get(CONF_RINGTONE_SECOND_ENTRANCE_DOOR_CALL):
sel = await select.new_select(
ringtone_door_call,
ringtone_second_entrance_door_call,
options=[CONF_RINGTONES],
)
await cg.register_parented(sel, config[CONF_TC_ID])
cg.add(tc_bus_component.set_ringtone_door_call_select(sel))
cg.add(tc_bus_component.set_ringtone_second_entrance_door_call_select(sel))

if ringtone_floor_call := config.get(CONF_RINGTONE_FLOOR_CALL):
sel = await select.new_select(
Expand Down
11 changes: 9 additions & 2 deletions components/tc_bus/select/ringtone_door_call_select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@
namespace esphome {
namespace tc_bus {

void RingtoneDoorCallSelect::control(const std::string &value)
void RingtoneEntranceDoorCallSelect::control(const std::string &value)
{
this->publish_state(value);
uint8_t ringtone = ringtone_to_int(value);
this->parent_->update_setting(SETTING_RINGTONE_DOOR_CALL, ringtone, 0);
this->parent_->update_setting(SETTING_RINGTONE_ENTRANCE_DOOR_CALL, ringtone, 0);
}

void RingtoneSecondEntranceDoorCallSelect::control(const std::string &value)
{
this->publish_state(value);
uint8_t ringtone = ringtone_to_int(value);
this->parent_->update_setting(SETTING_RINGTONE_SECOND_ENTRANCE_DOOR_CALL, ringtone, 0);
}

} // namespace tc_bus
Expand Down
12 changes: 10 additions & 2 deletions components/tc_bus/select/ringtone_door_call_select.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@
namespace esphome {
namespace tc_bus {

class RingtoneDoorCallSelect : public select::Select, public Parented<TCBusComponent> {
class RingtoneEntranceDoorCallSelect : public select::Select, public Parented<TCBusComponent> {
public:
RingtoneDoorCallSelect() = default;
RingtoneEntranceDoorCallSelect() = default;

protected:
void control(const std::string &value) override;
};

class RingtoneSecondEntranceDoorCallSelect : public select::Select, public Parented<TCBusComponent> {
public:
RingtoneSecondEntranceDoorCallSelect() = default;

protected:
void control(const std::string &value) override;
Expand Down
Loading

0 comments on commit 38f4229

Please sign in to comment.