@@ -182,69 +182,69 @@ python_script:
182
182
To support `HVAC Action` for Shelly BLU TRV you need to isnstall this `Send Trv Status` script on BLU Gateway Gen3 (**Scripts** -> **Create script**) :
183
183
184
184
` ` ` 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;
187
187
188
- function GetMqttConfigHandler (config) {
189
- topic_prefix = config.topic_prefix;
188
+ function getMqttConfigHandler (config) {
189
+ topicPrefix = config.topic_prefix;
190
190
}
191
191
192
- function GetMqttConfig () {
192
+ function getMqttConfig () {
193
193
try {
194
- Shelly.call("MQTT.GetConfig", {}, GetMqttConfigHandler );
194
+ Shelly.call("MQTT.GetConfig", {}, getMqttConfigHandler );
195
195
} catch (e) {
196
- console.log("GetMqttConfig has failed: ", e1);
196
+ console.log("getMqttConfig has failed: ", e1);
197
197
}
198
198
}
199
199
200
- function BluTrvGetRemoteStatusHandler (status, err_no, err_msg, user_data) {
200
+ function bluTrvGetRemoteStatusHandler (status, err_no, err_msg, user_data) {
201
201
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);
203
203
return;
204
204
}
205
205
206
- var topic = topic_prefix + publish_remote_status_topic .replace("{component}", user_data.component);
206
+ var topic = topicPrefix + publishRemoteStatusTopic .replace("{component}", user_data.component);
207
207
MQTT.publish(topic, JSON.stringify(status.status["trv:0"]));
208
208
}
209
209
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});
213
213
} else
214
- console.log("SendRemoteStatus topic_prefix is null");
214
+ console.log("sendRemoteStatus topicPrefix is null");
215
215
};
216
216
217
- function EventHandler (event) {
217
+ function eventHandler (event) {
218
218
try {
219
219
if (event && event.info) {
220
- SendRemoteStatus (event.info.component, event.info.id)
220
+ sendRemoteStatus (event.info.component, event.info.id)
221
221
} else
222
- console.log("EventHandler (event && event.info) is false");
222
+ console.log("eventHandler (event && event.info) is false");
223
223
} catch (e1) {
224
- console.log("Shelly handle event '", event, "' has failed. Error : ", e1);
224
+ console.log("Shelly handle event '", event, "' has failed: ", e1);
225
225
}
226
226
}
227
227
228
- function AddEventHandler () {
228
+ function addEventHandler () {
229
229
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");
233
233
} catch (e1) {
234
- console.log("AddEventHandler has failed: ", e1);
234
+ console.log("addEventHandler has failed: ", e1);
235
235
}
236
236
}
237
237
238
- function InitScript () {
238
+ function initScript () {
239
239
try {
240
- GetMqttConfig ();
241
- AddEventHandler ();
240
+ getMqttConfig ();
241
+ addEventHandler ();
242
242
} catch (e) {
243
- console.log("InitScript has failed: ", e1);
243
+ console.log("initScript has failed: ", e1);
244
244
}
245
245
}
246
246
247
- InitScript ();
247
+ initScript ();
248
248
` ` `
249
249
250
250
[releases] : https://github.com/bieniu/ha-shellies-discovery-gen2/releases
0 commit comments