Hello All.
I use a lot of dummy kWh counters in Domoticz, and for almost all counters i made some nice custom icons that have both ON and OFF states.
For example: on my dashboard i have a switch: and a kWh counter: So both devices use the same icon.
Now the issue:
At this moment there is nothing to count but the ON-icon is shown on the kWh counter, this is IMHO not correct visually..
It would be nice to see both states reflected in the counter: If counter-value is zero, the OFF-icon is shown. Any other value shows the ON-icon..
The only problem visually i can imagine is that, if there would be fast switching between zero and a value, this could be annoying..
But i think this could be resolved by fixing one of the icon-states to the device, or add a De-bounce time before the state is changed.
Dynamicly change dummy kWh counter icon state
Moderators: leecollings, remb0
- RonkA
- Posts: 115
- Joined: Tuesday 14 June 2022 12:57
- Target OS: NAS (Synology & others)
- Domoticz version: 2025.1
- Location: Harlingen
- Contact:
Dynamicly change dummy kWh counter icon state
SolarEdge ModbusTCP - Kaku - Synology NAS - Watermeter - ESPEasy - DS18b20
Work in progress = Life in general..
Work in progress = Life in general..
-
- Posts: 356
- Joined: Saturday 27 February 2016 0:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Contact:
Re: Dynamicly change dummy kWh counter icon state
It's possible to dynamically set any icon through a dzVents script :
In this example, "my Device name" is a selector with 3 values (0, 10 and 20), associated respectively with icons number 140, 137 and 138.
Code: Select all
return {
on = {devices = "my Device Name"},
execute = function(dz, item)
local icons = {
[0] = 140, -- Off
[10] = 137,-- Auto
[20] = 138-- Manual
}
print('Info: '..item.name..', level '..tostring(item.level)..', icon '..tostring(icons[item.level]))
item.setIcon(icons[item.level])
end
}
- RonkA
- Posts: 115
- Joined: Tuesday 14 June 2022 12:57
- Target OS: NAS (Synology & others)
- Domoticz version: 2025.1
- Location: Harlingen
- Contact:
Re: Dynamicly change dummy kWh counter icon state
Hi,
Thanks for your reply to my suggestion;
But this feels more like a workaround for wat i am proposing, because you have to make the same icon twice..
One icon, like the original i made, to use for the swich that has all the functionallity build into it to work in both on and off states;
And a second icon that is stripped of the original On-state image to use with for example a counter that has than to be swiched by using 'seticon' in a script..
Yes it should work, but it would IMHO be so much more elegant to be able to use just the one icon like i propose..
Another little bit lesser elegant way could be to have a function like a boolean device attribute like 'seticonstate'..
Thanks for your reply to my suggestion;
But this feels more like a workaround for wat i am proposing, because you have to make the same icon twice..
One icon, like the original i made, to use for the swich that has all the functionallity build into it to work in both on and off states;
And a second icon that is stripped of the original On-state image to use with for example a counter that has than to be swiched by using 'seticon' in a script..
Yes it should work, but it would IMHO be so much more elegant to be able to use just the one icon like i propose..
Another little bit lesser elegant way could be to have a function like a boolean device attribute like 'seticonstate'..
SolarEdge ModbusTCP - Kaku - Synology NAS - Watermeter - ESPEasy - DS18b20
Work in progress = Life in general..
Work in progress = Life in general..
Who is online
Users browsing this forum: No registered users and 1 guest