I'm trying to control Roller Shutter. The driver helper is easy to manage but read value of sensor not:
/*
This code is running one time when program is enabled
*/
int UmbralON = 520; // Umbral de desactivación
int UmbralOFF = 420; // Umbral de activación
public void Setup()
{
}
/*
This code is running periodicaly when program is enabled.
Cron job detirmine running period.
*/
public void Run()
{
ModuleParameter L = ModuleHelper.GetProperty(Domains.MYSENSORS, "N23S1", "Sensor.LightLevel");
// Luz Persiana ALTA
if (L != null && L > UmbralON) {
DriverHelper.ProcessCommad(Domains.MYSENSORS, "N23S0", "ControlDown", "1");
}
// Luz Persiana NORMAL
if (L != null && L <= UmbralON && L >= UmbralOFF){
DriverHelper.ProcessCommad(Domains.MYSENSORS, "N23S0", "ControlStop", "1");
}
// Luz Persiana BAJA
if (L != null && L < UmbralOFF){
DriverHelper.ProcessCommad(Domains.MYSENSORS, "N23S0", "ControlUp", "1");
}
}
I always get error:
Error CS0019 in line 21 column 20, Operator `>' cannot be applied to operands of type `GenericDriver.ModuleParameter' and `int'
Error CS0019 in line 25 column 21, Operator `<=' cannot be applied to operands of type `GenericDriver.ModuleParameter' and `int'
Error CS0019 in line 29 column 21, Operator `<' cannot be applied to operands of type `GenericDriver.ModuleParameter' and `int'
osalval wrote: I'm trying to control Roller Shutter. The driver helper is easy to manage but read value of sensor not:
/*
This code is running one time when program is enabled
*/
int UmbralON = 520; // Umbral de desactivación
int UmbralOFF = 420; // Umbral de activación
public void Setup()
{
}
/*
This code is running periodicaly when program is enabled.
Cron job detirmine running period.
*/
public void Run()
{
ModuleParameter L = ModuleHelper.GetProperty(Domains.MYSENSORS, "N23S1", "Sensor.LightLevel");
// Luz Persiana ALTA
if (L != null && L > UmbralON) {
DriverHelper.ProcessCommad(Domains.MYSENSORS, "N23S0", "ControlDown", "1");
}
// Luz Persiana NORMAL
if (L != null && L <= UmbralON && L >= UmbralOFF){
DriverHelper.ProcessCommad(Domains.MYSENSORS, "N23S0", "ControlStop", "1");
}
// Luz Persiana BAJA
if (L != null && L < UmbralOFF){
DriverHelper.ProcessCommad(Domains.MYSENSORS, "N23S0", "ControlUp", "1");
}
}
I always get error:
Error CS0019 in line 21 column 20, Operator `>' cannot be applied to operands of type `GenericDriver.ModuleParameter' and `int'
Error CS0019 in line 25 column 21, Operator `<=' cannot be applied to operands of type `GenericDriver.ModuleParameter' and `int'
Error CS0019 in line 29 column 21, Operator `<' cannot be applied to operands of type `GenericDriver.ModuleParameter' and `int'
Module parameter is object and you can not compare object and int. Search forum and you will find solution.
Error CS1061 in line 12 column 13, Type `GenericDriver.Module' does not contain a definition for `domain' and no extension method `domain' of type `GenericDriver.Module' could be found. Are you missing an assembly reference?
Error in line -11 column 0, /home/pi/easyiot/GenericDriver.dll (Location of the symbol related to previous error)
Error CS0103 in line 15 column 7, The name `LL' does not exist in the current context
Error CS0103 in line 19 column 8, The name `LL' does not exist in the current context
Error CS0103 in line 23 column 8, The name `LL' does not exist in the current context
Line 12 is:
if (m.domain == Domains.MYSENSORS && m.address == "N23S1"){
I'm not understand why error states: Type `GenericDriver.Module' because should be MYSENSORS driver?
Error CS1061 in line 12 column 13, Type `GenericDriver.Module' does not contain a definition for `domain' and no extension method `domain' of type `GenericDriver.Module' could be found. Are you missing an assembly reference?
Error in line -11 column 0, /home/pi/easyiot/GenericDriver.dll (Location of the symbol related to previous error)
Error CS0103 in line 15 column 7, The name `LL' does not exist in the current context
Error CS0103 in line 19 column 8, The name `LL' does not exist in the current context
Error CS0103 in line 23 column 8, The name `LL' does not exist in the current context
Line 12 is:
if (m.domain == Domains.MYSENSORS && m.address == "N23S1"){
I'm not understand why error states: Type `GenericDriver.Module' because should be MYSENSORS driver?
My code was untested. Address and domain starts with capital letter:
if (m.Domain == Domains.MYSENSORS && m.Address == "N23S1"){
Please read tutorials and other code examples on this site.