Input on pool automation

I am beginning my conceptual phase of automating my pool equipment. I wanted to get some feedback on my design. The design is still conceptual so don’t take it as set in stone.

Basically I found a pool motor that accepts digital input. My idea was to setup some relays such as the z wave gocontrol isolated relays that can trigger the digital inputs of the motor as each input you trigger respresents an rpm speed for the motor. Of course I will need a transformer to drop the power to 24v for the digital input on the motor. Does anyone know if the gocontrol will work like that. If I trigger one on will it keep the power flowing through it until I trigger it off?

2nd phase: Automation the pool/spa mode. I figured I could do that same with thegocontrol relay (again, not sure if this relay works like this) to trigger intermatic valve actuators.

There are a few pproblems I see that need to be worked out. The pump needs to be off before the valves are turned as its bad practice to turn pool valves with motor running. So I will need some rules in place. My issue is that if I have a z wave relay in place and only want it to activate when I click on the tile if the motor is stopped how would I handle that. I mean, if the device gets added to my devices shoud I edit the device handler to not allow manual activation or can I put rules in the device handler that the relay can only be activated if the motor is stopped.

I know how to write code but new to Groovy. Just trying to get the concept written out leveraging some great experience from the masses. I have read through posts but none were like what I’m trying to accomplish.

I just posted my setup here. I think something like this would be the route you want to go cause you can locally make rules like shutoff pump then move valve etc… The advantage to this is one device controlling all of it.

Automated Pool Controller

Thanks! I am looking at a simliar route with Particle. Did you create a device handler for Particle so you could control actions within the ST app? If so can you share so I can get a primer? That is what I would like to do but I am new to device handler writing.

I know code just started learning handlers and some things I don’t quite understand yet.

yes I have a couple… What actions are you most interested in? I’m not a code guy I just do it for a hobby with my self built stuff so I’m sure this could be made way better but here’s what I have and it works perfect.

Here’s my pool pump controllers device handler. Its a good example cause it both sends data to particle to trigger actions like setting pump speed as well as request data from particle variables like the current rpm and watts. I used the fake minimote template as a guide for making my device handler and then basically added more buttons and had the buttons instead of just do nothing like they do in the template I have them send a web request to the particle cloud which in turn launches functions on the device. Look at the very bottom of the code I have the “put function” that sends what button was pushed to particle to set the new pump speed and then the “getRPM” and “getWATT” request the data from a variable on the particle. I just reference those functions under button pushes and refreshes to launch them. I also under each button push call refresh so if I change the pump speed it sends the new speed to the photon and also refreshes which asks the photon for the rpm setting and power so I can verify it was received. I also have examples of a simple on off switch for controlling a single relay on a photon if you want. As far as the access token and device Id they are just added as an input so after you add the device you can click the gear in the smartthings app and give your device id and access token there.

/**
 *  Copyright 2015 SmartThings
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 */
preferences {
    input name: "deviceId", type: "text", title: "Device ID", required: true
    input name: "token", type: "password", title: "Access Token", required: true
    input name: "RPMVar", type: "text", title: "RPM Variable", required: true, defaultValue: "PumpRPM"
    input name: "wattVar", type: "text", title: "WATT Variable", required: true, defaultValue: "PowerUse"
    }
