Skip to content

Latest commit

 

History

History
58 lines (49 loc) · 2.6 KB

README.md

File metadata and controls

58 lines (49 loc) · 2.6 KB

logo

Project 5 Web Application

Running

  1. Install Docker, ngrok.
  2. Run ngrok http 5487 to create tunnel for notifications to localhost. 5487 is port of webapp already configured in Docker.
  3. cp ./config.sample.js ./src/config.js. Configure your credentials and host for notifications. Take accessKey and accessSecret from CreatorDev Console (API Keys). host is displayed after starting ngrok in previous step.
  4. Start webapp: docker-compose build && docker-compose up.
  5. Configure Grafana:
    • Login to Grafana: http://localhost:5489/. User: admin, password: admin.
    • Configure Data Source. Password for influxDB is root. alt text.
    • Import dashboard from ./grafana/climate_dashboard.json.
  6. For testing purposes you could start local AwaLWM2M client, which will connect to Device Server. See instructions in prj5HeatingControl_awa_client.sh.

Configuration endpoints:

  • /temperature/name, /presence/name, /heater/name
    • PUT Content-Type: application/json
    • GET Accept: application/json
    • HTTP Body:
      {"name": "NEW_NAME"}
      
  • /temperature/delta
    • PUT Content-Type: application/json
    • GET Accept: application/json
    • HTTP Body:
      {"delta": "DELTA_FLOAT_VALUE"}
      
  • /schedule
    • PUT Content-Type: application/json
    • GET Accept: application/json
    • HTTP Body:
      {"schedule": "SCHEDULE"}
      

Testing with curl

You could test configuration endpoints with following curl commands:

curl -i -X PUT -H "Content-Type: application/json" -d '{"name":"NewTemperatureName"}' http://127.0.0.1:5487/temperature/name
curl -i http://127.0.0.1:5487/temperature/name

curl -i -X PUT -H "Content-Type: application/json" -d '{"name":"NewPresenceName"}' http://127.0.0.1:5487/presence/name
curl -i http://127.0.0.1:5487/presence/name

curl -i -X PUT -H "Content-Type: application/json" -d '{"name":"NewHeaterName"}' http://127.0.0.1:5487/heater/name
curl -i http://127.0.0.1:5487/heater/name

curl -i -X PUT -H "Content-Type: application/json" -d '{"delta":"23.86"}' http://127.0.0.1:5487/temperature/delta
curl -i http://127.0.0.1:5487/temperature/delta

curl -i -X PUT -H "Content-Type: application/json" -d '{"schedule":"some schedule"}' http://127.0.0.1:5487/schedule
curl -i http://127.0.0.1:5487/schedule