Laundry status in Domoticz

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.

Moderator: leecollings

Post Reply
franzelare
Posts: 141
Joined: Thursday 19 February 2015 21:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Laundry status in Domoticz

Post by franzelare »

We recently moved and I was annoyed that I couldn't hear the buzzer anymore when the laudry is ready, since the washing machine and dryer are on an other floor in a separate room.
The purpose now is to display the status of the washing machine and dryer on my domotica app.
The signal can be connected to the GPIO port of the raspberry Pi that is almost next to it (now just control the heating and ventilation of the house)
Status to be displayed off/running/ready on my custom frontpage runing on an other Rasberry Pi
- Off would be when there is no power on the unit
- Running would be when there is power
- Finished would be when the LED with the finised status is on

First I started with taking the dryer apart to figure out who the LED's were controlled, since this unit is light weight and hardly used in summertime.
Image

The LED's are controlled by a darlington array on one side and a transistor on the other side, making them actually blink at ~10MHz (CPU run at 20MHz)
so this has to be tapped of, keeping the LED's working as normal and stabilizing the signal so the pi get's a continues signal and not the high frequency switching of the LED.

I have been thinking about using the flashport and hook this up to the SPI port of a raspberry pi, but that seems a lot more work than just reading the LED status.

Image

I slodered wires to the power connection and the signal for the finished LED

Image

then I hooked the wiring up to a circuit that would switch the GPIO ports using a optocoupler (to keep the units electrically separated)

Image

and on the second side connected the pi

Image

i installed a small box on the back of the dryer to install the electronics in

Image

then I tested the circuit and finetuned the capacitor and resistor values to get a stable output signal on the second side of the opto couplers

Image

and figures out how the LED's were controllerd in the washing machine to hook them up to the box on the back of the dryer

Image

when both units worked at the test setup, i made a small board to go into the box on the back of the dryer instead of the test board

Image
Image
Image

finally i hooked the signals up to my pi i'm using for my heating and ventilation control and added the idx to my custom frontpage
I use a python script that runs every 30 seconds and checks the status of the GPIO pins and compares them to the status in domoticz, if not equal, it changes the status in domoticz otherwise it sleeps again 30 seconds (using wiringpi2 library)

I put a lot more details in a few slides for the once who are interested in more about this project.

home.kpn.nl/fwiegers1995/doc/washing ma ... moticz.pdf

time to start a new project!
franzelare
Posts: 141
Joined: Thursday 19 February 2015 21:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Laundry status in Domoticz

Post by franzelare »

this is the bash script to start the python script that reads the pins, the bash scripts is started from rc.local at boot

Code: Select all

#!/bin/sh
# GPIO status detection launcher

sudo python /home/pi/domoticz/scripts/python/GPIOstatusdetection.py

Code: Select all

#!/usr/bin/python

import wiringpi2 as wiringpi  
import sys
import datetime
import time
import os
import subprocess
import urllib2
import json
import base64

# Settings for the domoticz server
domoticzserver="127.0.0.1:8080"
domoticzusername = ""
domoticzpassword = ""

# variables to be set depending on switch and pin ID matching wiringpi pin numbers to domoticz swtich id's
switchid0="94"
switchid1="95"
switchid2="96"
switchid3="97"
switchid4="98"
interval="30"

# debug y=on n=off
debug="n"

base64string = base64.encodestring('%s:%s' % (domoticzusername, domoticzpassword)).replace('\n', '')
domoticzurl = 'http://'+domoticzserver+'/json.htm?type=devices&filter=all&used=true&order=Name'

# set the GPIO port correct for the script
wiringpi.wiringPiSetup()
wiringpi.pinMode(0, 0)
wiringpi.pullUpDnControl(0, 2)# set pull-up
wiringpi.pinMode(1, 0)
wiringpi.pullUpDnControl(1, 1)# set pull-down
wiringpi.pinMode(2, 0)
wiringpi.pullUpDnControl(2, 1)# set pull-down
wiringpi.pinMode(3, 0)
wiringpi.pullUpDnControl(3, 1) # set pull-down
wiringpi.pinMode(4, 0)
wiringpi.pullUpDnControl(4, 1) # set pull-down

def domoticzstatus0 ():
  json_object = json.loads(domoticzrequest(domoticzurl))
  status = 0
  switchfound = False
  if json_object["status"] == "OK":
    for i, v in enumerate(json_object["result"]):
      if json_object["result"][i]["idx"] == switchid0 and "Lighting" in json_object["result"][i]["Type"] :
        switchfound = True
        if json_object["result"][i]["Status"] == "On": 
          status = 1
        if json_object["result"][i]["Status"] == "Off": 
          status = 0
  if switchfound == False: print (datetime.datetime.now().strftime("%H:%M:%S") + "- Error. Could not find switch idx in Domoticz response. Defaulting to switch off.")
  return status

def domoticzstatus1 ():
  json_object = json.loads(domoticzrequest(domoticzurl))
  status = 0
  switchfound = False
  if json_object["status"] == "OK":
    for i, v in enumerate(json_object["result"]):
      if json_object["result"][i]["idx"] == switchid1 and "Lighting" in json_object["result"][i]["Type"] :
        switchfound = True
        if json_object["result"][i]["Status"] == "On": 
          status = 1
        if json_object["result"][i]["Status"] == "Off": 
          status = 0
  if switchfound == False: print (datetime.datetime.now().strftime("%H:%M:%S") + "- Error. Could not find switch idx in Domoticz response. Defaulting to switch off.")
  return status

def domoticzstatus2 ():
  json_object = json.loads(domoticzrequest(domoticzurl))
  status = 0
  switchfound = False
  if json_object["status"] == "OK":
    for i, v in enumerate(json_object["result"]):
      if json_object["result"][i]["idx"] == switchid2 and "Lighting" in json_object["result"][i]["Type"] :
        switchfound = True
        if json_object["result"][i]["Status"] == "On": 
          status = 1
        if json_object["result"][i]["Status"] == "Off": 
          status = 0
  if switchfound == False: print (datetime.datetime.now().strftime("%H:%M:%S") + "- Error. Could not find switch idx in Domoticz response. Defaulting to switch off.")
  return status

def domoticzstatus3 ():
  json_object = json.loads(domoticzrequest(domoticzurl))
  status = 0
  switchfound = False
  if json_object["status"] == "OK":
    for i, v in enumerate(json_object["result"]):
      if json_object["result"][i]["idx"] == switchid3 and "Lighting" in json_object["result"][i]["Type"] :
        switchfound = True
        if json_object["result"][i]["Status"] == "On": 
          status = 1
        if json_object["result"][i]["Status"] == "Off": 
          status = 0
  if switchfound == False: print (datetime.datetime.now().strftime("%H:%M:%S") + "- Error. Could not find switch idx in Domoticz response. Defaulting to switch off.")
  return status

def domoticzstatus4 ():
  json_object = json.loads(domoticzrequest(domoticzurl))
  status = 0
  switchfound = False
  if json_object["status"] == "OK":
    for i, v in enumerate(json_object["result"]):
      if json_object["result"][i]["idx"] == switchid4 and "Lighting" in json_object["result"][i]["Type"] :
        switchfound = True
        if json_object["result"][i]["Status"] == "On": 
          status = 1
        if json_object["result"][i]["Status"] == "Off": 
          status = 0
  if switchfound == False: print (datetime.datetime.now().strftime("%H:%M:%S") + "- Error. Could not find switch idx in Domoticz response. Defaulting to switch off.")
  return status


def domoticzrequest (url):
  request = urllib2.Request(url)
  request.add_header("Authorization", "Basic %s" % base64string)
  response = urllib2.urlopen(request)
  return response.read()



