Dynamicly change dummy kWh counter icon state

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.

Moderators: leecollings, remb0

Post Reply
User avatar
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

Post by RonkA »

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:
wisselaar button.PNG
wisselaar button.PNG (8.01 KiB) Viewed 1237 times
and a kWh counter:
wisselaar kWh.PNG
wisselaar kWh.PNG (11.36 KiB) Viewed 1237 times
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.
SolarEdge ModbusTCP - Kaku - Synology NAS - Watermeter - ESPEasy - DS18b20
Work in progress = Life in general..
FlyingDomotic
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

Post by FlyingDomotic »

It's possible to dynamically set any icon through a dzVents script :

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
}
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.
User avatar
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

Post by RonkA »

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'..
SolarEdge ModbusTCP - Kaku - Synology NAS - Watermeter - ESPEasy - DS18b20
Work in progress = Life in general..
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest