After I got this script up and running I wanted to display the info on my wordpress page. This is how I did.
By using this code below with PHP Code for posts plugin you manage display information from your uservariables.
Code: Select all
<?php
echo "<b>Machine status</b>";
echo "</br>";
$arr = array(6, 8, 10);
foreach ($arr as &$value) {
$get_data = "http://192.168.0.11/json.htm?type=command¶m=getuservariable&idx=".$value;
$result = file_get_contents($get_data);
$decode = json_decode($result,true);
if ($decode["result"][0]["Value"] == "1"){
$icon = "green-icon.png";
}
else {
$icon = "red-icon.png";
}
switch ($decode['result'][0]['Name']) {
case "washingmachine_status":
$unit = "Washing machine";
break;
case "dryer_status":
$unit = "Dryer";
break;
case "dishwasher_status":
$unit = "Dishwasher";
break;
}
echo "</br> " . $unit . "</br><img src=\"/wp-content/uploads/2015/12/" . $icon . "\">" . $decode['result'][0]['LastUpdate'] . "<br>";
}
?>