automation

9 years 3 months ago #17 by ricardot
Replied by ricardot on topic automation
Hello,

What I need to do to execute a script when a binary sensor goes from "0" to "1"? I want to send an email.

Thanks!

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

9 years 3 months ago #18 by jilldris
Replied by jilldris on topic automation
A tutorial would be highly appreciated :cheer:
For some reason I dont't get the examples working just writing text to the console even thouht I have activated them.

Regarding the virtual sensor, It might also be used to present data from unsupported sensors. Today I use the mysensors driver and have som unsupported sensors, so I send and present them all as temperatures. Works really god but it would be nice to be able to map it to a configurable sensor where it is possible to configure the unit etc.

Thanks

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

9 years 3 months ago #23 by EasyIoT
Replied by EasyIoT on topic automation

ricardot wrote: Hello,

What I need to do to execute a script when a binary sensor goes from "0" to "1"? I want to send an email.

Thanks!


Basically you have two functions like in Arduino programming: Setup and Run.

Setup is called only once at beginning, Run is called as you set schedule in config. In your case you need only to set setup function because you set event function - > when value in driver changed you want to send email. At the moment there is no email helper function so you should write your own email send function. Don't forget to enable program.
To detect when value change to 1 write program like this:

public void Setup()
{
EventHelper.ModuleChangedHandler((o, m, p) =>
{
Console.WriteLine(m.Address + " in program id "+ Program.ProgramId.ToString()+ " property "+ p.Property + " value " + p.Value);

// this is example for MYSENSORS driver on address N1S1, door window sensor
if ((m.Domain == Domains.MYSENSORS) && (m.Address == "N1S1") && (p.Property == "Sensor.DoorWindow") && (p.Value == "1"))
{
// here write your own email send program
}
return true;
});
}


public void Run()
{
//Console.WriteLine("test x3");
}

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

9 years 3 months ago #24 by EasyIoT
Replied by EasyIoT on topic automation

jilldris wrote: A tutorial would be highly appreciated :cheer:
For some reason I dont't get the examples working just writing text to the console even thouht I have activated them.

Regarding the virtual sensor, It might also be used to present data from unsupported sensors. Today I use the mysensors driver and have som unsupported sensors, so I send and present them all as temperatures. Works really god but it would be nice to be able to map it to a configurable sensor where it is possible to configure the unit etc.

Thanks


At the moment you can use generic sensor type. It will show all properties of module.

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

9 years 3 months ago #32 by jilldris
Replied by jilldris on topic automation
I can add additional custom propetys to a generic sensor, however how do I set it to something else than a constant? Eg how do I map the data that I have sent as temperatures?

Do I need do do somethings else than to enable the scripts to get them to execute? Have done that with the examples but they do not seem to execute even thogh the cron setting is * * * * *.

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

9 years 3 months ago #37 by EasyIoT
Replied by EasyIoT on topic automation

jilldris wrote: I can add additional custom propetys to a generic sensor, however how do I set it to something else than a constant? Eg how do I map the data that I have sent as temperatures?

Do I need do do somethings else than to enable the scripts to get them to execute? Have done that with the examples but they do not seem to execute even thogh the cron setting is * * * * *.


Please wait for tutorial and new version of EasyIoT server.

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

Time to create page: 0.326 seconds

Forum latest

  • No posts to display.