Skip to content

Commit

Permalink
- better command input handling in python server (empty string as out…
Browse files Browse the repository at this point in the history
…put value)

- added links in Readme
  • Loading branch information
jgerlach-erminas committed Nov 25, 2019
1 parent 797e675 commit efdb3ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Python/Websocket based RevPi Nodes for Node-RED.
Server
------
> The server is needed to communicate between the Node-RED RevPi nodes and the I/O pins on the RevPi.
It is a Python based websocket server which utilizes the Python library [RevPiModIO](https://revpimodio.org/) to interface between the RevPi process image and Node-RED. The associated RevPi nodes can be acquired via the node-red-contrib-revpi-nodes package in the Node-RED Library or [here](https://github.com/erminas/node-red-contrib-revpi-nodes).
It is a Python based websocket server which utilizes the Python library [RevPiModIO](https://revpimodio.org/) to interface between the RevPi process image and Node-RED. The associated RevPi nodes can be acquired via the [node-red-contrib-revpi-nodes package](https://flows.nodered.org/node/node-red-contrib-revpi-nodes) in the Node-RED Library or [here](https://github.com/erminas/node-red-contrib-revpi-nodes).

### Installation
1. Install the server with the following command:
Expand Down
10 changes: 8 additions & 2 deletions revpi-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,15 @@ def handle_websocket_message(self, client, server, message):
server.send_message(client, message + ";" + json.dumps(self.get_io_list()))
elif command == "output": # write to pin
if isinstance(self.revpi.io[args[0]].value, bool):
val = bool(int(args[1]))
try:
val = bool(int(args[1]))
except ValueError:
val = False
elif isinstance(self.revpi.io[args[0]].value, int):
val = int(args[1])
try:
val = int(args[1])
except ValueError:
val = 0
else:
val = args[1]

Expand Down

0 comments on commit efdb3ad

Please sign in to comment.