Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AzonInc committed Sep 30, 2024
1 parent f8dfe85 commit 2a7a4e6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
31 changes: 31 additions & 0 deletions components/tc_bus/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,37 @@ namespace esphome
return data;
}

CommandType string_to_command_type(const std::string& str)
{
if (str == "DOOR_CALL") return COMMAND_TYPE_DOOR_CALL;
if (str == "FLOOR_CALL") return COMMAND_TYPE_FLOOR_CALL;
if (str == "INTERNAL_CALL") return COMMAND_TYPE_INTERNAL_CALL;
if (str == "CONTROL_FUNCTION") return COMMAND_TYPE_CONTROL_FUNCTION;
if (str == "START_TALKING_DOOR_STATION") return COMMAND_TYPE_START_TALKING_DOOR_STATION;
if (str == "START_TALKING_IA") return COMMAND_TYPE_START_TALKING_IA;
if (str == "STOP_TALKING_DOOR_STATION") return COMMAND_TYPE_STOP_TALKING_DOOR_STATION;
if (str == "STOP_TALKING_IA") return COMMAND_TYPE_STOP_TALKING_IA;
if (str == "OPEN_DOOR") return COMMAND_TYPE_OPEN_DOOR;
if (str == "LIGHT") return COMMAND_TYPE_LIGHT;
if (str == "DOOR_OPENED") return COMMAND_TYPE_DOOR_OPENED;
if (str == "DOOR_CLOSED") return COMMAND_TYPE_DOOR_CLOSED;
if (str == "END_OF_RINGTONE") return COMMAND_TYPE_END_OF_RINGTONE;
if (str == "END_OF_DOOR_READINESS") return COMMAND_TYPE_END_OF_DOOR_READINESS;
if (str == "INITIALIZE_DOOR_STATION") return COMMAND_TYPE_INITIALIZE_DOOR_STATION;
if (str == "RESET") return COMMAND_TYPE_RESET;
if (str == "SELECT_DEVICE_GROUP") return COMMAND_TYPE_SELECT_DEVICE_GROUP;
if (str == "SELECT_DEVICE_GROUP_RESET") return COMMAND_TYPE_SELECT_DEVICE_GROUP_RESET;
if (str == "SEARCH_DEVICES") return COMMAND_TYPE_SEARCH_DEVICES;
if (str == "FOUND_DEVICE") return COMMAND_TYPE_FOUND_DEVICE;
if (str == "FOUND_DEVICE_SUBSYSTEM") return COMMAND_TYPE_FOUND_DEVICE_SUBSYSTEM;
if (str == "PROGRAMMING_MODE") return COMMAND_TYPE_PROGRAMMING_MODE;
if (str == "READ_MEMORY_BLOCK") return COMMAND_TYPE_READ_MEMORY_BLOCK;
if (str == "SELECT_MEMORY_PAGE") return COMMAND_TYPE_SELECT_MEMORY_PAGE;
if (str == "WRITE_MEMORY") return COMMAND_TYPE_WRITE_MEMORY;

return COMMAND_TYPE_UNKNOWN;
}

const char* command_type_to_string(CommandType type)
{
switch (type)
Expand Down
2 changes: 2 additions & 0 deletions components/tc_bus/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,7 @@ namespace esphome
CommandData parseCommand(uint32_t command);

const char* command_type_to_string(CommandType type);
const CommandType* string_to_command_type(char type);

} // namespace tc_bus
} // namespace esphome
2 changes: 1 addition & 1 deletion firmware/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ api:
serial_number: int
then:
- tc_bus.send:
type: !lambda 'return type;'
type: !lambda 'return string_to_command_type(type);'
address: !lambda 'return address;'
payload: !lambda 'return payload;'
serial_number: !lambda 'return serial_number;'
Expand Down

0 comments on commit 2a7a4e6

Please sign in to comment.