Page 1 of 1

Modifying domoticz Last Seen status - changing js script

Posted: Monday 29 April 2019 9:55
by blazej222
Hi.I'm trying to modify domoticz website so
1) in place of field Last Seen of tab switches it would return either OFF status or device uptime (not overall - just time since it was powered on during this particular "session").
2) The overall time of device power on time would be stored somewhere and alert would be shown after device has worked for 1000 hrs(lets say a lifespan of a light bulb).
I have no idea where I should look for a script that is responsible for what is shown in Last Seen field.
I've found script called domoticzdevices.js and the following piece of code inside:

Code: Select all

            var gText = makeSVGnode('text', { id: "lastseen", x: 0, y: Device.elementPadding * 7.5, 'font-size': '80%' }, '');
            gStatusGroup.appendChild(gText);
            gText.appendChild(makeSVGnode('tspan', { id: "lastlabel", 'font-style': 'italic', 'font-size': '80%' }, $.t('Last Seen')));
            gText.appendChild(makeSVGnode('tspan', { id: "lastlabel", 'font-style': 'italic', 'font-size': '80%' }, ':'));
            gText.appendChild(makeSVGnode('tspan', { id: "lastupdate", 'font-size': '80%' }, ' ' + this.lastupdate));
However, when I modify anything there it seems to have no effect - even if I change "Last Seen" title, after refreshing page it's still the same.
I've been looking for "Last Seen" and "lastupdate" with grep - and domoticzdevices.js seemed to be the most logical name for a script that returns lastupdate time.

I'd be very, very thankful for any help in modifying this website - it's very important to me to get it done :)

Re: Modifying domoticz Last Seen status - changing js script

Posted: Thursday 02 May 2019 16:04
by SweetPants
You have to reload the app cache before changes take effect. refreshing browser cache is not enough

Re: Modifying domoticz Last Seen status - changing js script

Posted: Monday 06 May 2019 0:24
by blazej222
How do I reload the app cache? I've tried exiting and starting again domoticz binary - it doesn't work.

Re: Modifying domoticz Last Seen status - changing js script

Posted: Monday 06 May 2019 7:55
by waaren
blazej222 wrote: Monday 06 May 2019 0:24 How do I reload the app cache? I've tried exiting and starting again domoticz binary - it doesn't work.
- clear browser appcache
Chrome: chrome://appcache-internals/#
Firefox: https://support.mozilla.org/en-US/kb/storage

Re: Modifying domoticz Last Seen status - changing js script

Posted: Monday 06 May 2019 8:08
by gizmocuz
If you would like to modify the HTTP code it is best to launch domoticz from the commandline with the option -nocache

./domoticz -nocache

then clear the browser cache + appcache

from now on, there will be no more caching and you can edit the HTML

Re: Modifying domoticz Last Seen status - changing js script

Posted: Monday 13 May 2019 12:39
by blazej222
Thanks for all sugestions, they definitely help a lot when working with html and js code. However, I've searched through whole domoticz directory using grep (to be precise, grepWin and AgentRansack since I've tried doing it on RPI and Windows.) Unfortunately, both programs find some css files and js files - but changing any of the files doesn't really do anything. I've also tried changing domoticz language - the fun fact is,after changing language to Polish and searching domoticz files for Polish strings that appear on screen, there's no results. It seems domoticz doesn't store translations with all the files - or I am doing something wrong. Does anybody have any idea how I could search domoticz files for the strings I am looking for ( and most important - how do I change the "Last Seen" text?)