Error while compiling automation script

9 years 2 months ago #2247 by NightOne
In your first post the following was wrong

DriverHelper.ProcessCommad(Domains.MYSENSORS, "N1S1", "Sensor.LightLevel", "pVal");

the line above this declared pVal and in this line of code you are adding it as a string..."pVal" the code is expecting a value so you would have to do it like this.

DriverHelper.ProcessCommad(Domains.MYSENSORS, "N1S1", "Sensor.LightLevel", pVal.Value);

Please Log in or Create an account to join the conversation.

9 years 2 months ago #2248 by vickeyhort
Now I am having a different error

Errors:

Error CS0019 in line 8 column 11, Operator `>' cannot be applied to operands of type `GenericDriver.ModuleParameter' and `int'
Program disabled, fix errors first.


Here is the code

public void Setup()
{
EventHelper.ModuleChangedHandler((o, m, p) =>
{
// filter digital switch - change module address
if (m.Domain == Domains.MYSENSORS && m.Address == "N1S0" && p.Property == "Sensor.DigitalValue"){
ModuleParameter n = ModuleHelper.GetProperty(Domains.MYSENSORS, "N0S0", "Sensor.LightLevel");
if (n > 50) {
DriverHelper.ProcessCommad(Domains.MYSENSORS, "N10S0", "Sensor.DigitalValue", "1");
}
}
return true;
});
}

Please Log in or Create an account to join the conversation.

9 years 2 months ago - 9 years 2 months ago #2249 by NightOne
the module doesnt know what you what to do with n as it has many properties...you need to use n.Value
so it should read like this
if (n.Value > "50")

Please Log in or Create an account to join the conversation.

9 years 2 months ago #2250 by vickeyhort
Opps! Error changed!!

Errors:

Error CS1525 in line 7 column 23, Unexpected symbol `.', expecting `,', `;', or `='
Error CS1525 in line 7 column 78, Unexpected symbol `N0S0', expecting `,', `;', or `='
Error CS1525 in line 7 column 86, Unexpected symbol `Sensor.LightLevel', expecting `,', `;', or `='
Program disabled, fix errors first.


Here is the code

public void Setup()
{
EventHelper.ModuleChangedHandler((o, m, p) =>
{
// filter digital switch - change module address
if (m.Domain == Domains.MYSENSORS && m.Address == "N1S0" && p.Property == "Sensor.DigitalValue"){
ModuleParameter n.Value = ModuleHelper.GetProperty(Domains.MYSENSORS, "N0S0", "Sensor.LightLevel");
if (n.Value > "50") {
DriverHelper.ProcessCommad(Domains.MYSENSORS, "N10S0", "Sensor.DigitalValue", "1");
}
}
return true;
});
}

Please Log in or Create an account to join the conversation.

9 years 2 months ago - 9 years 2 months ago #2251 by NightOne
welcome to my world....I normally get 1000 errors and then I have no idea what i did to fix it...

you only need to change the n.Value on the (n.Value > "50") when you declared the first n in ModuleParameter you only put

ModuleParameter n =ModuleHelper.GetProperty

when then happens is the n variable is populated with the data on the server. so there is Value, Name, Description, Unit etc etc....so if you wanted to return one of those values then after you have instansiated the variable you can do stuff like n.Value or n.Description or whatever you need.

PS... I am not 100% sure if its if (n.Value > "50") or if (n.Value > 50) I am pretty sure its the first
The following user(s) said Thank You: vickeyhort

Please Log in or Create an account to join the conversation.

9 years 2 months ago #2252 by vickeyhort
Back with an old error

Errors:

Error CS0019 in line 8 column 13, Operator `>' cannot be applied to operands of type `string' and `string'
Program disabled, fix errors first.


and the script

public void Setup()
{
EventHelper.ModuleChangedHandler((o, m, p) =>
{
// filter digital switch - change module address
if (m.Domain == Domains.MYSENSORS && m.Address == "N1S0" && p.Property == "Sensor.DigitalValue"){
ModuleParameter n = ModuleHelper.GetProperty(Domains.MYSENSORS, "N0S0", "Sensor.LightLevel");
if (n.Value > "50")
{
DriverHelper.ProcessCommad(Domains.MYSENSORS, "N10S0", "Sensor.DigitalValue", "1");
}
}
return true;
});
}

Please Log in or Create an account to join the conversation.

Time to create page: 0.221 seconds

Forum latest

  • No posts to display.