Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
energy
bmon
Commits
a93f06d2
Commit
a93f06d2
authored
Nov 02, 2016
by
Alan Mitchell
Browse files
Skeleton of Ecobee Authorization done.
parent
d4e971b2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
3 deletions
+38
-3
bmsapp/templates/bmsapp/ecobee_auth.html
bmsapp/templates/bmsapp/ecobee_auth.html
+4
-2
bmsapp/templates/bmsapp/ecobee_auth_result.html
bmsapp/templates/bmsapp/ecobee_auth_result.html
+17
-0
bmsapp/urls.py
bmsapp/urls.py
+1
-0
bmsapp/views.py
bmsapp/views.py
+16
-1
No files found.
bmsapp/templates/bmsapp/ecobee_auth.html
View file @
a93f06d2
...
...
@@ -2,6 +2,8 @@
{% block pagetitle %}Ecobee Authorization{% endblock %}
{% block this_nav_link %}{% endblock %}
{% block title %}Ecobee Thermostat Authorization{% endblock %}
{% block content %}
...
...
@@ -19,11 +21,11 @@ the following 4 character PIN in your account:</p>
<h2>
Step 2: Click the following Button after Completing Step 1
</h2>
<form
style=
"text-align:center"
>
<form
method=
"post"
style=
"text-align:center"
>
{% csrf_token %}
<input
type=
"hidden"
name=
"auth_code"
value=
"{{ auth_code }}"
>
<input
type=
"hidden"
name=
"ecobee_PIN"
value=
"{{ ecobee_PIN }}"
>
<input
type=
"submit"
value=
"Click after Completing Step 1"
>
<input
type=
"submit"
value=
"Click after Completing Step 1"
style=
"font-size:20px"
>
</form>
...
...
bmsapp/templates/bmsapp/ecobee_auth_result.html
0 → 100644
View file @
a93f06d2
{% extends "bmsapp/base.html" %}
{% block pagetitle %}Ecobee Access Tokens{% endblock %}
{% block title %}Ecobee Thermostat Access Tokens{% endblock %}
{% block content %}
<p>
Copy and Paste the text below into the Script Parameters input for your
Ecobee Periodic Script:
</p>
<textarea
style=
"font-size:15px"
rows=
"3"
cols=
"50"
>
access_token: {{ access_token }}
refresh_token: {{ refresh_token }}
</textarea>
{% endblock %}
bmsapp/urls.py
View file @
a93f06d2
...
...
@@ -21,6 +21,7 @@ urlpatterns = [
url
(
r
'^map_json/$'
,
views
.
map_json
,
name
=
'map-json'
),
url
(
r
'^training/video/(\w+)/(\d+)/(\d+)/$'
,
views
.
show_video
,
name
=
'show-video'
),
url
(
r
'^make_store_key/$'
,
views
.
make_store_key
),
url
(
r
'^ecobee_auth/$'
,
views
.
ecobee_auth
),
# catches URLs that don't match the above patterns. Assumes they give a template name to render.
url
(
r
'^(\w+)/$'
,
views
.
wildcard
,
name
=
'wildcard'
),
...
...
bmsapp/views.py
View file @
a93f06d2
...
...
@@ -2,7 +2,7 @@
import
sys
,
logging
,
json
,
random
,
time
from
django.http
import
HttpResponse
from
django.shortcuts
import
render_to_response
,
redirect
from
django.shortcuts
import
render_to_response
,
redirect
,
render
from
django.contrib.auth.decorators
import
login_required
from
django.views.decorators.csrf
import
csrf_exempt
from
django.core.urlresolvers
import
reverse
...
...
@@ -297,6 +297,21 @@ def map_json(request):
return
HttpResponse
(
json
.
dumps
(
ret
),
content_type
=
"application/json"
)
def
ecobee_auth
(
request
):
"""Used to generated a form so that a System Admin can obtain access keys
for reading data from the Ecobee thermostat server.
"""
ctx
=
base_context
()
if
request
.
method
==
'GET'
:
ctx
.
update
({
'ecobee_PIN'
:
'Xy12'
,
'auth_code'
:
'ABcd132435@#45xaui'
})
return
render
(
request
,
'bmsapp/ecobee_auth.html'
,
ctx
)
elif
request
.
method
==
'POST'
:
req
=
request
.
POST
.
dict
()
ctx
.
update
({
'access_token'
:
'XYZ123abc'
,
'refresh_token'
:
'123abcDEF'
})
return
render_to_response
(
'bmsapp/ecobee_auth_result.html'
,
ctx
)
def
wildcard
(
request
,
template_name
):
'''
Used if a URL component doesn't match any of the predefied URL patterns. Renders
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment