mirror of
https://github.com/beestat/app.git
synced 2025-07-09 03:04:07 -04:00
Updated heat map type to support °C
This commit is contained in:
parent
cde2ac1d29
commit
97c65a95b9
@ -5,6 +5,8 @@
|
|||||||
*
|
*
|
||||||
* @param {object} args Instructions on how to format:
|
* @param {object} args Instructions on how to format:
|
||||||
* temperature (required) - Temperature to work with
|
* temperature (required) - Temperature to work with
|
||||||
|
* input_temperature_unit (optional, default °F) - Input temperature unit
|
||||||
|
* output_temperature_unit (optional, default °F|°C) - Input temperature unit; default matches setting.
|
||||||
* convert (optional, default true) - Whether or not to convert to Celcius if necessary
|
* convert (optional, default true) - Whether or not to convert to Celcius if necessary
|
||||||
* delta (optional, default false) - Whether or not the convert action is for a delta instead of a normal value
|
* delta (optional, default false) - Whether or not the convert action is for a delta instead of a normal value
|
||||||
* round (optional, default 1) - Number of decimal points to round to
|
* round (optional, default 1) - Number of decimal points to round to
|
||||||
@ -21,7 +23,14 @@ beestat.temperature = function(args) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var convert = beestat.default_value(args.convert, true);
|
var input_temperature_unit = beestat.default_value(
|
||||||
|
args.input_temperature_unit,
|
||||||
|
'°F'
|
||||||
|
);
|
||||||
|
var output_temperature_unit = beestat.default_value(
|
||||||
|
args.output_temperature_unit,
|
||||||
|
beestat.setting('temperature_unit')
|
||||||
|
);
|
||||||
var delta = beestat.default_value(args.delta, false);
|
var delta = beestat.default_value(args.delta, false);
|
||||||
var round = beestat.default_value(args.round, 1);
|
var round = beestat.default_value(args.round, 1);
|
||||||
var units = beestat.default_value(args.units, false);
|
var units = beestat.default_value(args.units, false);
|
||||||
@ -35,12 +44,20 @@ beestat.temperature = function(args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert to Celcius if necessary and asked for.
|
// Convert to Celcius if necessary and asked for.
|
||||||
if (convert === true && beestat.setting('temperature_unit') === '°C') {
|
if (input_temperature_unit !== output_temperature_unit) {
|
||||||
|
if (input_temperature_unit === '°F') {
|
||||||
if (delta === true) {
|
if (delta === true) {
|
||||||
temperature *= (5 / 9);
|
temperature *= (5 / 9);
|
||||||
} else {
|
} else {
|
||||||
temperature = (temperature - 32) * (5 / 9);
|
temperature = (temperature - 32) * (5 / 9);
|
||||||
}
|
}
|
||||||
|
} else if (input_temperature_unit === '°C') {
|
||||||
|
if (delta === true) {
|
||||||
|
temperature *= (9 / 5);
|
||||||
|
} else {
|
||||||
|
temperature = (temperature * (9 / 5)) + 32;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -62,7 +79,7 @@ beestat.temperature = function(args) {
|
|||||||
|
|
||||||
// Append units if asked for.
|
// Append units if asked for.
|
||||||
if (units === true) {
|
if (units === true) {
|
||||||
temperature += beestat.setting('temperature_unit');
|
temperature += output_temperature_unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
return temperature;
|
return temperature;
|
||||||
|
@ -103,7 +103,6 @@ beestat.component.card.three_d.prototype.decorate_contents_ = function(parent) {
|
|||||||
parent.appendChild(controls_container);
|
parent.appendChild(controls_container);
|
||||||
this.decorate_controls_(controls_container);
|
this.decorate_controls_(controls_container);
|
||||||
|
|
||||||
|
|
||||||
// var thermostat = beestat.cache.thermostat[this.thermostat_id_];
|
// var thermostat = beestat.cache.thermostat[this.thermostat_id_];
|
||||||
|
|
||||||
let required_begin;
|
let required_begin;
|
||||||
|
@ -150,21 +150,65 @@ beestat.component.card.visualize_settings.prototype.decorate_heat_map_type_ = fu
|
|||||||
parent.appendChild(min_max_container);
|
parent.appendChild(min_max_container);
|
||||||
|
|
||||||
const min = new beestat.component.input.text()
|
const min = new beestat.component.input.text()
|
||||||
.set_value(beestat.setting(
|
.set_maxlength('5')
|
||||||
'visualize.heat_map_absolute.' + beestat.setting('visualize.data_type') + '.min')
|
.set_requirements({
|
||||||
|
'type': 'decimal',
|
||||||
|
'required': true
|
||||||
|
})
|
||||||
|
.set_value(
|
||||||
|
beestat.temperature(beestat.setting(
|
||||||
|
'visualize.heat_map_absolute.' + beestat.setting('visualize.data_type') + '.min'
|
||||||
|
))
|
||||||
)
|
)
|
||||||
.set_width(50);
|
.set_width(50);
|
||||||
min.addEventListener('change', function() {
|
min.addEventListener('change', function() {
|
||||||
beestat.setting('visualize.heat_map_absolute.' + beestat.setting('visualize.data_type') + '.min', min.get_value());
|
if (min.meets_requirements() === true) {
|
||||||
|
beestat.setting(
|
||||||
|
'visualize.heat_map_absolute.' + beestat.setting('visualize.data_type') + '.min',
|
||||||
|
beestat.temperature({
|
||||||
|
'temperature': min.get_value(),
|
||||||
|
'input_temperature_unit': beestat.setting('temperature_unit'),
|
||||||
|
'output_temperature_unit': '°F'
|
||||||
|
})
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
min.set_value(
|
||||||
|
beestat.temperature(beestat.setting(
|
||||||
|
'visualize.heat_map_absolute.' + beestat.setting('visualize.data_type') + '.min'
|
||||||
|
))
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const max = new beestat.component.input.text()
|
const max = new beestat.component.input.text()
|
||||||
.set_value(beestat.setting(
|
.set_maxlength('5')
|
||||||
'visualize.heat_map_absolute.' + beestat.setting('visualize.data_type') + '.max')
|
.set_requirements({
|
||||||
|
'type': 'decimal',
|
||||||
|
'required': true
|
||||||
|
})
|
||||||
|
.set_value(
|
||||||
|
beestat.temperature(beestat.setting(
|
||||||
|
'visualize.heat_map_absolute.' + beestat.setting('visualize.data_type') + '.max'
|
||||||
|
))
|
||||||
)
|
)
|
||||||
.set_width(50);
|
.set_width(50);
|
||||||
max.addEventListener('change', function() {
|
max.addEventListener('change', function() {
|
||||||
beestat.setting('visualize.heat_map_absolute.' + beestat.setting('visualize.data_type') + '.max', max.get_value());
|
if (max.meets_requirements() === true) {
|
||||||
|
beestat.setting(
|
||||||
|
'visualize.heat_map_absolute.' + beestat.setting('visualize.data_type') + '.max',
|
||||||
|
beestat.temperature({
|
||||||
|
'temperature': max.get_value(),
|
||||||
|
'input_temperature_unit': beestat.setting('temperature_unit'),
|
||||||
|
'output_temperature_unit': '°F'
|
||||||
|
})
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
max.set_value(
|
||||||
|
beestat.temperature(beestat.setting(
|
||||||
|
'visualize.heat_map_absolute.' + beestat.setting('visualize.data_type') + '.max'
|
||||||
|
))
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let span;
|
let span;
|
||||||
|
@ -230,7 +230,7 @@ beestat.component.chart.runtime_sensor_detail_temperature.prototype.get_options_
|
|||||||
} else {
|
} else {
|
||||||
value = beestat.temperature({
|
value = beestat.temperature({
|
||||||
'temperature': point.value,
|
'temperature': point.value,
|
||||||
'convert': false,
|
'input_temperature_unit': beestat.setting('temperature_unit'),
|
||||||
'units': true
|
'units': true
|
||||||
});
|
});
|
||||||
point_value = point.value;
|
point_value = point.value;
|
||||||
|
@ -288,7 +288,7 @@ beestat.component.chart.runtime_thermostat_detail_temperature.prototype.get_opti
|
|||||||
|
|
||||||
value = beestat.temperature({
|
value = beestat.temperature({
|
||||||
'temperature': value,
|
'temperature': value,
|
||||||
'convert': false,
|
'input_temperature_unit': beestat.setting('temperature_unit'),
|
||||||
'units': true
|
'units': true
|
||||||
});
|
});
|
||||||
} else if (point.series_code.includes('humidity') === true) {
|
} else if (point.series_code.includes('humidity') === true) {
|
||||||
|
@ -234,14 +234,14 @@ beestat.component.chart.runtime_thermostat_summary.prototype.get_options_tooltip
|
|||||||
) {
|
) {
|
||||||
value = beestat.temperature({
|
value = beestat.temperature({
|
||||||
'temperature': values.min_outdoor_temperature,
|
'temperature': values.min_outdoor_temperature,
|
||||||
'convert': false,
|
'input_temperature_unit': beestat.setting('temperature_unit'),
|
||||||
'units': true,
|
'units': true,
|
||||||
'round': 0
|
'round': 0
|
||||||
});
|
});
|
||||||
value += ' to ';
|
value += ' to ';
|
||||||
value += beestat.temperature({
|
value += beestat.temperature({
|
||||||
'temperature': values.max_outdoor_temperature,
|
'temperature': values.max_outdoor_temperature,
|
||||||
'convert': false,
|
'input_temperature_unit': beestat.setting('temperature_unit'),
|
||||||
'units': true,
|
'units': true,
|
||||||
'round': 0
|
'round': 0
|
||||||
});
|
});
|
||||||
@ -252,7 +252,7 @@ beestat.component.chart.runtime_thermostat_summary.prototype.get_options_tooltip
|
|||||||
color = point.series.color;
|
color = point.series.color;
|
||||||
value = beestat.temperature({
|
value = beestat.temperature({
|
||||||
'temperature': values.avg_outdoor_temperature,
|
'temperature': values.avg_outdoor_temperature,
|
||||||
'convert': false,
|
'input_temperature_unit': beestat.setting('temperature_unit'),
|
||||||
'units': true,
|
'units': true,
|
||||||
'round': 0
|
'round': 0
|
||||||
});
|
});
|
||||||
|
@ -296,7 +296,7 @@ beestat.component.chart.temperature_profiles.prototype.get_options_tooltip_forma
|
|||||||
var value = beestat.temperature({
|
var value = beestat.temperature({
|
||||||
'temperature': point.y,
|
'temperature': point.y,
|
||||||
'units': true,
|
'units': true,
|
||||||
'convert': false,
|
'input_temperature_unit': beestat.setting('temperature_unit'),
|
||||||
'delta': true,
|
'delta': true,
|
||||||
'type': 'string'
|
'type': 'string'
|
||||||
}) + ' / h';
|
}) + ' / h';
|
||||||
@ -321,7 +321,7 @@ beestat.component.chart.temperature_profiles.prototype.get_options_tooltip_forma
|
|||||||
'temperature': this.x,
|
'temperature': this.x,
|
||||||
'round': 0,
|
'round': 0,
|
||||||
'units': true,
|
'units': true,
|
||||||
'convert': false
|
'input_temperature_unit': beestat.setting('temperature_unit')
|
||||||
}),
|
}),
|
||||||
sections
|
sections
|
||||||
);
|
);
|
||||||
@ -380,7 +380,7 @@ beestat.component.chart.temperature_profiles.prototype.get_options_xAxis_ = func
|
|||||||
'useHTML': true,
|
'useHTML': true,
|
||||||
'text': 'Now: ' + beestat.temperature({
|
'text': 'Now: ' + beestat.temperature({
|
||||||
'temperature': this.data_.metadata.chart.outdoor_temperature,
|
'temperature': this.data_.metadata.chart.outdoor_temperature,
|
||||||
'convert': false,
|
'input_temperature_unit': beestat.setting('temperature_unit'),
|
||||||
'units': true,
|
'units': true,
|
||||||
'round': 0
|
'round': 0
|
||||||
})
|
})
|
||||||
|
@ -79,6 +79,9 @@ beestat.component.input.prototype.meets_requirements = function() {
|
|||||||
case 'integer':
|
case 'integer':
|
||||||
this.requirements_.regexp = /^-?\d+$/;
|
this.requirements_.regexp = /^-?\d+$/;
|
||||||
break;
|
break;
|
||||||
|
case 'decimal':
|
||||||
|
this.requirements_.regexp = /^-?\d+(?:\.\d+)?$/;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user