Skip to content

Commit

Permalink
Merge pull request #87 from mayaculpa/dev
Browse files Browse the repository at this point in the history
Merging branch "dev" and adding small fix on ENV topic.
  • Loading branch information
TylerReedMC committed May 30, 2017
2 parents f4e5bcb + 0dd6e18 commit 2e7d15d
Show file tree
Hide file tree
Showing 19 changed files with 524 additions and 378 deletions.
68 changes: 1 addition & 67 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,73 +21,7 @@ Note: we can say that Linux Mint and Arch Linux were used to run some tests, tho

## *Development Requirements*
### **Smart Module**
1. Python influxdb: ```pip install influxdb```
2. Python schedule: ```pip install schedule```
3. Python zeroconf: ```pip install zeroconf```
4. Python psutil: ```pip install psutil```
5. Python Paho-MQTT: ```pip install paho-mqtt```
6. Python RPi.GPIO*: ```pip install RPi.GPIO```
7. Python SDL_DS3231*: ![SDL_DS3231 module](https://github.com/switchdoclabs/RTC_SDL_DS3231)

*Only needed if running on real mode (with actual sensor data). Read the next note for more information.

You might also considering using a Virtual Environment for testing.

**Note**: the system will try to import all the necessary sensor modules to run. If it can't, then the system will automatically run on "mock" mode.
If you are facing any troubles to get it running, drop us a message or open an issue.

### *System Configuration*
Note: Soon we'll introduce configuration via regular file and/or database. For now all configuration are hardcoded.
The system needs the following packages installed and properly configured:

1. **Avahi** (daemon) configured to publish MQTT service.

Here is an example. ![avahi-example](/readme/avahi-example)

Note: it must be off by default (systemctl stop avahi-daemon.service or similar).
2. **MQTT Mosquitto** with default configuration.

Here is an example. ![mosquitto-example](/readme/mosquitto-example)
3. **Influxdb** with default configuration.
4. **Grafana** [Optional] (highly recommended).

### *Usage:*
```python smart_module.py```

**You should get something like this:**

$ python smart_module.py
2017-05-15 22:37:55.089210 - communicator.log - INFO - Communicator initialized
Mock Smart Module hosting asset HSM-WT123-MOCK wt Environment
2017-05-15 22:37:55.091207 - smartmodule.log - INFO - Performing Discovery...
2017-05-15 22:37:55.091782 - smartmodule.log - INFO - Waiting Broker information on attempt: 1.
2017-05-15 22:37:56.092877 - smartmodule.log - INFO - MQTT Broker: ArchMain.local. IP: 192.168.0.99.
2017-05-15 22:37:56.093225 - communicator.log - INFO - Connecting to ArchMain.local. at 192.168.0.99.
2017-05-15 22:37:57.094778 - communicator.log - INFO - Connected with result code 0
$SYS/broker/clients/total 0
$SYS/broker/clients/total 1
2017-05-15 22:38:02.648088 - smartmodule.log - INFO - No Scheduler found. Becoming the Scheduler.
2017-05-15 22:38:02.648342 - scheduler.log - INFO - Loading Schedule Data...
2017-05-15 22:38:02.648997 - scheduler.log - INFO - Schedule Data Loaded.
2017-05-15 22:38:02.649105 - scheduler.log - INFO - Loading seconds job: System Status.
2017-05-15 22:38:02.649160 - scheduler.log - INFO - Loading seconds job: Check Alert.
2017-05-15 22:38:02.649627 - smartmodule.log - INFO - Scheduler program loaded.
2017-05-15 22:38:02.650200 - smartmodule.log - INFO - Site data loaded.
Running command self.smart_module.on_query_status()
Running command self.smart_module.on_check_alert()
STATUS/QUERY I might need to know how you are!
ASSET/QUERY/HSM-WT123-MOCK Is it warm here?
STATUS/RESPONSE [{'memory': {'cached': 913498112, 'used': 2294038528, 'free': 533913600}, 'disk': {'total': 52472872960, 'free': 36725215232, 'used': 13051768832}, 'network': {'packet_recv': 558630, 'packet_sent': 601295}, 'time': 1494898693.364454, 'hostname': 'ArchMain', 'boot': '2017-05-15 17:09:17', 'cpu': {'percentage': 3.2}, 'clients': 1}]
ASSET/RESPONSE/HSM-WT123-MOCK 8.0
2017-05-15 22:38:13.892977 - alert.log - INFO - Fetching alert param. from database
2017-05-15 22:38:13.893555 - alert.log - INFO - ALERT DETECTED. Value: 8.0.
2017-05-15 22:38:14.283729 - smartmodule.log - INFO - Wrote to analytic database: [{'fields': {'unit': 'C', 'value': '8.0'}, 'tags': {'site': u'HPF-0', 'asset': 'Indoor Temperature'}, 'time': '2017-05-15 22:38:14.010127', 'measurement': 'Environment'}].

An important note: we're currently using sqlite3 database to load schedule jobs and others information.
You can check/use a demo of the database here: ![Database example](/readme/database-example)
For now you should place it on the same folder as `smart_module.py` and name it as `hapi_core.db`.

You might have noticed we're using many hard-coded information. We will refactor them soon.
See src/smart-module/README.rst for details about smart module.

### Node (HAPInode)
**Soon.**
Expand Down
52 changes: 52 additions & 0 deletions readme/FMS.Requirements.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
==============
FMS Activities
==============

.. image:: hapi-four-leaf-square.png

Home Screen
===========

- User can see/edit Site Name
- User can see activated Alerts
- Show current Asset (sensor) readings
- User can rename an asset
- User can select frequency of screen refresh
- HAPI Logo should be visible

Configure Site
==============
- Set WiFi SSID and Password (bluetooth based)
- Set Cloud Analytics User and Password
- Set Site Name
- Set Operator Email Address
- Set Latitude and Longitude
- Set Weather Underground API Key Information (tentative)
- Set Twilio Account Information (SSID & Token) (tentative)

Manage Scheduled Jobs
=====================
- Schedulable Jobs are
- Check Alerts
- Get Sensor Data
- Get System Health
- Get Weather Data (if Wunderground info is set)
- User can Enable/Disable jobs
- User can set job time interval to seconds, minutes, hours or days
- User can set the frequency in integer values
- The above 2 reqs allow the user to run a job “every 10 seconds", “every 3 hours”, etc

View Analytics
==============
- User can view historic/analytic visualizations in WebView

Manage Alerts
=============
- User can Create an alert with Asset Name, Lower Threshold, Upper Threshold
- User can edit alert message e.g. “Reservoir Level Low”
- User can set 1 or more notification options for an alert (email, SMS, Home Screen)
- Multiple alerts can be created for any 1 asset
- This supports scenarios like show an On-Screen if the level is low and send a text message
- if it goes empty.
- User can Disable/Enable an alert
- User can Delete an alert

0 comments on commit 2e7d15d

Please sign in to comment.