Page 1 of 1

send value via dashboard

Posted: 23 Aug 2019, 23:18
by ingoiot
hi,

i want to set the switching temperature of my smartplug on the mini dashboard.
i've no html skills whatsoever, maybe someone could give me the code for an textfield which sends its value on button click

so far i copied the code from the wiki and added my sensor to display its value, but im not able to get the setpoint transfered at all.

Code: Select all

<meta name="viewport" content="width=width=device-width, initial-scale=1">
<STYLE>
* {font-family:sans-serif; font-size:16pt;}
.button {margin:4px; padding:4px 16px; background-color:#07D; color:#FFF; text-decoration:none; border-radius:4px}
</STYLE>
<HTML>
<br><br>
<table>
<tr><td>aktuelle Temperatur<td align='center'>[ds18b20#Temperature]
<td><a class='button link' href="dashboarddemo.esp?cmd=taskvalueset oder variablennamen?">Up</a>
<td><a class='button link' href="dashboarddemo.esp?cmd=event,valuedown">Down</a>
<td><a class='button link' href="dashboarddemo.esp?cmd=event,valuedown">Down</a>
</HTML>

Re: send value via dashboard

Posted: 24 Aug 2019, 08:37
by grovkillen
Try changing this line:

Code: Select all

href="dashboarddemo.esp?cmd=...
To

Code: Select all

href="/control?cmd=...

Re: send value via dashboard

Posted: 24 Aug 2019, 13:14
by ingoiot
my problem starts even earlier.
how to change "button" class to something that accepst a number input and and creates an ok button to send it.

Re: send value via dashboard

Posted: 06 Sep 2019, 23:57
by ingoiot
there is currently no way to add to this line

<td><a class='button link' href="dashboarddemo.esp?cmd=event,valuedown">Down</a>

a variable like

<td><a class='button link' href="dashboarddemo.esp?cmd=event,valuedown <var>22</var> Down</a>

i only can send the whole line via the button, or am wrong?

Re: send value via dashboard

Posted: 23 Sep 2019, 20:17
by tiomny
Try this approach:
Create a script section and add the following code:
function espCommand(command) {
var req = new Image();
req.src = "/dashboarddemo.esp?cmd=" + command + ',' + document.getElementById('somevar').value;
}
Using:
<input type='text' id='somevar' />
<a class='button link' onclick="espCommand('taskvalueset')">Up</a>
This is a pure JS, indeed, with jQuery or Angular you can create a much powerful dashboard.