Posted on April 8, 2017 in home automation, linux, raspberryPi
This is how I solved it!
The script that show status on homepage.
<?php echo "<b>Machine status</b>"; echo "</br>"; $arr = array(5, 7, 9); foreach ($arr as &$value) { $get_data = "http://10.0.20.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 . "\"><em>" . $decode['result'][0]['LastUpdate'] . "</em><br>"; } ?>
The script that check my machines.
--script_time_washingmachine.lua --This script monitors the current consumption indicated by a Z-Wave plug, placed between the washingmachine and the mains outlet --It will count the amount of time that the power usage is below the triggervalue to be configured below. This indicates us that the washer has finished. --When the script thinks the washingmachine is done, it will send you a pushnotification (line #38)</code> --Change the values below to reflect to your own setup local switch_washingmachine = 'virt_wasmachine' --Name of virtual switch that will show the state of the washingmachine (on/off) local washer_status_uservar = 'washingmachine_status' local energy_consumption = 'Wasmachine' --Name of Z-Wave plug that contains actual consumption of washingmachine (in Watts) local washer_counter_uservar = 'washingmachine_counter' --Name of the uservariable that will contain the counter that is needed local idle_minutes = 5 --The amount of minutes the consumption has to stay below the 'consumption_lower' value local consumption_upper = 20 --If usage is higher than this value (Watts), the washingmachine has started local consumption_lower = 3 --If usage is lower than this value (Watts), the washingmachine is idle for a moment/done washing sWatt, sTotalkWh = otherdevices_svalues[energy_consumption]:match("([^;]+);([^;]+)") washer_usage = tonumber(sWatt) commandArray = {} --Virtual switch is off, but consumption is higher than configured level, so washing has started if (washer_usage > consumption_upper) and uservariables[washer_status_uservar] == 0 then --commandArray[switch_washingmachine]='On' commandArray['Variable:' .. washer_status_uservar]='1' print('Current power usage (' ..washer_usage.. 'W) is above upper boundary (' ..consumption_upper.. 'W), so washing has started!') commandArray['Variable:' .. washer_counter_uservar]=tostring(idle_minutes) end if (washer_usage < consumption_lower) and uservariables[washer_status_uservar] == 1 then --Washing machine is not using a lot of energy, subtract the counter commandArray['Variable:' .. washer_counter_uservar]=tostring(math.max(tonumber(uservariables[washer_counter_uservar]) - 1, 0)) print('Current power usage (' ..washer_usage.. 'W) is below lower boundary (' ..consumption_lower.. 'W), washer is idle or almost ready') print('Subtracting counter with 1, new value: ' ..uservariables[washer_counter_uservar].. ' minutes') end --Washingmachine is done if ((uservariables[washer_status_uservar] == 1) and uservariables[washer_counter_uservar] == 0) then print('Washingmachine is DONE') print('Current power usage washingmachine ' ..washer_usage.. 'W') print('Washingmachine is done, please go empty it!') commandArray['SendNotification']='Washingmachine#Washingmachine is done, please go empty it!#0' --Use Domoticz to send a notification, replace line for your own command if needed. --commandArray[switch_washingmachine]='Off' commandArray['Variable:' .. washer_status_uservar]='0' end return commandArray
Posted on February 21, 2016 in home automation, linux, raspberryPi
I have a solution, this is how i manage solve this “irritating problem”.
I assume that you have a Z-wave base, mine is a raspberryPi with a razberry chip and with software domoticz.
You shoppinglist:
1pcs Inline Smart Energy Switch from Aeon Labs
1pcs Motion sensor from Fibaro
In sweden you can get all you need at www.m.nu

Aeon Labs – Switch

Fibaro motion sensor
And I use a LUA script named script_time_PIR-tv.lua. So after 20 minutes of inactivity in livingroom, the tv shutsdown… Simply as that!
function timedifference(s) year = string.sub(s, 1, 4) month = string.sub(s, 6, 7) day = string.sub(s, 9, 10) hour = string.sub(s, 12, 13) minutes = string.sub(s, 15, 16) seconds = string.sub(s, 18, 19) t1 = os.time() t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds} difference = os.difftime (t1, t2) return difference end commandArray = {} -- Set length of time light should be on for in seconds timeon = 1200 -- Calculate time since time PIR was last activated difference = timedifference(otherdevices_lastupdate['Vardagsrum motion']) -- If the time since last activation was within 1 minute of time for light to stay on if (difference > timeon and difference < (timeon + 61)) then tempdiff = tostring(difference) tempmessage = "Switch1 Light Off - after at least " .. (timeon+1) .. "secs up - actually - " .. tempdiff .. "seconds" print(tempmessage) -- Switch off Switch1 commandArray['Tv'] = 'Off' end return commandArray