metadata {
	definition (name: "Simulated Pool Controller", namespace: "brennonsapps", author: "bscuderi") {
		capability "Actuator"
		capability "Button"
		capability "Sensor"
        attribute "RPM", "number"
       	capability "Power Meter"
        capability "Polling"
        capability "Refresh"
        capability "Temperature Measurement"
        attribute "temperature", "number"
        

        command "push1"
        command "push2"
        command "push3"
        command "push4"
        command "push5"
        command "push6"
        command "push7"
        command "push8"
	}

	simulator {
		status "button 1 pushed":  "command: 2001, payload: 01"
		status "button 5 pushed":  "command: 2001, payload: 15"
		status "button 2 pushed":  "command: 2001, payload: 29"
		status "button 6 pushed":  "command: 2001, payload: 3D"
		status "button 3 pushed":  "command: 2001, payload: 51"
		status "button 7 pushed":  "command: 2001, payload: 65"
		status "button 4 pushed":  "command: 2001, payload: 79"
		status "button 8 pushed":  "command: 2001, payload: 8D"
		status "wakeup":  "command: 8407, payload: "
	}
	tiles {
		     
		 valueTile("RPM", "device.RPM", width: 2, height: 1) {
            state("RPM", label:'${currentValue} RPM')
        }
         valueTile("WATT", "device.power", width: 1, height: 1) {
            state("power", label:'${currentValue} Watts')
        }
        standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat", width: 1, height: 1) {
            state "default", action:"refresh.refresh", icon:"st.secondary.refresh"
        }

        standardTile("button", "device.button") {
			state "default", label: "", icon: "st.unknown.zwave.remote-controller", backgroundColor: "#ffffff"
		}
 		standardTile("push1", "device.button", width: 1, height: 1, decoration: "flat") {
			state "default", label: "OFF", backgroundColor: "#ffffff", action: "push1"
		}
 		standardTile("push2", "device.button", width: 1, height: 1, decoration: "flat") {
			state "default", label: "1,000 RPM", backgroundColor: "#ffffff", action: "push2"
		}
 		standardTile("push3", "device.button", width: 1, height: 1, decoration: "flat") {
			state "default", label: "1,250 RPM", backgroundColor: "#ffffff", action: "push3"
		}
 		standardTile("push4", "device.button", width: 1, height: 1, decoration: "flat") {
			state "default", label: "1,500 RPM", backgroundColor: "#ffffff", action: "push4"
		}
 			standardTile("push5", "device.button", width: 1, height: 1, decoration: "flat") {
			state "default", label: "2,000 RPM", backgroundColor: "#ffffff", action: "push5"
		}
 		standardTile("push6", "device.button", width: 1, height: 1, decoration: "flat") {
			state "default", label: "2,500 RPM", backgroundColor: "#ffffff", action: "push6"
		}
 			standardTile("push7", "device.button", width: 1, height: 1, decoration: "flat") {
			state "default", label: "3,000 RPM", backgroundColor: "#ffffff", action: "push7"
		}
 		standardTile("push8", "device.button", width: 1, height: 1, decoration: "flat") {
			state "default", label: "3,450 RPM", backgroundColor: "#ffffff", action: "push8"
		}

		main (["RPM","WATT","button",])
		details(["RPM","WATT","push1","push2","push3","push4","push5","push6","push7","push8","refresh"])
	
       
		}

}

def parse(String description) {
    def pair = description.split(":")

    createEvent(name: pair[0].trim(), value: pair[1].trim())
}

def push1() {
    put(0)
    push(1)
    refresh()
}

def push2() {
	put(1)
    push(2)
    refresh()
}

def push3() {
	put(2)
    push(3)
    refresh()
}

def push4() {
    put(3)
    push(4)
    refresh()
}

def push5() {
	put(4)
    push(5)
    refresh()
}

def push6() {
	put(5)
    push(6)
    refresh()
}

def push7() {
	put(6)
    push(7)
    refresh()
}

def push8() {
	put(7)
    push(8)
    refresh()
}

private push(button) {
	log.debug "$device.displayName button $button was pushed"
	sendEvent(name: "button", value: "pushed", data: [buttonNumber: button], descriptionText: "$device.displayName button $button was pushed", isStateChange: true)
}


def installed() {
	initialize()
}

def updated() {
	initialize()
    // attempted fix
    log.debug "Updated !"
    state.RPM = 1    
    log.debug "device.RPM: ${device.RPM}"
}

def initialize() {
	sendEvent(name: "numberOfButtons", value: 8)
}


def poll() {
    log.debug "Executing 'poll'"
    getWATT()
    getRPM()
}

def refresh() {
    log.debug "Executing 'refresh'"
    getWATT()
    getRPM()
}
    


// get pool pump RPM
private getRPM() {
    def closure = { response ->
        log.debug "RPM request was successful, $response.data"

        sendEvent(name: "RPM", value: response.data.result)
    }

    httpGet("https://api.particle.io/v1/devices/${deviceId}/${RPMVar}?access_token=${token}", closure)
}
private getWATT() {
    def closure = { response ->
        log.debug "WATT request was successful, $response.data"

        sendEvent(name: "power", value: response.data.result)
    }

    httpGet("https://api.particle.io/v1/devices/${deviceId}/${wattVar}?access_token=${token}", closure)
}

// Send a button push to pump
private put(button) {
	httpPost(
		uri: "https://api.particle.io/v1/devices/${deviceId}/PumpSpeed",
        body: [access_token: token, command: button],  
	) {response -> log.debug (response.data)}
}

No, this is great! I better understand the handlers now. I typically write code in C# but have done Arduino and Raspberry PI.

Just new to the handlers and all that goes with them. I can better understand yours than most. There are a few that I have looked at in regards to working with Particle that contained so much garbage.

I am automating 8 valves with particle and an 8 relay board. The other 3 relays are for motor control. My motor is a Century that has a computer on top in which you basically program 3 speeds to it which is all I need. Have no need for more than 3 rpm speeds. A low and a high does pretty much what I need. But basically after you set the 3 speeds you can send a digital 12V or 24V signal via relay in which depending on which input port you trigger is the speed at which the motor runs.

The valves will be triggered for spa modes and turn on/off vacuum.

1 Like