Scheduled Endpoints Cache variable

If I go and change the product value to different, it is not working. I need to stop and start dashboad. Is there a solution to this?

$Schedule = New-UDEndpointSchedule -Every 1 -Second
$Endpoint = New-UDEndpoint -Schedule $Schedule -Endpoint {
$Cache:Products = 100 # if I change the value here, it is not loading
}

$Dashboard = New-UDDashboard -Title “Cached Products” -Content {
New-UDCounter -Title “Number of Products” -Endpoint {
$Cache:Products
}
}

Start-UDDashboard -Dashboard $Dashboard -Port 8080 -Endpoint $Endpoint

That seems like a bug to me. Can you open an issue on GitHub?

it works on and off, I need to put -autoreload

I might not be understanding the post properly but you could use Sync-UDElement to refresh the visualizations when I am updated their variables.

Step 1 - Add an id to the counter

New-UDCounter -Id "Counter1" -Title "Number of Products" -AutoRefresh -Endpoint  {
        $Cache:Products
    }

Step 2 - Do a Sync-UDElement targeting the ID you set on the counter

$Endpoint = New-UDEndpoint -Schedule $Schedule -Endpoint {
    $Cache:Products = get-random -Minimum 0 -Maximum 100 # if I change the value here, it is not loading
    Sync-UDElement -Id "Counter1" -Broadcast
}

i have txt file C:\temp\myfile.txt
if I put an integer value in the txt file, works well, when I put a string value e.g. test in the txt file, it comes 0
why?

$Schedule = New-UDEndpointSchedule -Every 3 -Second
$Endpoint = New-UDEndpoint -Schedule $Schedule -Endpoint {
($Cache:Products) = [sting](Get-Content C:\temp\myfile.txt)
Sync-UDElement -id “Counter1” -Broadcast

}

$Dashboard = New-UDDashboard -Title “Cached Products” -Content {
New-UDCounter -id “Counter1” -Title “Number of Products” -Endpoint {
($Cache:Products)

}

}

Get-UDDashboard | Stop-UDDashboard

Start-UDDashboard -Dashboard $Dashboard -Port 8080 -Endpoint $Endpoint

Because the New-UDCounter only displays numbers?
https://docs.universaldashboard.io/components/counter

@leeberg
Not to hijack the thread but…
I Assume the Sync-UDelement is used to force refresh the UDCounter control - could you then leave out the -autorefresh parameter completely, in this particular example?

yes, I left autorefresh parameter completely.