Skip to content

Commit

Permalink
pressure model
Browse files Browse the repository at this point in the history
  • Loading branch information
laurabugo authored and AdamF42 committed Jul 22, 2020
1 parent da4b8ef commit b6ed8bb
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 24 deletions.
4 changes: 2 additions & 2 deletions AlertBot/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM node:12.18.1-alpine3.12
FROM node:12.18.1

# use the value to set the ENV var default
ENV TOKEN=$TOKEN
ENV TELEGRAM_TOKEN=$TELEGRAM_TOKEN
ENV CHAT_ID=$CHAT_ID

# Create app directory
Expand Down
1 change: 1 addition & 0 deletions ForecastingService/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ENV INFLUX_BUCKET=$INFLUX_BUCKET

COPY . /app
WORKDIR /app
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
ENTRYPOINT ["python"]
CMD ["app.py"]
20 changes: 10 additions & 10 deletions ForecastingService/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
app = Flask(__name__)

# Auth parameters
my_token = "yaKfFeAsha8tNAZxvYeZBMmq-khO8tz-6Ut_PARgohiWzeW2j8BB86ND33Qbq7hR8bylmOROPQAUr-7M103_Yw==" #os.environ['INFLUX_TOKEN']
my_org = "iot-org" #os.environ['INFLUX_ORG']
bucket = "iot-demo" #os.environ['INFLUX_BUCKET']
influx_url = "http://192.168.1.100:9999" #os.environ['INFLUX_URL']
my_token = os.environ['INFLUX_TOKEN']
my_org = os.environ['INFLUX_ORG']
bucket = os.environ['INFLUX_BUCKET']
influx_url = os.environ['INFLUX_URL']


client = InfluxDBClient(url=influx_url, token=my_token, org=my_org, debug=False)
Expand Down Expand Up @@ -83,11 +83,11 @@ def predict_room(df):
df = df.drop(columns=['people'])
(to_be_predicted, data_mean, data_std) = normalize_dataframe(df)
prediction_temperature = temperature_model.predict(to_be_predicted)
prediction_temperature = (data_std[1] * prediction) + data_mean[1]
prediction_temperature = (data_std[1] * prediction_temperature) + data_mean[1]
prediction_humidity = humidity_model.predict(to_be_predicted)
prediction_humidity = (data_std[2] * prediction) + data_mean[2]
prediction_humidity = (data_std[2] * prediction_humidity) + data_mean[2]
prediction_pressure = pressure_model.predict(to_be_predicted)
prediction_pressure = (data_std[0] * prediction) + data_mean[0]
prediction_pressure = (data_std[0] * prediction_pressure) + data_mean[0]
return prediction_temperature, prediction_humidity, prediction_pressure


Expand All @@ -97,13 +97,13 @@ def predict_room(df):
people_model = tf.keras.models.load_model('./model/people_model.h5')

if (os.path.exists('./model/humidity_model.h5')):
people_model = tf.keras.models.load_model('./model/humidity_model.h5')
humidity_model = tf.keras.models.load_model('./model/humidity_model.h5')

if (os.path.exists('./model/pressure_model.h5')):
people_model = tf.keras.models.load_model('./model/pressure_model.h5')
pressure_model = tf.keras.models.load_model('./model/pressure_model.h5')

if (os.path.exists('./model/temperature_model.h5')):
people_model = tf.keras.models.load_model('./model/temperature_model.h5')
temperature_model = tf.keras.models.load_model('./model/temperature_model.h5')

@app.route('/predict', methods=['GET'])
def predict():
Expand Down
Binary file modified ForecastingService/model/humidity_model.h5
Binary file not shown.
Binary file added ForecastingService/model/pressure_model.h5
Binary file not shown.
4 changes: 2 additions & 2 deletions ForecastingService/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tensorflow
Flask
numpy
pandas
influxdb_client
tensorflow
influxdb_client
2 changes: 1 addition & 1 deletion WriterService/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:12.18.1-alpine3.12
FROM node:12.18.1

# use the value to set the ENV var default
ENV INFLUX_URL=$INFLUX_URL
Expand Down
6 changes: 6 additions & 0 deletions WriterService/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions WriterService/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"typescript": "^3.9.5"
},
"devDependencies": {
"@types/node": "^14.0.24",
"concurrently": "^5.2.0",
"nodemon": "^2.0.4"
}
Expand Down
17 changes: 14 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.7"
services:
grafana:
image: grafana/grafana:6.7.3
image: grafana/grafana:7.1.0
container_name: grafana
restart: unless-stopped
user: ${GRAFANA_USER_ID}
Expand All @@ -14,7 +14,7 @@ services:
env_file:
- .env
influxdb:
image: quay.io/influxdb/influxdb:2.0.0-beta
image: influx
container_name: influxdb
restart: unless-stopped
ports:
Expand All @@ -31,7 +31,7 @@ services:
restart: unless-stopped
network_mode: host
environment:
- "TZ=America/Los_Angeles"
- "TZ=Europe/Rome"
volumes:
- ${MOZILLA_IOT_VOLUME}:/home/node/.mozilla-iot
logging:
Expand All @@ -54,5 +54,16 @@ services:
- .env
networks:
- monitoring
writer_service:
image: writer_service
container_name: writer_service
restart: unless-stopped
build:
context: ./WriterService
dockerfile: Dockerfile
env_file:
- .env
networks:
- monitoring
networks:
monitoring:
8 changes: 2 additions & 6 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,12 @@ docker stop influxdb && docker rm influxdb

sudo rm $INFLUX_VOLUME/influx_setup $INFLUX_VOLUME/install.sh

# # check meta.db file in meta folder to make sure that the changes were correctly written
#DATA=$(sudo cat $INFLUX_VOLUME/influxd.bolt | grep 'User Created' )
#[[ "$DATA" != *"Binary"* ]] && { cerror "influxd.bolt file incorrenct."; exit 1 ; }

############################# GRAFANA #############################

docker container run -d --name grafana \
-v=$GRAFANA_VOLUME:/var/lib/grafana \
-p 3000:3000 \
grafana/grafana:6.7.3 \
grafana/grafana:7.1.0 \

wait-for-url http://localhost:3000

Expand All @@ -125,7 +121,7 @@ sudo tee .env << END
INFLUX_VOLUME=$INFLUX_VOLUME
GRAFANA_VOLUME=$GRAFANA_VOLUME
MOZILLA_IOT_VOLUME=$MOZILLA_IOT_VOLUME
TOKEN=$TOKEN
TELEGRAM_TOKEN=$TELEGRAM_TOKEN
CHAT_ID=$CHAT_ID
GRAFANA_USER_ID=$GRAFANA_USER_ID
END
Expand Down

0 comments on commit b6ed8bb

Please sign in to comment.