Hi,
I uploaded a script to my I4, enabled it and started it.
Everything worked really nice until I rebooted the I4.
After reboot the script is stopped and not automatically started as described in the documentation.
Any ideas? Thanks in advance.
The script just sends all events to a server in the local network….
Code
let CONFIG = {
URL: 'http://192.168.178.200:10001/callback',
SENDER: '192.168.178.235'
};
if(CONFIG.SENDER === ''){
Shelly.call(
'Shelly.GetStatus',''
function (res, error_code, error_msg, ud) {
let status = res;
// print(JSON.stringify(status));
CONFIG.SENDER = status.wifi.sta_ip;
print('SENDER = ' + CONFIG.SENDER);
},
null
);
}
Shelly.addEventHandler(
function (event, userdata) {
if (typeof event.info.event !== 'undefined') {
let eventType = event.info.event;
if(eventType !== 'btn_up' && eventType !== 'btn_down'){
CallNodeRed(event)
}
}
else{
return true;
}
},
null
);
function CallNodeRed(event) {
print('CallNodeRed: ' + JSON.stringify(event));
let data = {
event: event,
sender : CONFIG.SENDER
};
let body = JSON.stringify(data );
Shelly.call(
'http.request', {
method: 'PUT',
url: CONFIG.URL,
body: body
},
function (r, e, m) {
},
null
);
}
Alles anzeigen