Welcome, Guest
Username: Password: Remember me

TOPIC: Dynamic Icon change

Dynamic Icon change 1 year 10 months ago #2339

  • NightOne
  • NightOne's Avatar
  • Offline
  • Premium Member
  • Posts: 81
  • Thank you received: 26
  • Karma: 5
Hi all,

Just thought I would share something that is simple and works quit well.... I wrote an external program that gets the local weather from forecast.io and uploads all the data to EasyIOT server, I could probably do the whole thing in automation but I dont have the skill.
The summary of the weather comes back as clear text and reads something like "Drizzle", "Rain", "Cloudy" etc etc... so what I have done is create corrisponding icons in the custom folder that match the name of the summary, so i have a file called "Drizzle.png" etc etc....you will see why in a moment.

I created a small automation script that changes the setting of the icon when the summary changes.....so when it says Drizzle for example you get a nice little icon with a cloud and rain.

I hope someone finds this useful

Code Here:

public void Setup()
{

EventHelper.ModuleChangedHandler((o, m, p) =>
{
Console.WriteLine(m.Address + " in program id "+ Program.ProgramId.ToString()+ " property "+ p.Property + " value " + p.Value);
if (m.Domain == Domains.VIRTUAL && m.Address == "N2S0" && p.Property == "Sensor.AnalogValue"){

if (p.Value.Contains("%20"))
{
string n = p.Value.Replace("%20"," ");
ModuleHelper.SetProperty(Domains.VIRTUAL, "N2S0", "Sensor.AnalogValue", n);
EventHelper.SetEvent(Domains.VIRTUAL, "N2S0", "Sensor.AnalogValue");
}

ModuleHelper.SetProperty(Domains.VIRTUAL, "N2S0", "Settings.Icon", p.Value +".png");
EventHelper.SetEvent(Domains.VIRTUAL, "N2S0", "Settings.Icon");


}
return true;

});

}

public void Run()
{
}
Last Edit: 1 year 10 months ago by NightOne.
The administrator has disabled public write access.

Dynamic Icon change 1 year 10 months ago #2348

  • EasyIoT
  • EasyIoT's Avatar
  • Offline
  • Administrator
  • Posts: 833
  • Thank you received: 258
  • Karma: 24
NightOne wrote:
Hi all,

Just thought I would share something that is simple and works quit well.... I wrote an external program that gets the local weather from forecast.io and uploads all the data to EasyIOT server, I could probably do the whole thing in automation but I dont have the skill.
The summary of the weather comes back as clear text and reads something like "Drizzle", "Rain", "Cloudy" etc etc... so what I have done is create corrisponding icons in the custom folder that match the name of the summary, so i have a file called "Drizzle.png" etc etc....you will see why in a moment.

I created a small automation script that changes the setting of the icon when the summary changes.....so when it says Drizzle for example you get a nice little icon with a cloud and rain.

I hope someone finds this useful

Code Here:

public void Setup()
{

EventHelper.ModuleChangedHandler((o, m, p) =>
{
Console.WriteLine(m.Address + " in program id "+ Program.ProgramId.ToString()+ " property "+ p.Property + " value " + p.Value);
if (m.Domain == Domains.VIRTUAL && m.Address == "N2S0" && p.Property == "Sensor.AnalogValue"){


ModuleHelper.SetProperty(Domains.VIRTUAL, "N2S0", "Settings.Icon", p.Value +".png");
EventHelper.SetEvent(Domains.VIRTUAL, "N2S0", "Settings.Icon");


}
return true;

});

}

public void Run()
{
}

Nice idea.
The administrator has disabled public write access.
Time to create page: 0.133 seconds
Powered by Kunena Forum