Hello Mircho,
I'm want to use a BLU1 to control a Plus 2PM in "Cover mode"
So i'm using 2 scripts from the library : Ble-Shellyblu.js and the ble-evnets-handler.js
first of all had to adapt the library version:: the BLU scanner sends "adress" : "12:34:56:.... " , the script conditions contain: "mac": "12:34:56...". after adapting this, the basic library works
Then I started with what this needs to do, ti activate the cover when the button is pushed. the Shelly.Call(Cover.open...) works.
Next, make it work like my other covers : cyclically, in a up - stop - down - stop at each click on the BLU.
So, I use Shelly.Call to get the status of the cover, and then intend do some logic on the callback result.
It did not go well.
After a while, I got to this thread and borrowed your code.
Here i'm stuck again:
this is the console output :
The button was pressed
09:46:11
Uncaught ReferenceError: "result" is not defined
09:46:11
at line 10 col 21
09:46:11
console.log(result);
09:46:11
^
09:46:11
in function "func" called from line 12 col 16
09:46:11
func(data);
09:46:11
^
09:46:11
in function "executeScene" called from line 12 col 43
09:46:11
this.executeScene(sceneIndex, data);
09:46:11
^
09:46:11
in function "onNewData" called from line 17 col 36
09:46:11
sceneEventObject.onNewData(info);
09:46:11
^
09:46:11
in function called from system
09:46:11
This is the part I changed on the library the code in BOLD is where the problem is
/****************** START CHANGE ******************/
let coverstate ;
let coverinfo ;
let CONFIG = {scenes: [ // List of scenes {1}
{ /** SCENE START 1 - Shelly BLU example **/ //{2}
// when event name is `shelly-blu` and button is pressed more than 0 times
conditions: { //{3}
event: "shelly-blu",
address: "bc:02:6e:c3:7e:32",
button: { //{4}
compare: "==",
value: 1,
}, //{4}
}, //{3}
action: function (data) { //{4}
console.log("The button was pressed");
Shelly.call(
"Cover.Getstatus",
{ id: 0 },
function(result){//{5}
coverinfo = result.temperature;
coverstate = result.state;
} //{5}
);
console.log(result);
if (coverstate == "closed") {//{5}
console.log("state is : closed");
Shelly.call("Cover.Open", { id: 0 });
}//{5}
},//{4}
},//{3}
/** SCENE END 1 **/
/** SCENE START 3 - Shelly BLU Scanner example **/
{//{3}
// when event name is `shelly-blu`
},//{2}
/** SCENE END 3 **/
],
//When set to true, debug messages will be logged to the console
debug: false,
};//1
/******************END CHANGE ******************/
How do I define that "result" ? And in the same line, how can I put the whole callback string in an array ?
Some help would be much appreciated