Bump
I’ve been playing with this in the last days, and got it quite working as I want. Thanks for the nice work.
The original pihlaja-script.js script connects to the socket, and get all the states from pimatic. It was a little bitch to find out all the object-id’s and I was afraid how future proof this would be when the object-id changes.
So I changed it into this:
function GetStates()
{
socket.on('devices', function(devices)
{
console.log(devices);
$.each( devices, function( key, value )
{
if (devices[key].id == "bijkeuken")
{
toggleUI(devices[key]["attributes"][0].value, "bijkeuken")
}
if (devices[key].id == "anybody-home")
{
toggleCircle(devices[key].attributes[0].value.toString(), "anybodyhome")
}
});
$("#mainLoading").hide();
$("#main").show();
});
}
And created some general functions:
function toggleUI(state, device)
{
if (state == true)
{
$("#" + device).addClass('active');
}
else
{
$("#" + device).removeClass('active');
}
}
function toggleCircle(state, device)
{
if (state == "true")
{
document.getElementById(device).innerHTML = "<span class='fa fa-circle pull-right'></span>";
}
if (state == "false")
{
document.getElementById(device).innerHTML = "<span class='fa fa-circle-o pull-right'></span>";
}
}
function toggleDevice(device){
socket.emit('call', {
id: 'executeAction-1',
action: 'executeAction',
params: {
actionString: 'toggle ' + device
}
});
}
Hope someone finds this useful