Software: modifications and extensions Toon

Everything about software tools, new software development and toolchains. For developers, mostly.

Moderators: marcelr, TerrorSource, Toonz, TheHogNL

Re: Software: modifications and extensions Toon

Postby adjego » Sun Dec 04, 2016 5:28 pm

So managed to get some buttons working via Toon. Not fancy at all but getting this to work took already quite some time and i'm not a programmer..;)
The most annoying part is that restarting qt takes around 5 minutes.

So i just made a copy of an existing page and modified it to show 4 images, with text center aligned with the buttons.
Image

Image

How to install:
  1. Unzip the folder to /HCBv2/qml/apps
  2. Edit the /HCBv2/qml/apps/domoticz/DomoticzScreen.qml file. You will find a hostName and portNum string. Edit this to match the location of your Domoticz API interface.
  3. Edit the file: /HCBv2/qml/qb/base/Globals.qml , here around line 80 add the line:
    Code: Select all
    "domoticz",

    so: before:
    Code: Select all
                      var appsToLoad = [
                         "homescreen",
                         "systray",
                         "inbox",
                         "thermostat",
                         "clock",
                         "weather",

    After:
    Code: Select all
                      var appsToLoad = [
                         "homescreen",
                         "systray",
                         "inbox",
                         "thermostat",
                         "clock",
                         "weather",
                         "domoticz",
  4. Restart QT, by a reboot or via
    Code: Select all
    killall -9 qt-gui

Next step is to also display the current return when my solar panels are producing more than needed.
I tried already many things but i can not get the data which is available on Toon displayed on a tile.

Running this http://<TOON IP>:<TOON PORT>/happ_pwrusage?action=GetCurrentUsage will show something like this:
Code: Select all
{
"result": "ok",
"powerUsage": {
"value": 0,
"dayCost": 0,
"avgValue": 0
},
"powerProduction": {
"value": 100,
"dayCost": 0.53,
"avgValue": 36.76
},
"gasUsage": {
"value": 0,
"dayCost": 0,
"avgValue": 0
}
}


So the data is there, but getting it displayed on a tile.
Made a copy of /HCBv2/qml/apps/graph/PowerThisMomentTile.qml and tried to manipulate is but i can't find a function call to fetch the correct value.
I think Toon can only do something with solar when it can actually measure the current produced power coming from the invertor. I do have this data but only in Domoticz, and not via a kWh meter.

Anybody else has some ideas?
Attachments
domoticz.zip
(49.05 KiB) Downloaded 352 times
adjego
Starting Member
Starting Member
 
Posts: 7
Joined: November 2016

Re: Software: modifications and extensions Toon

Postby Tom » Fri Dec 16, 2016 6:39 pm

Thanks guys for developing these nice plugins, I am now using the domoticz app of adjego and trying to make it more generic by requesting devices from domoticz and build a dynamic list of the switches using javascript. However I am running into the issue that the app is not working and like to be able to debug a bit. I put console.log() statements in the code but where does the output go? Should it be on the console when I am connected trough ssh or do I need a serial connection? I also viewed /var/log/messages, dmesg and /tmp/lighttpd_error.log without any result.

Basically the question is, what is the best way to debug qml code?
Tom
Starting Member
Starting Member
 
Posts: 25
Joined: May 2016

Re: Software: modifications and extensions Toon

Postby Toonz » Thu Dec 22, 2016 8:58 pm

Hi all,

I purchased a second hand Toon on Marktplaats.
I rooted it successfully and running it without a subscription with Eneco.
My problem is that I cannot get any custom tile to work.
E.g. the myClock example cannot be added to the screen (not visible in the tile selection screens).
Also, when installing the Kodi remote I do see the icon in the system tray, but when I click on it, the app shows an empty screen like the app isn't starting at all.

My question is: is there a setting I can change to make these non-standard tiles work or is this a side-effect of running Toon without subscription?
If it is the latter I can probably only use one of the standard tiles to replace the content with my own, but I don't like that solution.

Any hints or tips would be highly appreciated.
member of the Toon Software Collective
User avatar
Toonz
Forum Moderator
Forum Moderator
 
Posts: 1637
Joined: December 2016

Re: Software: modifications and extensions Toon

Postby RomMon » Thu Dec 22, 2016 10:57 pm

Hi Toonz,

For the myClock example you have to be aware that the smallest typo will cause the tile not to show up.
(and a typo is sooo easily made...)

For the empty screen in kodiRemote you have to be aware that it is mainly made to show the 'queued items'.
So queue a few TVshows, or Movies, and verify if it works.
It will also show a current playing TVshow or movie (and it think video add-ons like YouTube), but than only the play/pause button and stop button will work (the stop button will stop what is playing, but you cannot resume it anymore).
RomMon
Starting Member
Starting Member
 
Posts: 43
Joined: August 2016

Re: Software: modifications and extensions Toon

Postby Toonz » Fri Dec 23, 2016 12:38 pm

RomMon wrote:Hi Toonz,
For the myClock example you have to be aware that the smallest typo will cause the tile not to show up.
(and a typo is sooo easily made...).


Thanks for the feedback. After trying the myClock example two times without success I took another approach:
I copied the clock folder and renamed all references to 'clock', including the id's in the qml files and the filenames.
That new tile did show up correctly to my surprise and can be selected when adding a tile.
I went back to the myClock example, did it again (third time) and it still doesn't show up.
If I have time during the Christmas holiday I might play around a bit more to check the difference between the two options.
At least I can start now creating my own tiles. Thanks to all on this forum for your support and happy holidays.
member of the Toon Software Collective
User avatar
Toonz
Forum Moderator
Forum Moderator
 
Posts: 1637
Joined: December 2016

Re: Software: modifications and extensions Toon

Postby Tom » Fri Dec 23, 2016 4:28 pm

Did you add the myClock to the Globals.qml file? To be able to use the custom app you should add them there.

RomMon wrote:
Code: Select all
add:   "myClock",         just after clock



Also can anybody tell me where to find the console.log("") printouts on toon? (see my previous post)
Tom
Starting Member
Starting Member
 
Posts: 25
Joined: May 2016

Re: Software: modifications and extensions Toon

Postby marcelr » Fri Dec 23, 2016 4:57 pm

Like this:

Code: Select all
toon:~# cd /
toon:/# find ./ -name console.log


Happy hunting,

marcelr
marcelr
Global Moderator
Global Moderator
 
Posts: 1152
Joined: May 2012
Location: Ehv

Re: Software: modifications and extensions Toon

Postby Toonz » Sat Dec 24, 2016 11:59 am

Tom wrote:Did you add the myClock to the Globals.qml file? To be able to use the custom app you should add them there.

Yes I did, I have added three new apps there, just the myClock doesn't show up, the others do.
Really weird. Must be a stupid typo in myClock but I can't find it, or maybe permissions now I think of it.
Will have another look next week.
member of the Toon Software Collective
User avatar
Toonz
Forum Moderator
Forum Moderator
 
Posts: 1637
Joined: December 2016

(WIP) Stand-alone tile with actual buienradar weather info.

Postby Toonz » Thu Dec 29, 2016 5:34 pm

Hi all,

I am using a Toon without Eneco subscription but did want to be able to see actual weather data from xml.buienradar.nl without making use of Eneco or another webserver at home.
This the first result, the app 'buienradar' retrieves the actual data from http://xml.buienradar.nl every 15 minutes and shows a tile with the actual temperature, windforce and wind direction of the weather station of your choice.
Future developments are to add a detail screen with all weather data from the selected station and probably more. It is not supposed to become an exact copy of the official Eneco weather app.

Bear with me this is my first Qt app, my first Java based app, my first XML processing app and my first Toon app.
I am fully aware that the code can be heavily optimised and made more resilient against XML structure changes.
I just post it here because it does what it is supposed to do and gives me the opportunity to learn from your comments :-).

Two remarks: the name of the selected weather station is hardcoded in 'buienradar.js' to allow customised short strings instead of the long XML based location names.
Secondly, the selected weather station can be updated in BuienradarApp.qml (variable location) with the code of the weather station of your choice from the XML file (line 26). Don't forget to add 'buienradar' to the Globals.qml file as usual.

I would welcome some help for the following: in order to determine the right weather icon to show I need to retrieve the values for the attributes 'ID' and 'zin' from the XML source: <icoonactueel ID="pp" zin="bewolkt">http://xml.buienradar.nl/icons/pp.gif</icoonactueel>.
Any tips ? Googled a lot but can't seem to resolve this (BuienradarApp.qml line 61/62).

Have a safe and happy new year.

(I will post future versions when substantial new functionality is added)

EDIT (marcelr): Attachment removed, stable version of the app to be found in the Downloads thread.
member of the Toon Software Collective
User avatar
Toonz
Forum Moderator
Forum Moderator
 
Posts: 1637
Joined: December 2016

Re: Software: modifications and extensions Toon

Postby Tom » Thu Dec 29, 2016 8:54 pm

marcelr wrote:Like this:

Code: Select all
toon:~# cd /
toon:/# find ./ -name console.log


Happy hunting,

marcelr


Doing this gives no results, looking for console will give several options but none of them contain any messages which are output using the console.log() in qml. How do you guys debug the apps?
Tom
Starting Member
Starting Member
 
Posts: 25
Joined: May 2016

Re: Software: modifications and extensions Toon

Postby marcelr » Thu Dec 29, 2016 9:16 pm

Doing this gives no results,

Then it doesn't exist.

Aren't the log data sent to /dev/coonsole, which, according to the kernel boot parameters, is rerouted to /dev/ttymxc0?

best,

marcelr
marcelr
Global Moderator
Global Moderator
 
Posts: 1152
Joined: May 2012
Location: Ehv

Re: Software: modifications and extensions Toon

Postby RomMon » Sat Dec 31, 2016 2:05 am

Hi Toonz,

I haven't tried your app on the Toon yet, but did play with it in a regular html file.
Found the following should work:
Code: Select all
attributes.getNamedItem("ID").value
attributes.getNamedItem("zin").value


Be aware, also just started with qml, javascript, xml...

Maybe this can be of help:
(just create a .html file with the content below)
Code: Select all
<html>
<header><title>display All</title></header>
<body>

<p id="demo">all</p>


<script>
updateBuienradar();



function updateBuienradar() {
      var xmlhttp = new XMLHttpRequest();
      xmlhttp.open("GET", "http://xml.buienradar.nl", true);
      xmlhttp.onreadystatechange=function() {
         if (xmlhttp.readyState == 4) {
            if (xmlhttp.status == 200) {
               var a, b, c, x, y, i, xmlDoc, txt;
               xmlDoc = xmlhttp.responseXML;
               txt = "";
               document.getElementById("demo").innerHTML = "ready";
               x = xmlDoc.documentElement;
               y = x.childNodes;
               for(i = 0; i < y.length; i++) {
                  txt += "Nodename 1: " + y[i].nodeName +
                  " (nodetype: " + y[i].nodeType + " )" +
                  " (nodevalue: " +  y[i].childNodes[0].nodeValue + ")<br>";
                  for(z = 0; z < y[i].childNodes.length; z++) {
                     txt += "Nodename 2: " + y[i].childNodes[z].nodeName +
                     " (nodetype: " + y[i].childNodes[z].nodeType + " )" +
                     " (nodevalue: " +  y[i].childNodes[z].childNodes[0].nodeValue + ")<br>";
                     for(a = 0; a < y[i].childNodes[z].childNodes.length; a++) {
                         txt += "Nodename 3: " + y[i].childNodes[z].childNodes[a].nodeName +
                         " (nodetype: " + y[i].childNodes[z].childNodes[a].nodeType + " )";
                         if (y[i].childNodes[z].childNodes[a].nodeType != 3) {
                            txt += " (nodevalue: " + y[i].childNodes[z].childNodes[a].childNodes[0].nodeValue + " )";
                         }
                         txt += "<br>";
                         for(b = 0; b < y[i].childNodes[z].childNodes[a].childNodes.length; b++) {
                            txt += "Nodename 4: " + y[i].childNodes[z].childNodes[a].childNodes[b].nodeName +
                           " (nodetype: " + y[i].childNodes[z].childNodes[a].childNodes[b].nodeType + " )";
                           if (y[i].childNodes[z].childNodes[a].childNodes[b].nodeType != 3) {
                              txt += " (nodevalue: " + y[i].childNodes[z].childNodes[a].childNodes[b].childNodes[0].nodeValue + " )";
                              txt += " (textContent: " + y[i].childNodes[z].childNodes[a].childNodes[b].textContent + " )";
                           }
                           txt += "<br>";
                            for(c = 0; c < y[i].childNodes[z].childNodes[a].childNodes[b].childNodes.length; c++) {
                              txt += "Nodename 5: " + y[i].childNodes[z].childNodes[a].childNodes[b].childNodes[c].nodeName +
                              " (nodetype: " + y[i].childNodes[z].childNodes[a].childNodes[b].childNodes[c].nodeType + " )";
                              if (y[i].childNodes[z].childNodes[a].childNodes[b].childNodes[c].nodeType != 3) {
                                 //txt += " (nodevalue: " + y[i].childNodes[z].childNodes[a].childNodes[b].childNodes[c].childNodes[0].nodeValue + " )";
                                 txt += " (textContent: " + y[i].childNodes[z].childNodes[a].childNodes[b].childNodes[c].textContent + " )";
                                 txt += " (attr: " + y[i].childNodes[z].childNodes[a].childNodes[b].childNodes[c].attr + " )";
                                 if (y[i].childNodes[z].childNodes[a].childNodes[b].childNodes[c].nodeName == "icoonactueel") {
                                    txt += " (nodevalue: " + y[i].childNodes[z].childNodes[a].childNodes[b].childNodes[c].childNodes[0].nodeValue + " )";
                                    txt += " (ID attribute: " + y[i].childNodes[z].childNodes[a].childNodes[b].childNodes[c].attributes.getNamedItem("ID").value + " )";
                                    txt += " (zin atribute: " + y[i].childNodes[z].childNodes[a].childNodes[b].childNodes[c].attributes.getNamedItem("zin").value + " )";
                                 }
                              }
                              txt += "<br>";
                            }
                         }
                     }
                  }
               }
               document.getElementById("demo").innerHTML =
               "Nodename xml: " + xmlDoc.nodeName +
               " (nodetype: " + xmlDoc.nodeType + ")<br>" +
               "Nodename x: " + x.nodeName +
               " (nodetype: " + x.nodeType + ")<br>" +
               txt;
            }
         }
      }
   xmlhttp.send();
}

</script>
</body>
</html>

RomMon
Starting Member
Starting Member
 
Posts: 43
Joined: August 2016

Re: Software: modifications and extensions Toon

Postby Toonz » Sat Dec 31, 2016 2:56 pm

RomMon wrote:Hi Toonz,
I haven't tried your app on the Toon yet, but did play with it in a regular html file.
Found the following should work:
Code: Select all
attributes.getNamedItem("ID").value
attributes.getNamedItem("zin").value



Hi RomMon,

Thanks for the reply, unfortunately this doesn't work on Toon (or more specific, I can't get it to work). It looks like the function XMLhttpRequest has implemented only a subset of the standard set of attributes and methods. I am now displaying the standard buienradar icon for the time being (value of the element). It does the job but the original Toon weather icons are nicer (on my wishlist now).
In the mean time I made a lot of progress. It now shows a detail screen with all weather info from your selected weather station plus the narrative weather forecast when you click on the tile. I just need to add the next 5-days forecast to it. Will upload again when done.

