Skip to content

Commit ba67543

Browse files
Merge pull request #26 from vzakharchenko/fixed_mikrotik_scripts
update Mikrotik Scripts
2 parents f904956 + d5f5a24 commit ba67543

File tree

5 files changed

+41
-35
lines changed

5 files changed

+41
-35
lines changed

.github/workflows/docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ jobs:
3333
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/arm/v7
3434
push: true
3535
tags: |
36-
vassio/smartthings-phevctl:1.3.10
36+
vassio/smartthings-phevctl:1.4.0
3737
vassio/smartthings-phevctl:latest

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ RUN cd /opt/phevctl/phevcore && mkdir build && cd build && cmake .. && make && m
2222
RUN cd /opt/phevctl/phevctl && mkdir -p build && cd build && cmake .. && make
2323
RUN ln -sf /opt/phevctl/phevctl/build/phevctl /usr/bin/phevctl
2424
# Bundle APP files
25-
RUN npm i smartthings-phevctl@1.3.10 -g
25+
RUN npm i smartthings-phevctl@1.4.0 -g
2626
# Install app dependencies
2727
ENV NPM_CONFIG_LOGLEVEL warn
2828

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "smartthings-phevctl",
3-
"version": "1.3.10",
3+
"version": "1.4.0",
44
"description": "smartthings remote ctrl",
55
"main": "smartthings-phevctl.js",
66
"scripts": {

remote-ctrl-ui/public/mikrotikSMS.script

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,29 @@ foreach i in=[/tool sms inbox find where phone=$phone] do={
1818
:set encodedMessage ($encodedMessage . $char)
1919
}
2020
:local appUrl "$applicationHost/$applicationId/$applicationSecret/sms\?command=$encodedMessage"
21-
/tool fetch url=$appUrl dst-path="sms.txt"
22-
:local response [/file get "sms.txt" contents]
23-
/file remove sms.txt;
24-
:if ([:len $response] >0) do={
25-
/tool sms send lte1 $phone message $response
26-
}
21+
:local result [/tool fetch output=user url="$appUrl" as-value ];
22+
:if ($result->"status" = "finished") do={
23+
:if ( $result->"data" !="" ) do={
24+
/log info "SMS Service response: $[($result->"data")]"
25+
/tool sms send lte1 $phone message "$[($result->"data")]"
26+
}
27+
}
2728
}
2829

2930
:local appUrl1 "$applicationHost/$applicationId/$applicationSecret/message1"
30-
/tool fetch url=$appUrl1 dst-path="message1.txt"
31-
:local message1 [/file get "message1.txt" contents]
32-
/file remove message1.txt;
33-
:if ([:len $message1] >0) do={
34-
/tool sms send lte1 $phone message $message1
31+
:local result1 [/tool fetch output=user url=$appUrl1 as-value];
32+
:if ($result1->"status" = "finished") do={
33+
:if ($result1->"data" != "" ) do={
34+
/log error "SMS Service error: $[($result1->"data")]"
35+
/tool sms send lte1 $phone message "$[($result1->"data")]"
36+
}
3537
}
3638

3739
:local appUrl2 "$applicationHost/$applicationId/$applicationSecret/message2"
38-
/tool fetch url=$appUrl2 dst-path="message2.txt"
39-
:local message2 [/file get "message2.txt" contents]
40-
/file remove message2.txt;
41-
:if ([:len $message2] >0) do={
42-
/tool sms send lte1 $phone message $message2
40+
:local result2 [/tool fetch url=$appUrl2 as-value output=user];
41+
:if ($result2->"status" = "finished") do={
42+
:if ($result2->"data" != "" ) do={
43+
/log error "SMS Service error: $[($result2->"data")]"
44+
/tool sms send lte1 $phone message "$[($result2->"data")]"
45+
}
4346
}

ui/mikrotikSMS.script

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,29 @@ foreach i in=[/tool sms inbox find where phone=$phone] do={
1818
:set encodedMessage ($encodedMessage . $char)
1919
}
2020
:local appUrl "$applicationHost/$applicationId/$applicationSecret/sms\?command=$encodedMessage"
21-
/tool fetch url=$appUrl dst-path="sms.txt"
22-
:local response [/file get "sms.txt" contents]
23-
/file remove sms.txt;
24-
:if ([:len $response] >0) do={
25-
/tool sms send lte1 $phone message $response
26-
}
21+
:local result [/tool fetch output=user url="$appUrl" as-value ];
22+
:if ($result->"status" = "finished") do={
23+
:if ( $result->"data" !="" ) do={
24+
/log info "SMS Service response: $[($result->"data")]"
25+
/tool sms send lte1 $phone message "$[($result->"data")]"
26+
}
27+
}
2728
}
2829

2930
:local appUrl1 "$applicationHost/$applicationId/$applicationSecret/message1"
30-
/tool fetch url=$appUrl1 dst-path="message1.txt"
31-
:local message1 [/file get "message1.txt" contents]
32-
/file remove message1.txt;
33-
:if ([:len $message1] >0) do={
34-
/tool sms send lte1 $phone message $message1
31+
:local result1 [/tool fetch output=user url=$appUrl1 as-value];
32+
:if ($result1->"status" = "finished") do={
33+
:if ($result1->"data" != "" ) do={
34+
/log error "SMS Service error: $[($result1->"data")]"
35+
/tool sms send lte1 $phone message "$[($result1->"data")]"
36+
}
3537
}
3638

3739
:local appUrl2 "$applicationHost/$applicationId/$applicationSecret/message2"
38-
/tool fetch url=$appUrl2 dst-path="message2.txt"
39-
:local message2 [/file get "message2.txt" contents]
40-
/file remove message2.txt;
41-
:if ([:len $message2] >0) do={
42-
/tool sms send lte1 $phone message $message2
40+
:local result2 [/tool fetch url=$appUrl2 as-value output=user];
41+
:if ($result2->"status" = "finished") do={
42+
:if ($result2->"data" != "" ) do={
43+
/log error "SMS Service error: $[($result2->"data")]"
44+
/tool sms send lte1 $phone message "$[($result2->"data")]"
45+
}
4346
}

0 commit comments

Comments
 (0)