Posts: 11
Threads: 3
Joined: Jan 2026
Reputation:
0
Hello,
I have a problem with a thermostat. I want the circular slider to change color depending on the current mode (heating/cooling), but right now I have to send the status every time.
Is there a solution for this?
Code: localbus.listen('object', '1/4/8', (value) => {
const wrap = document.querySelector('.circularslider-fg')
if (!wrap) return
wrap.style.setProperty(
'--visu-widget-active-color',
value ? 'red' : 'blue'
)
})
Posts: 8610
Threads: 48
Joined: Jun 2015
Reputation:
489
Posts: 11
Threads: 3
Joined: Jan 2026
Reputation:
0
(26.01.2026, 08:53)admin Wrote: See this: https://forum.logicmachine.net/showthrea...7#pid40967 Hello, I will explain in more detail what is happening.
I have a system with several thermostats. Each thermostat returns its current mode status, and I want each one (using its own return address) to change color depending on whether it is in heating or cooling mode.
I have implemented this using a custom widget, where I change the addresses using the group address replacement function.
There is also another issue: when I reload the page, it does not know whether the status is heating or cooling, so it does not change color until it receives this information again.
Is there any way to solve all this?
Thank you for your help!
Posts: 8610
Threads: 48
Joined: Jun 2015
Reputation:
489
You need a separate script for each widget. You can't use "document.querySelector('.circularslider-fg')" because it will return only the first matching element at random.
Posts: 11
Threads: 3
Joined: Jan 2026
Reputation:
0
(26.01.2026, 11:32)admin Wrote: You need a separate script for each widget. You can't use "document.querySelector('.circularslider-fg')" because it will return only the first matching element at random. Could you give me the code for an example thermostat?
Posts: 8610
Threads: 48
Joined: Jun 2015
Reputation:
489
Wait for the next Visu version. It will be easier to implement it there.
Posts: 11
Threads: 3
Joined: Jan 2026
Reputation:
0
(26.01.2026, 13:22)admin Wrote: Wait for the next Visu version. It will be easier to implement it there.
Do you know date ?
Posts: 8610
Threads: 48
Joined: Jun 2015
Reputation:
489
Should be ready by the end of this week.
Posts: 8610
Threads: 48
Joined: Jun 2015
Reputation:
489
New Visu version has been published.
Custom JS example, change widget ID (39) and listening group address ('0/0/1') as needed:
Code: Visu.on('widget-ready', 39, ({ widget }) => {
const el = widget.getEl()
if (el) {
const fg = el.querySelector('.circularslider-fg')
widget.listen('0/0/1', (value) => {
fg.style.setProperty('--visu-widget-active-color', value ? 'red' : 'blue')
})
}
})
Posts: 100
Threads: 7
Joined: Aug 2024
Reputation:
3
Sorry to hijack this thread - I'm trying to use this to change the color of a spinner in compact mode.
But whatever I use as "querySelector" I get "Uncaught (in promise) TypeError: can't access property "style", fg is null". I feel this is something I should figure out myself, but have already spent too much time on it with no progress, so here I am, begging for help
Posts: 8610
Threads: 48
Joined: Jun 2015
Reputation:
489
What part of the spinner do you want to customize?
Posts: 100
Threads: 7
Joined: Aug 2024
Reputation:
3
Just the value-part, preferably both in compact mode and when opened - but most important the compact mode...
Posts: 8610
Threads: 48
Joined: Jun 2015
Reputation:
489
Use this:
Code: Visu.on('widget-ready', 123, ({ widget }) => {
const el = widget.getEl()
if (el) {
widget.listen('0/0/1', (value) => {
el.style.setProperty('--visu-widget-color', value ? 'red' : 'blue')
})
}
})
Posts: 100
Threads: 7
Joined: Aug 2024
Reputation:
3
Thanks! This works fine - but I was mostly looking for a way to change colour on the compact value, the one I click to open the spinner - not the necessarily the spinner itself (altough that's neat also).
Posts: 8610
Threads: 48
Joined: Jun 2015
Reputation:
489
Replace getEl() with getCompactModeEl()
Posts: 100
Threads: 7
Joined: Aug 2024
Reputation:
3
Perfect, thank you! This gives so many possibilities!
Posts: 11
Threads: 3
Joined: Jan 2026
Reputation:
0
Hello, I have a question.
I have a custom thermostat widget, and using this code I can change its color depending on the state (heating/cooling). However, I use the same custom widget for different thermostats and replace the group addresses.
The problem is that the other thermostat depends on a different state address of (heating/cooling), and I’m not sure how to handle this properly with the same widget.
Do you have any solution or suggestion for this?
Code: Visu.on('widget-ready', 894, ({ widget }) =>
{ const el = widget.getEl()
if (el) { const fg = el.querySelector('.circularslider-fg')
widget.listen('1/4/8', (value) =>
{ fg.style.setProperty('--visu-widget-active-color', value ? 'rgb(255, 0, 0)' : 'rgb(0, 0, 255)') }) } })
Posts: 5520
Threads: 30
Joined: Aug 2017
Reputation:
246
You need seperate script for each widget.
------------------------------
Ctrl+F5
Posts: 8610
Threads: 48
Joined: Jun 2015
Reputation:
489
For widgets placed in a custom widget you must use a compound ID format: "widget_id-custom_widget_instance_id" (e.g. "12-43")
At this moment Visu.on does not use compound IDs when generating events. This will be fixed in the next version.
|