Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Smart-UPS RT 1000 XL emulator #6

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ jobs:
- name: Validate test configurations
run: |
esphome -s external_components_source ../components config tests/esp8266-apc-su420inet-emulator.yaml
esphome -s external_components_source ../components config tests/esp8266-apc-rt1000xl-emulator.yaml
esphome -s external_components_source ../components config tests/esp8266-apc-protocol.yaml

esphome-compile:
Expand Down
187 changes: 187 additions & 0 deletions tests/esp8266-apc-rt1000xl-emulator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
substitutions:
name: apc-emulator
tx_pin: GPIO4
rx_pin: GPIO5

esphome:
name: ${name}

esp8266:
board: d1_mini

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password

ota:

logger:
level: DEBUG

api:
reboot_timeout: 0s

uart:
id: uart_0
baud_rate: 2400
tx_pin: ${tx_pin}
rx_pin: ${rx_pin}
debug:
direction: BOTH
dummy_receiver: true
after:
delimiter: "\n"
sequence:
- lambda: UARTDebug::log_string(direction, bytes);
- lambda:
std::string request(bytes.begin(), bytes.end());
if(request == "Y") {
id(uart_0).write_str("SM\r\n");
return;
}
if(request == "B") {
id(uart_0).write_str("54.27\r\n");
return;
}
if(request == "C") {
id(uart_0).write_str("027.4\r\n");
return;
}
if(request == "E") {
id(uart_0).write_str("OFF\r\n");
return;
}
if(request == "F") {
id(uart_0).write_str("50.03\r\n");
return;
}
if(request == "G") {
id(uart_0).write_str("S\r\n");
return;
}
if(request == "L") {
id(uart_0).write_str("216.0\r\n");
return;
}
if(request == "M") {
id(uart_0).write_str("217.4\r\n");
return;
}
if(request == "N") {
id(uart_0).write_str("214.5\r\n");
return;
}
if(request == "O") {
id(uart_0).write_str("229.3\r\n");
return;
}
if(request == "P") {
id(uart_0).write_str("027.0\r\n");
return;
}
if(request == "Q") {
id(uart_0).write_str("08\r\n");
return;
}
if(request == "V") {
id(uart_0).write_str("5YI\r\n");
return;
}
if(request == "a") {
id(uart_0).write_str("4.!$%+?=*#|\x04.\x01\x05\t\f\x0E\x14\x16\x1A')+-/789<>@ABCDEFGKLMNOPQRSUVWXYZ\^abcdefgjklmnopqrsuwxyz~�.\x81:\xD0\xE2\xF0\xFD\xFE\xFF\r\n");
return;
}
if(request == "b") {
id(uart_0).write_str("411.7.I\r\n");
return;
}
if(request == "c") {
id(uart_0).write_str("UPS_IDEN\r\n");
return;
}
if(request == "e") {
id(uart_0).write_str("00\r\n");
return;
}
if(request == "f") {
id(uart_0).write_str("100.0\r\n");
return;
}
if(request == "g") {
id(uart_0).write_str("048\r\n");
return;
}
if(request == "h") {
id(uart_0).write_str("NA\r\n");
return;
}
if(request == "i") {
id(uart_0).write_str("NA\r\n");
return;
}
if(request == "j") {
id(uart_0).write_str("0064:\r\n");
return;
}
if(request == "k") {
id(uart_0).write_str("0\r\n");
return;
}
if(request == "l") {
id(uart_0).write_str("161\r\n");
return;
}
if(request == "m") {
id(uart_0).write_str("01/06/07\r\n");
return;
}
if(request == "n") {
id(uart_0).write_str("JS1501113445\x00\x00\r\n");
return;
}
if(request == "o") {
id(uart_0).write_str("230\r\n");
return;
}
if(request == "p") {
id(uart_0).write_str("020\r\n");
return;
}
if(request == "q") {
id(uart_0).write_str("02\r\n");
return;
}
if(request == "r") {
id(uart_0).write_str("000\r\n");
return;
}
if(request == "s") {
id(uart_0).write_str("A\r\n");
return;
}
if(request == "t") {
id(uart_0).write_str("NA\r\n");
return;
}
if(request == "u") {
id(uart_0).write_str("253\r\n");
return;
}
if(request == "v") {
id(uart_0).write_str("NA\r\n");
return;
}
if(request == "x") {
id(uart_0).write_str("01/06/21\r\n");
return;
}
if(request == "y") {
id(uart_0).write_str("(C) APCC\r\n");
return;
}
if(request == "9") {
id(uart_0).write_str("FF\r\n");
return;
}
id(uart_0).write_str("NA\r\n");
ESP_LOGD("Lambda", "Unhandled request %s", request.c_str());
Loading