Weather Images

Posts: 42
What do I need to name the images I  have to make them be pulled from my folder for weather? I have the daytime ones working, but not the nighttime ones. Image shows what I am working with.








Edited (1 time)
Posts: 785
You'd need some way to distinguish daytime from night time, most likely using the time of day in the sim. How you do that exactly is up to you. At the very least you'd need a script that checks both the time of day, and the sky type.

The easiest I can think of is to append "Night" to the sky name when the time is between certain hours (e.g. 8pm and 7am). Then you'd name your night images as "Clear Night", "Mostly Cloudy Night", etc. Then, use a script like below to decide when to append "Night" to the sky. Use that script as the converter script for your dynamic image binding.

Note: the binding should now consist of two bindings: (1) the "livedatetime_object" and (2) the "sky" binding.



using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;

namespace Scripts
{
public class WeatherConverter : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
if (value == null)
return null;

var values = (object[])value;
if (values?.Length != 2)
return null;

// Get the two binding values
// First binding should be: "livedatetime_object"
// Second binding should be: "sky"
var time = (DateTime) values[0];
var sky = (string) values[1];

// When is "night time"?
// Arbitrary choice here: between 20:00 and 07:00
if (time.Hour > 20 || time.Hour < 7)
{
// Append "night" to the sky name
sky = sky + " Night";
}

return sky;
}
}
}
Edited (1 time)
Posts: 42
I added that and it said it failed.
Posts: 42
Error I am getting: Script must have a namespace called "Scripts" with a class called "Weather" or "Script"
Posts: 42
The script is giving me a check mark now, but still not showing the graphic with the name Partly Cloudy Night.
Posts: 785
Can you show me the script and how it's setup now?