while 1==1:
  currentstate0 = domoticzstatus0()
  if(wiringpi.digitalRead(0) == 1) and currentstate0 == 0: 
 	domoticzrequest("http://" + domoticzserver + "/json.htm?type=command&param=switchlight&idx=" + switchid0 + "&switchcmd=On&level=0")
  if(wiringpi.digitalRead(0) == 0) and currentstate0 == 1: 
	domoticzrequest("http://" + domoticzserver + "/json.htm?type=command&param=switchlight&idx=" + switchid0 + "&switchcmd=Off&level=0")
  if debug == "y": print ("Current 0 status:" +str(currentstate0))
  if debug == "y": print ("input 0 status:" +str(wiringpi.digitalRead(0)))

  currentstate1 = domoticzstatus1()
  if(wiringpi.digitalRead(1) == 1) and currentstate1 == 0: 
 	domoticzrequest("http://" + domoticzserver + "/json.htm?type=command&param=switchlight&idx=" + switchid1 + "&switchcmd=On&level=0")
  if (wiringpi.digitalRead(1) == 0) and currentstate1 == 1: 
	domoticzrequest("http://" + domoticzserver + "/json.htm?type=command&param=switchlight&idx=" + switchid1 + "&switchcmd=Off&level=0")
  if debug == "y": print ("Current 1 status:" +str(currentstate1))
  if debug == "y": print ("input 1 status:" +str(wiringpi.digitalRead(1)))

  currentstate2 = domoticzstatus2()
  if(wiringpi.digitalRead(2) == 1) and currentstate2 == 0: 
 	domoticzrequest("http://" + domoticzserver + "/json.htm?type=command&param=switchlight&idx=" + switchid2 + "&switchcmd=On&level=0")
  if (wiringpi.digitalRead(2) == 0) and currentstate2 == 1: 
	domoticzrequest("http://" + domoticzserver + "/json.htm?type=command&param=switchlight&idx=" + switchid2 + "&switchcmd=Off&level=0")
  if debug == "y": print ("Current 2 status:" +str(currentstate2))
  if debug == "y": print ("input 2 status:" +str(wiringpi.digitalRead(2)))

  currentstate3 = domoticzstatus3()
  if(wiringpi.digitalRead(3) == 1) and currentstate3 == 0: 
 	domoticzrequest("http://" + domoticzserver + "/json.htm?type=command&param=switchlight&idx=" + switchid3 + "&switchcmd=On&level=0")
  if (wiringpi.digitalRead(3) == 0) and currentstate3 == 1: 
	domoticzrequest("http://" + domoticzserver + "/json.htm?type=command&param=switchlight&idx=" + switchid3 + "&switchcmd=Off&level=0")
  if debug == "y": print ("Current 3 status:" +str(currentstate3))
  if debug == "y": print ("input 3 status:" +str(wiringpi.digitalRead(3)))

  currentstate4 = domoticzstatus4()
  if(wiringpi.digitalRead(4) == 1) and currentstate4 == 0: 
 	domoticzrequest("http://" + domoticzserver + "/json.htm?type=command&param=switchlight&idx=" + switchid4 + "&switchcmd=On&level=0")
  if(wiringpi.digitalRead(4) == 0) and currentstate4 == 1: 
	domoticzrequest("http://" + domoticzserver + "/json.htm?type=command&param=switchlight&idx=" + switchid4 + "&switchcmd=Off&level=0")
  if debug == "y": print ("Current 4 status:" +str(currentstate4))
  if debug == "y": print ("input 4 status:" +str(wiringpi.digitalRead(4)))

  if debug == "y": print ("Sleep:" +str(interval) +"Seconde")
  time.sleep (float(interval))
nigels0
Posts: 221
Joined: Thursday 23 January 2014 12:43
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Contact:

Re: Laundry status in Domoticz

Post by nigels0 »

Great work! I suppose this is fully adaptable to anything using a led to denote status.
franzelare
Posts: 141
Joined: Thursday 19 February 2015 21:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Laundry status in Domoticz

Post by franzelare »

In my case the LED's were not continuesly on, they were actually blinking with a few MHz so appear always on... for that I needed the stabilization next to the amplification, but it would not hurt to have it in when the LED is on a stable signal.
I also wanted the original led to remain working as normal, in case my network would be down, so I could not remove the LED and use the signal, I had to amplify it enough for both to work

I think I will upgrade the system soon and replace the connection to the Pi with an arduino nano with ethernet gateway and mysensor gateway. than mount a RJ45 connector in the back of my washing machine and dryer since there is a router almost next to them
but for that I also need to see if the power supply onboard the machine can power the nano and interface or if I have to add a additional power supply and tie that in with the on of dail on the machine
pbrink
Posts: 5
Joined: Wednesday 04 February 2015 20:37
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Laundry status in Domoticz

Post by pbrink »

Interesting, I had saw the same challenge :) (was not really frustrated, but always looking to add sensors to my home).

I am intend to do this by measuring Vibration with a vibration sensor. I assume there must be a pattern or a number of minutes after heavy vibrations (centrifugeren), but still waiting on the parts to come in from China :).
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Laundry status in Domoticz

Post by ThinkPad »

Cool project!

To make this wireless, you could also modify a cheap doorcontact (PT2262) or a cheap 433Mhz. I did that to receive my doorbell in Domoticz: http://thinkpad.tweakblogs.net/blog/120 ... aar-433mhz (Dutch, but you will understand the scheme i guess). The power needed for the doorcontact/remote could be grabbed of the PCB of your washer maybe.

For the washing machine, i was busy writing a script that measures the energy consumption of the washer (Z-Wave plug): http://domoticz.com/forum/viewtopic.php?f=23&t=253
It's not finished yet, i am quite busy the last weeks.
I am not active on this forum anymore.
franzelare
Posts: 141
Joined: Thursday 19 February 2015 21:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Laundry status in Domoticz

Post by franzelare »

an esp8266 might also be interesting...
GPIO can be expanded up to 10 pins with some soldering, only need to get it fully functional as mysensor node by just running on the onboard chip
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest