summaryrefslogtreecommitdiff
path: root/api.py
blob: 11abd44e4cd9897d8ce3c1503c627f80037d1bb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from __main__ import app
from __main__ import boiler


@app.route("/api/info")
def api_info():
    msg = """
    <link rel="stylesheet" type="text/css" href="/static/style.css">
    <pre>
    You can access data with the api. There are multiple api routes to
    get data. They are all in the format of [ip address]/api/[data]
    
    [ip] is used for the device ip address

    [ip]/api/current_temperautre
        returns the current actual temperature
    [ip]/api/target_temperature
        returns the current target temperature
    [ip]/api/on
    [ip]/api/heating_on
        returns True if the heating is off and False if it is off
    </pre>
    """
    return msg


@app.route("/api/current_temperature")
def api_current_temperature():
    return str(boiler.temperature)


@app.route("/api/target_temperature")
def api_target_temperature():
    return str(boiler.target)


@app.route("/api/on")
@app.route("/api/heating_on")
def api_on():
    return str(boiler.on)