How about this:jkimmel wrote:@bbqkees
Is this fixed already?I created a virtual setpoint device, I now see I need to send another command for those devices.
/json.htm?type=command¶m=udevice&idx=93&nvalue=0&svalue=21.5
But I can fix that this weekend.
I changed the ValueChange function (from my last version) so that it now checks if it is either a Setpoint device or not.
If it is a Setpoint device, it will send a different json command.
Otherwise, it just does the regular dimming json command.
In the HTML change the button contents :
Code: Select all
<div class="minbutton"><input onclick="ValueChange('+item.idx+', '+vtype+', '+vdimmercurrent+', \'min\', '+vplusminus+', '+vdimmermax+');" type="submit" name="" value=""></div><span onclick="SwitchOff('+item.idx+')"; style='+alarmcss+'>'+vdata+'</span><div class="plusbutton"><input onclick="ValueChange('+item.idx+', '+vdimmercurrent+', \'plus\', '+vplusminus+', '+vdimmermax+');" type="submit" name="" value=""></div>Code: Select all
'+vtype+',And the modified ValueChange function (not tested):
Code: Select all
function ValueChange(idx, type, currentvalue, dimtype, stepsize, dimmermax)
{
newvalue='';
if (dimtype == 'plus') {
if ((currentvalue + stepsize) > dimmermax){
newvalue = dimmermax;
} else {
newvalue = currentvalue + stepsize;
}
}
else if (dimtype == 'min'){
if (currentvalue < stepsize){
newvalue = 1;
} else {
newvalue = currentvalue - stepsize;
}
}
if (type == 'Setpoint') {
$.ajax({
url: "json.htm?type=command¶m=udevice" + "&idx=" + idx + "&nvalue=0" + "&svalue=" + newvalue,
async: false,
dataType: 'json',
success: function(){
console.log('SUCCES');
},
error: function(){
console.log('ERROR');
}
});
}
else {
$.ajax({
url: "json.htm?type=command¶m=switchlight" + "&idx=" + idx + "&switchcmd=" + "Set%20Level" + "&level=" + newvalue,
async: false,
dataType: 'json',
success: function(){
console.log('SUCCES');
},
error: function(){
console.log('ERROR');
}
});
}
RefreshData();
}
