Skip to content

Commit 1a86bef

Browse files
committed
Format script
1 parent 3c6bb30 commit 1a86bef

File tree

2 files changed

+56
-56
lines changed

2 files changed

+56
-56
lines changed

README.md

+28-28
Original file line numberDiff line numberDiff line change
@@ -182,69 +182,69 @@ python_script:
182182
To support `HVAC Action` for Shelly BLU TRV you need to isnstall this `Send Trv Status` script on BLU Gateway Gen3 (**Scripts** -> **Create script**):
183183

184184
```js
185-
let publish_remote_status_topic = "/remote-status/{component}";
186-
let topic_prefix = null;
185+
let publishRemoteStatusTopic = "/remote-status/{component}";
186+
let topicPrefix = null;
187187
188-
function GetMqttConfigHandler(config) {
189-
topic_prefix = config.topic_prefix;
188+
function getMqttConfigHandler(config) {
189+
topicPrefix = config.topic_prefix;
190190
}
191191
192-
function GetMqttConfig() {
192+
function getMqttConfig() {
193193
try {
194-
Shelly.call("MQTT.GetConfig", {}, GetMqttConfigHandler);
194+
Shelly.call("MQTT.GetConfig", {}, getMqttConfigHandler);
195195
} catch (e) {
196-
console.log("GetMqttConfig has failed: ", e1);
196+
console.log("getMqttConfig has failed: ", e1);
197197
}
198198
}
199199
200-
function BluTrvGetRemoteStatusHandler(status, err_no, err_msg, user_data) {
200+
function bluTrvGetRemoteStatusHandler(status, err_no, err_msg, user_data) {
201201
if (err_no !== 0) {
202-
console.log("BluTrvGetRemoteStatusHandler error no: ", err_no, ", err_msg: '", err_msg, "', user_data: ", user_data);
202+
console.log("bluTrvGetRemoteStatusHandler error no: ", err_no, ", err_msg: '", err_msg, "', user_data: ", user_data);
203203
return;
204204
}
205205
206-
var topic = topic_prefix + publish_remote_status_topic.replace("{component}", user_data.component);
206+
var topic = topicPrefix + publishRemoteStatusTopic.replace("{component}", user_data.component);
207207
MQTT.publish(topic, JSON.stringify(status.status["trv:0"]));
208208
}
209209
210-
function SendRemoteStatus(component, id) {
211-
if (topic_prefix !== null) {
212-
Shelly.call("BluTrv.GetRemoteStatus", {"id": id}, BluTrvGetRemoteStatusHandler, {component: component, id: id});
210+
function sendRemoteStatus(component, id) {
211+
if (topicPrefix !== null) {
212+
Shelly.call("BluTrv.GetRemoteStatus", {"id": id}, bluTrvGetRemoteStatusHandler, {component: component, id: id});
213213
} else
214-
console.log("SendRemoteStatus topic_prefix is null");
214+
console.log("sendRemoteStatus topicPrefix is null");
215215
};
216216
217-
function EventHandler(event) {
217+
function eventHandler(event) {
218218
try {
219219
if (event && event.info) {
220-
SendRemoteStatus(event.info.component, event.info.id)
220+
sendRemoteStatus(event.info.component, event.info.id)
221221
} else
222-
console.log("EventHandler (event && event.info) is false");
222+
console.log("eventHandler (event && event.info) is false");
223223
} catch (e1) {
224-
console.log("Shelly handle event '", event, "' has failed. Error: ", e1);
224+
console.log("Shelly handle event '", event, "' has failed: ", e1);
225225
}
226226
}
227227
228-
function AddEventHandler() {
228+
function addEventHandler() {
229229
try {
230-
console.log("AddEventHandler...");
231-
Shelly.addEventHandler(EventHandler);
232-
console.log("AddEventHandler done.");
230+
console.log("addEventHandler...");
231+
Shelly.addEventHandler(eventHandler);
232+
console.log("addEventHandler done");
233233
} catch (e1) {
234-
console.log("AddEventHandler has failed: ", e1);
234+
console.log("addEventHandler has failed: ", e1);
235235
}
236236
}
237237
238-
function InitScript() {
238+
function initScript() {
239239
try {
240-
GetMqttConfig();
241-
AddEventHandler();
240+
getMqttConfig();
241+
addEventHandler();
242242
} catch (e) {
243-
console.log("InitScript has failed: ", e1);
243+
console.log("initScript has failed: ", e1);
244244
}
245245
}
246246
247-
InitScript();
247+
initScript();
248248
```
249249

