mirror of
https://github.com/beestat/app.git
synced 2025-05-24 02:14:03 -04:00
Added rudimentary support for legacy monitor and control sensors (temperature only)
This commit is contained in:
parent
06073bfc25
commit
bcb59df01d
@ -35,6 +35,17 @@ class ecobee_sensor extends cora\crud {
|
||||
) === true
|
||||
) {
|
||||
$return[$ecobee_sensor['ecobee_sensor_id']] = $ecobee_sensor;
|
||||
} else if (
|
||||
in_array(
|
||||
$ecobee_sensor['type'],
|
||||
['monitor_sensor', 'control_sensor']
|
||||
) === true
|
||||
) {
|
||||
foreach($ecobee_sensor['capability'] as $capability) {
|
||||
if($capability['type'] === 'temperature') {
|
||||
$return[$ecobee_sensor['ecobee_sensor_id']] = $ecobee_sensor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -755,6 +755,9 @@ class runtime extends cora\api {
|
||||
* has to be accounted for.
|
||||
*
|
||||
* For now I am simply ignoring this situation.
|
||||
*
|
||||
* Update 12/14/2021: At the very least this affects monitor_sensor
|
||||
* and control_sensor. Both are somewhat uncommon.
|
||||
*/
|
||||
if (isset($sensors_by_identifier[$sensor_identifier]) === true) {
|
||||
$sensor = $sensors_by_identifier[$sensor_identifier];
|
||||
@ -779,6 +782,38 @@ class runtime extends cora\api {
|
||||
$datas[$sensor['sensor_id']][$capability['type']] = ($capability['type'] === 'temperature') ? ($value * 10) : $value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If the first attempt to identify the sensor failed, try again.
|
||||
// This is for monitor_sensor and control_sensor.
|
||||
$sensor_identifier = $key;
|
||||
$capability_identifier = '';
|
||||
|
||||
if (isset($sensors_by_identifier[$sensor_identifier]) === true) {
|
||||
$sensor = $sensors_by_identifier[$sensor_identifier];
|
||||
$sensor_id = $sensors_by_identifier[$sensor_identifier]['sensor_id'];
|
||||
|
||||
if (isset($datas[$sensor['sensor_id']]) === false) {
|
||||
$datas[$sensor['sensor_id']] = [
|
||||
'sensor_id' => $sensor['sensor_id'],
|
||||
'timestamp' => get_utc_datetime(
|
||||
$columns['date'] . ' ' . $columns['time'],
|
||||
$thermostat['time_zone']
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
foreach($sensor['capability'] as $capability) {
|
||||
if(
|
||||
$capability['id'] == $capability_identifier &&
|
||||
in_array($capability['type'], ['temperature', 'occupancy']) === true &&
|
||||
$value !== null
|
||||
) {
|
||||
$datas[$sensor['sensor_id']][$capability['type']] = ($capability['type'] === 'temperature') ? ($value * 10) : $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,28 @@ class sensor extends cora\crud {
|
||||
) === true
|
||||
) {
|
||||
$return[$sensor['sensor_id']] = $sensor;
|
||||
} else if (
|
||||
in_array(
|
||||
$sensor['type'],
|
||||
['monitor_sensor', 'control_sensor']
|
||||
) === true
|
||||
) {
|
||||
/**
|
||||
* Support for these sensor types is rudimentary. It's enough to get
|
||||
* temperature but some of these legacy sensors split a single sensor
|
||||
* up into multiple sensors. For example, thermostat temperature,
|
||||
* humidity, and motion are three different sensors. Newer sensors
|
||||
* show up as a single sensor with more than one capability. To make
|
||||
* sense of this I would have to do a good deal of merging etc in the
|
||||
* GUI.
|
||||
*
|
||||
* I don't really think it's worth the clutter or the time investment.
|
||||
*/
|
||||
foreach($sensor['capability'] as $capability) {
|
||||
if($capability['type'] === 'temperature') {
|
||||
$return[$sensor['sensor_id']] = $sensor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,6 +132,11 @@ beestat.component.card.sensors.prototype.decorate_sensor_ = function(parent, sen
|
||||
.render(td_above_below);
|
||||
}
|
||||
|
||||
if (
|
||||
sensor.type !== 'monitor_sensor' &&
|
||||
sensor.type !== 'control_sensor'
|
||||
) {
|
||||
// Occupancy is not supported for these legacy sensor types.
|
||||
if (sensor.occupancy === true) {
|
||||
(new beestat.component.icon('eye', 'Occupied')).render(td_icons);
|
||||
} else {
|
||||
@ -139,6 +144,7 @@ beestat.component.card.sensors.prototype.decorate_sensor_ = function(parent, sen
|
||||
.set_color(beestat.style.color.bluegray.light)
|
||||
.render(td_icons);
|
||||
}
|
||||
}
|
||||
|
||||
td_icons.appendChild($.createElement('span').style({
|
||||
'display': 'inline-block',
|
||||
|
Loading…
x
Reference in New Issue
Block a user