diff --git a/app/templates/site_help.html b/app/templates/site_help.html
index f63ce793..d603eb1d 100644
--- a/app/templates/site_help.html
+++ b/app/templates/site_help.html
@@ -106,6 +106,13 @@
Other logs
+
+Other troubleshooting tools
+
+
+ Troubleshoot Tilt/Bluetooth Support
+
+
{% endblock %}
{% block scripts %}{% endblock %}
diff --git a/docs/source/develop/changelog.rst b/docs/source/develop/changelog.rst
index 04068bd2..f9b7c3a8 100644
--- a/docs/source/develop/changelog.rst
+++ b/docs/source/develop/changelog.rst
@@ -17,6 +17,7 @@ Added
- Store the exact last time that a message was received from a Tilt to Redis
- Add sentry support to tilt_monitor_aio.py
- Added "debug" scripts for bluetooth Tilt connections
+- Added TiltBridge connection settings to Tilt management page
diff --git a/gravity/templates/gravity/gravity_manage_tilt.html b/gravity/templates/gravity/gravity_manage_tilt.html
index f0f4a2f1..fe16da81 100644
--- a/gravity/templates/gravity/gravity_manage_tilt.html
+++ b/gravity/templates/gravity/gravity_manage_tilt.html
@@ -26,7 +26,9 @@ Configuration Options
Connection Type |
- {{ active_device.tilt_configuration.connection_type }} |
+
+ {% if active_device.tilt_configuration.connection_type == "Bridge" %}TiltBridge{% elif active_device.tilt_configuration.connection_type == "Bluetooth" %}Bluetooth{% else %}Unknown{% endif %}
+ |
Smoothing Window (Readings) |
@@ -151,6 +153,31 @@ Troubleshoot Tilt Connection
{% endif %}
+ {% if active_device.tilt_configuration.connection_type == "Bridge" %}
+ TiltBridge Configuration
+
+
+ In order for your TiltBridge to communicate with Fermentrack, it needs to be told where Fermentrack can be
+ reached on your network. If the mDNS ID specified above is correct, this can be done automatically by
+ Fermentrack, or you can set this manually on the TiltBridge's configuration page.
+
+
+
+
+
+
+ Fermentrack URL (copy to TiltBridge) |
+ {{ fermentrack_url }} |
+
+
+
+
+
+
+ Update TiltBridge Automatically
+
+ {% endif %}
+
diff --git a/gravity/templates/gravity/gravity_tilt_test.html b/gravity/templates/gravity/gravity_tilt_test.html
index 433aca3a..1b815858 100644
--- a/gravity/templates/gravity/gravity_tilt_test.html
+++ b/gravity/templates/gravity/gravity_tilt_test.html
@@ -24,10 +24,12 @@
Several system packages are missing.
{% endif %}{# has_apt_packages #}
-
- Package Name |
- OK? |
-
+
+
+ Package Name |
+ OK? |
+
+
{% for test_result in apt_test_results %}
@@ -86,12 +88,14 @@ Several python packages are missing.
-
- Package Name |
- Required Version |
- Installed Version |
- OK? |
-
+
+
+ Package Name |
+ Required Version |
+ Installed Version |
+ OK? |
+
+
{% for test_result in python_test_results %}
diff --git a/gravity/urls.py b/gravity/urls.py
index d76b4a7b..8ec600f0 100644
--- a/gravity/urls.py
+++ b/gravity/urls.py
@@ -63,6 +63,8 @@
# TiltBridge specific views
url(r'^gravity/tiltbridge/add/$', gravity.views_tilt.gravity_tiltbridge_add, name='gravity_tiltbridge_add'),
+ url(r'^gravity/tiltbridge/update/(?P[A-Za-z0-9]{1,20})/set_url/$', gravity.views_tilt.gravity_tiltbridge_set_url, name='gravity_tiltbridge_set_url'),
+ url(r'^gravity/tiltbridge/update/(?P[A-Za-z0-9]{1,20})/set_url/(?P[A-Za-z0-9]{1,20})$', gravity.views_tilt.gravity_tiltbridge_set_url, name='gravity_tiltbridge_set_url'),
url(r'^gravity/tiltbridge/urlerror/(?P[A-Za-z0-9]+)/$', gravity.views_tilt.gravity_tiltbridge_urlerror, name='gravity_tiltbridge_urlerror'),
]
diff --git a/gravity/views.py b/gravity/views.py
index 0fbd5557..9f44fef5 100644
--- a/gravity/views.py
+++ b/gravity/views.py
@@ -15,7 +15,7 @@
from app.decorators import site_is_configured, login_if_required_for_dashboard, gravity_support_enabled
-import os, subprocess, datetime, pytz, json, logging, sys
+import os, subprocess, datetime, pytz, json, logging, sys, socket
import gravity.forms as forms
@@ -533,6 +533,24 @@ def gravity_manage(request, sensor_id):
tilt_calibration_form = forms.TiltGravityCalibrationPointForm(initial={'sensor': sensor.tilt_configuration})
context['tilt_calibration_form'] = tilt_calibration_form
+ if sensor.tilt_configuration.connection_type == TiltConfiguration.CONNECTION_BRIDGE:
+ # For TiltBridges, we want to give the user the info necessary to configure the device to communicate with
+ # Fermentrack
+ fermentrack_host = request.META['HTTP_HOST']
+ try:
+ if ":" in fermentrack_host:
+ fermentrack_host = fermentrack_host[:fermentrack_host.find(":")]
+ ais = socket.getaddrinfo(fermentrack_host, 0, 0, 0, 0)
+ ip_list = [result[-1][0] for result in ais]
+ ip_list = list(set(ip_list))
+ resolved_address = ip_list[0]
+ fermentrack_url = "http://{}/tiltbridge/".format(resolved_address)
+ except:
+ # For some reason we failed to resolve the IP address of Fermentrack
+ fermentrack_url = ""
+ context['fermentrack_url'] = fermentrack_url
+
+
return render(request, template_name='gravity/gravity_manage_tilt.html', context=context)
else:
return render(request, template_name='gravity/gravity_manage.html', context=context)
diff --git a/gravity/views_tilt.py b/gravity/views_tilt.py
index 56471daa..6720c2ff 100644
--- a/gravity/views_tilt.py
+++ b/gravity/views_tilt.py
@@ -458,6 +458,37 @@ def gravity_tiltbridge_add(request):
return render(request, template_name='gravity/gravity_tiltbridge_add.html',
context={'form': form, 'available_devices': available_devices,})
+@login_required
+@site_is_configured
+def gravity_tiltbridge_set_url(request, tiltbridge_id, sensor_id=None):
+ # TODO - Add user permissioning
+ # if not request.user.has_perm('app.edit_device'):
+ # messages.error(request, 'Your account is not permissioned to edit devices. Please contact an admin')
+ # return redirect("/")
+
+ try:
+ this_tiltbridge = TiltBridge.objects.get(mdns_id=tiltbridge_id)
+ except ObjectDoesNotExist:
+ messages.error(request, "Unable to locate TiltBridge with mDNS ID {}".format(tiltbridge_id))
+ if sensor_id is not None:
+ return redirect("gravity_manage", sensor_id=sensor_id)
+ else:
+ return redirect("siteroot")
+
+
+ fermentrack_host = request.META['HTTP_HOST']
+
+ if this_tiltbridge.update_fermentrack_url_on_tiltbridge(fermentrack_host):
+ messages.success(request, u"Updated Fermentrack URL on TiltBridge '{}'".format(this_tiltbridge.name))
+ else:
+ messages.error(request, u"Unable to automatically update Fermentrack URL at {}.local".format(this_tiltbridge.mdns_id))
+
+ # If we were passed a sensor ID, we want to return to the management screen for that ID.
+ if sensor_id is not None:
+ return redirect("gravity_manage", sensor_id=sensor_id)
+ else:
+ return redirect("siteroot")
+
@login_required
@site_is_configured