https://github.com/bjyurkovich/iotery_command_example
https://github.com/bjyurkovich/iotery_command_example
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/bjyurkovich/iotery_command_example
- Owner: bjyurkovich
- Created: 2019-07-10T13:31:58.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T05:52:06.000Z (about 3 years ago)
- Last Synced: 2025-06-10T19:18:29.754Z (7 months ago)
- Language: Python
- Size: 3.91 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Iotery Command Example in Python
The following code is an example utilizing a server and a device to create a command instance, have the device process the command, and set the command as executed.
Make sure you are using Python 3!
## Getting Started
Clone the repo:
```
git clone https://github.com/bjyurkovich/iotery_command_example.git
```
Activate your virtualenv and install the dependencies:
```
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
```
The `server.py` and `device.py` assume you have some environment variables set:
```
export IOTERY_API_KEY=your-api-key-found-on-iotery-dashboard
export IOTERY_TEAM_UUID=your-iotery-team-uuid-found-on-dashboard
export IOTERY_DEVICE_SERIAL=your-device-serial-that-you-create
export IOTERY_DEVICE_KEY=your-device-serial-that-you-create
export IOTERY_DEVICE_SECRET=your-device-serial-that-you-create
```
If you are new to Iotery an creating device types and devices, [check out this tutorial](https://dev.to/bjyurkovich/get-started-with-your-iot-devices-using-iotery-io-4c2d).
## Running the Example:
Then run the server:
```
python server.py
```
> `server.py` assumes you have already created a device (identity set in your env vars), command type called `SENSOR_COMMAND_1`, and a command field for that command type called `TIME_TO_TURN_ON`. The server will create a `command instance` that will be retrieved by the device when it posts data
and then run the device:
```
python device.py
```
> `device.py` assumes you have created your device in iotery and will post data to the cloud, and if a command instance exists from your server, will set it executed after printing out the command field.