Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions _includes/config_battery_reporting.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<hr>
<div id="battery_reporting_settings">
<label>Battery Reporting</label>
<br>
<div class="alert alert-info" role="alert">
Send battery status updates to a remote HTTP endpoint. The watch will POST battery percentage and charging status to the configured URL.
</div>
<label class="subtle">Remote Endpoint URL</label>
<div class="form-group">
<input type="text" class="form-control" id="remote_endpoint_url" placeholder='https://your-endpoint.com/battery'>
</div>
<label class="subtle">Bearer Token (optional)</label>
<div class="form-group">
<input type="text" class="form-control" id="remote_endpoint_token" placeholder='your-auth-token'>
</div>
<hr>
</div>
1 change: 1 addition & 0 deletions config_aplite.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
{% include config_theme_bw.html %}
{% include config_sidebar_layout_rect.html %}
{% include config_common_options.html %}
{% include config_battery_reporting.html %}
</form>
</div>

Expand Down
1 change: 1 addition & 0 deletions config_basalt.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
{% include config_theme_color.html %}
{% include config_sidebar_layout_rect.html %}
{% include config_common_options.html %}
{% include config_battery_reporting.html %}
</form>
</div>

Expand Down
1 change: 1 addition & 0 deletions config_bw.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
{% include config_theme_bw.html %}
{% include config_sidebar_layout_rect.html %}
{% include config_common_options.html %}
{% include config_battery_reporting.html %}
</form>
</div>

Expand Down
1 change: 1 addition & 0 deletions config_chalk.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
{% include config_theme_color.html %}
{% include config_sidebar_layout_round.html %}
{% include config_common_options.html %}
{% include config_battery_reporting.html %}
</form>
</div>

Expand Down
1 change: 1 addition & 0 deletions config_color.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
{% include config_theme_color.html %}
{% include config_sidebar_layout_rect.html %}
{% include config_common_options.html %}
{% include config_battery_reporting.html %}
</form>
</div>

Expand Down
1 change: 1 addition & 0 deletions config_color_round.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
{% include config_theme_color.html %}
{% include config_sidebar_layout_round.html %}
{% include config_common_options.html %}
{% include config_battery_reporting.html %}
</form>
</div>

Expand Down
1 change: 1 addition & 0 deletions config_diorite.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
{% include config_theme_bw.html %}
{% include config_sidebar_layout_rect.html %}
{% include config_common_options.html %}
{% include config_battery_reporting.html %}
</form>
</div>

Expand Down
1 change: 1 addition & 0 deletions config_emery.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
{% include config_theme_color.html %}
{% include config_sidebar_layout_rect.html %}
{% include config_common_options.html %}
{% include config_battery_reporting.html %}
</form>
</div>

Expand Down
18 changes: 18 additions & 0 deletions js/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ function loadPreviousSettings() {
health_use_restful_sleep: 'no',
decimal_separator: '.',

// battery reporting settings
remote_endpoint_url: '',
remote_endpoint_token: '',

// version key used for migrations
settings_version: CURRENT_SETTINGS_VERSION
};
Expand Down Expand Up @@ -147,6 +151,14 @@ function loadPreviousSettings() {
$('#altclock_offset_hour option[data-setting="' + savedSettings.altclock_offset + '"]').prop('selected', true);
$('#altclock_offset_hour option[data-setting="' + savedSettings.altclock_offset + '"]').prop('selected', true);

// load battery reporting settings
if(savedSettings.remote_endpoint_url) {
$('#remote_endpoint_url').val(savedSettings.remote_endpoint_url);
}
if(savedSettings.remote_endpoint_token) {
$('#remote_endpoint_token').val(savedSettings.remote_endpoint_token);
}

// update the widget settings sections to only show ones that are relevant
showOnlySelectedWidgetSettings();
}
Expand Down Expand Up @@ -182,6 +194,8 @@ $('select').on('change', setFormHasChanges);
$('#weather_loc').on('input', setFormHasChanges);
$('#weather_api_key').on('input', setFormHasChanges);
$('#altclock_name').on('input', setFormHasChanges);
$('#remote_endpoint_url').on('input', setFormHasChanges);
$('#remote_endpoint_token').on('input', setFormHasChanges);

$('#use_large_sidebar_font_setting').on('change', updateSidebarPreview);
$('#battery_meter_setting').on('change', updateSidebarPreview);
Expand Down Expand Up @@ -579,6 +593,10 @@ function sendSettingsToWatch() {
config.altclock_name = $('#altclock_name').val();
config.altclock_offset = $('#altclock_offset_hour option:selected').data('setting');

// battery reporting settings
config.remote_endpoint_url = $('#remote_endpoint_url').val();
config.remote_endpoint_token = $('#remote_endpoint_token').val();

// add the version, in case we need to do more migrations
config.settings_version = CURRENT_SETTINGS_VERSION;

Expand Down