250250
[releases]: https://github.com/bieniu/ha-shellies-discovery-gen2/releases

info.md

+28-28
Original file line numberDiff line numberDiff line change
@@ -175,69 +175,69 @@ python_script:
175175
To support `HVAC Action` for Shelly BLU TRV you need to isnstall this `Send Trv Status` script on BLU Gateway Gen3 (**Scripts** -> **Create script**):
176176

177177
```js
178-
let publish_remote_status_topic = "/remote-status/{component}";
179-
let topic_prefix = null;
178+
let publishRemoteStatusTopic = "/remote-status/{component}";
179+
let topicPrefix = null;
180180
181-
function GetMqttConfigHandler(config) {
182-
topic_prefix = config.topic_prefix;
181+
function getMqttConfigHandler(config) {
182+
topicPrefix = config.topic_prefix;
183183
}
184184
185-
function GetMqttConfig() {
185+
function getMqttConfig() {
186186
try {
187-
Shelly.call("MQTT.GetConfig", {}, GetMqttConfigHandler);
187+
Shelly.call("MQTT.GetConfig", {}, getMqttConfigHandler);
188188
} catch (e) {
189-
console.log("GetMqttConfig has failed: ", e1);
189+
console.log("getMqttConfig has failed: ", e1);
190190
}
191191
}
192192
193-
function BluTrvGetRemoteStatusHandler(status, err_no, err_msg, user_data) {
193+
function bluTrvGetRemoteStatusHandler(status, err_no, err_msg, user_data) {
194194
if (err_no !== 0) {
195-
console.log("BluTrvGetRemoteStatusHandler error no: ", err_no, ", err_msg: '", err_msg, "', user_data: ", user_data);
195+
console.log("bluTrvGetRemoteStatusHandler error no: ", err_no, ", err_msg: '", err_msg, "', user_data: ", user_data);
196196
return;
197197
}
198198
199-
var topic = topic_prefix + publish_remote_status_topic.replace("{component}", user_data.component);
199+
var topic = topicPrefix + publishRemoteStatusTopic.replace("{component}", user_data.component);
200200
MQTT.publish(topic, JSON.stringify(status.status["trv:0"]));
201201
}
202202
203-
function SendRemoteStatus(component, id) {
204-
if (topic_prefix !== null) {
205-
Shelly.call("BluTrv.GetRemoteStatus", {"id": id}, BluTrvGetRemoteStatusHandler, {component: component, id: id});
203+
function sendRemoteStatus(component, id) {
204+
if (topicPrefix !== null) {
205+
Shelly.call("BluTrv.GetRemoteStatus", {"id": id}, bluTrvGetRemoteStatusHandler, {component: component, id: id});
206206
} else
207-
console.log("SendRemoteStatus topic_prefix is null");
207+
console.log("sendRemoteStatus topicPrefix is null");
208208
};
209209
210-
function EventHandler(event) {
210+
function eventHandler(event) {
211211
try {
212212
if (event && event.info) {
213-
SendRemoteStatus(event.info.component, event.info.id)
213+
sendRemoteStatus(event.info.component, event.info.id)
214214
} else
215-
console.log("EventHandler (event && event.info) is false");
215+
console.log("eventHandler (event && event.info) is false");
216216
} catch (e1) {
217-
console.log("Shelly handle event '", event, "' has failed. Error: ", e1);
217+
console.log("Shelly handle event '", event, "' has failed: ", e1);
218218
}
219219
}
220220
221-
function AddEventHandler() {
221+
function addEventHandler() {
222222
try {
223-
console.log("AddEventHandler...");
224-
Shelly.addEventHandler(EventHandler);
225-
console.log("AddEventHandler done.");
223+
console.log("addEventHandler...");
224+
Shelly.addEventHandler(eventHandler);
225+
console.log("addEventHandler done");
226226
} catch (e1) {
227-
console.log("AddEventHandler has failed: ", e1);
227+
console.log("addEventHandler has failed: ", e1);
228228
}
229229
}
230230
231-
function InitScript() {
231+
function initScript() {
232232
try {
233-
GetMqttConfig();
234-
AddEventHandler();
233+
getMqttConfig();
234+
addEventHandler();
235235
} catch (e) {
236-
console.log("InitScript has failed: ", e1);
236+
console.log("initScript has failed: ", e1);
237237
}
238238
}
239239
240-
InitScript();
240+
initScript();
241241
```
242242

243243
[forum]: https://community.home-assistant.io/t/shellies-discovery-gen2-script/384479

0 commit comments

Comments
 (0)