How is a switch ope...
Clear all

How is a switch operated by a sensor?  


New Member
Joined: 1 year ago
Posts: 2
June 28, 2019 8:55 am  

So I want a to switch on a pump when the water level reaches a certain point. I have the deriver for the water sensor working okay I think. It is a simple 0,1 kind of thing, where if there is water, the output is 1. So that's all good, but when the level goes to 1, how does it trigger the switch?

Member Admin
Joined: 6 years ago
Posts: 5
June 28, 2019 11:24 am  

You didn't mention that there is a driver for the switch.  You need a driver for the switch itself.  You can probably use our GPIO driver for your switch if you aren't already:

There's a couple ways to accomplish this: 1- put some code in your sensor driver, or 2- use our propagate app.

First the more difficult but more streamlined way, put the code in your water sensor driver:

// find the pump switch
const query = this.server.where({name: "pump_switch"}); // (or whatever your pump switch is named )
this.server.find(query, (err, results) => {
this.pump_switch = results[0];

// now set up an event handler to call the pump_switch directly when needed
this.streams['high_water'].on('data', (message) => {'change-output', 'high');

The other option is to simply use our propagate app:

Just set up the config.json for the sensor device (fromDevice) and the pump switch (toDevice):

"connections": [
"fromDevice": {
"name": "water",
"property": "high_water"
"toDevice": {
"name": "pump_switch",
"transitions": [
"transition": "change-output",
"arguments": ["high"],
"acceptsMessage": false

Then whenever the water sensor triggers 'high_water', the pump switch will receive the 'change-output high' command.