Project Home‎ > ‎Documentation‎ > ‎Interfaces‎ > ‎

Named Pipe

NamedPipe is a virtual device that has it's roots as a UNIX pipe. It is used with a StateInterface device and points to a UNIX pipe file. A UNIX pipe file is a file that can be read and written to by more than one device. In most cases a script or other program will open the pipe file and write a state to the file name. Pytomation will read the state from the file and perform any desired actions based on the state.

Lets give an example:

Say we have a script that monitors moisture level in the ground, the script talks to a custom moisture device and indicates a moisture level from 0 to 100%. A script is then created to read the moisture level and based on the level write either an “ON” or “OFF” to the pipe file which is located at /tmp/moisture.

Now define a device in Pytomation as such:
front_yard_water = StateInterface(NamedPipe('/tmp/moisture'))

front_yard_water is connected to a sprinkler system and runs when it reads ON from the pipe. Normally one would add a timed OFF to their definition.




Comments