to be continued.... :-)
member of the Toon Software Collective
User avatar
Toonz
Forum Moderator
Forum Moderator
 
Posts: 1637
Joined: December 2016

Re: Software: modifications and extensions Toon

Postby Toonz » Sat Dec 31, 2016 6:48 pm

HI all,

my last post this year: a new release of ToonBuienradar which runs on stand alone Toons, without an Eneco subscription and without the VPN to Eneco.
It contains a detailed weather info screen with data from your selected weather station, the 5 days weather forecast table and the general weather forecast in writing.
This screen is displayed when clicking on the tile.
You only need to hardcode the weather station of your choice in BuienradarApp.qml (line 108: both the ID and the description).
Next year I might add a station selection form ;-).

All data is taken from xml.buienradar.nl, no connection to Eneco required at all. Of course Toon must have internet access.

Happy new year

EDIT (marcelr): Attachment removed, stable version of the app to be found in the Downloads thread.
member of the Toon Software Collective
User avatar
Toonz
Forum Moderator
Forum Moderator
 
Posts: 1637
Joined: December 2016

Re: Software: modifications and extensions Toon

Postby hvxl » Sun Jan 01, 2017 5:33 pm

Very nice! Thanks for sharing.

One remark, editing the location variable on line 108 of BuienradarApp.qml doesn't really help much as you still have 6344 hardcoded on line 132. Obviously you intended that to be location.

In addition, through experimentation I have found out that you can access the attributes this way:
    cNode.attributes["zin"].value
Or if you prefer:
    cNode.attributes.zin.value
Schelte
hvxl
Senior Member
Senior Member
 
Posts: 1490
Joined: June 2010

PreviousNext

Return to Toon software development

Who is online

Users browsing this forum: No registered users and 1 guest