View Single Post
Markkyboy's Avatar
Posts: 433 | Thanked: 727 times | Joined on Oct 2012 @ Costa Blanca, Espaņa
#22
I need some help with the following;

I'm making a webview app for tasmota, it has 2 preset cover actions; 1 for toggling power of my 'sonoff basic' and the other for my main desk lamp via 'sonoff RF bridge'.

When I press either of my cover action buttons, I get the desired result (light off or on; power off or on), the first press of either button returns the http response data and displays it on the cover, but pressing either of the cover actions after the initial press, the response message is not displayed - why is this response text not repeatable?, what do i need to do so that each time a cover action is pressed, I get the response text displayed.

I think Timer may have something to do with the problem, or does it?,

Here's my code so far;

Code:
        CoverAction {
            iconSource: "image://theme/icon-cover-location"
            onTriggered: getData();

            function getData(url) {
                var xhttp = new XMLHttpRequest();
                var url = "http://192.168.1.201/cm?cmnd=rfkey1"

                xhttp.onreadystatechange=function() {
                    if (xhttp.readyState == XMLHttpRequest.DONE) {
                        console.log(xhttp.responseText);
                        mainText.text = xhttp.responseText;
                    }
                };
                xhttp.open("GET", url);
                xhttp.send();
            }
        }
    }
    Label {
        text: ""
        id: mainText
        x: Theme.paddingMedium
        horizontalAlignment: Text.AlignHCenter
        font.pixelSize: Theme.fontSizeExtraSmall
        width: parent.width -x*2
        anchors {
            bottom: cover.bottom
            bottomMargin: Theme.paddingLarge*4
            horizontalCenter: parent.horizontalCenter
        }
        Timer {
            interval: 5000; running: true;
            onTriggered: mainText.opacity = 0.0;
        }
    }
__________________
..oO(Don't just sit there standing around, pick up a shovel and sweep up!)Oo..
 

The Following 2 Users Say Thank You to Markkyboy For This Useful Post: