Skip to content

Commit

Permalink
Merge branch 'master' into ask-ai-in-scene
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Gilles authored Oct 25, 2024
2 parents 2c1399c + b8ab133 commit f033d05
Show file tree
Hide file tree
Showing 32 changed files with 579 additions and 1,144 deletions.
2 changes: 2 additions & 0 deletions front/src/components/boxs/device-in-room/DeviceRow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import NumberDeviceFeature from './device-features/NumberDeviceFeature';
import CoverDeviceFeature from './device-features/CoverDeviceFeature';
import ThermostatDeviceFeature from './device-features/ThermostatDeviceFeature';
import AirConditioningModeDeviceFeature from './device-features/AirConditioningModeDeviceFeature';
import PilotWireModeDeviceFeature from './device-features/PilotWireModeDeviceFeature';
import LMHVolumeDeviceFeature from './device-features/LMHVolumeDeviceFeature';

const ROW_TYPE_BY_FEATURE_TYPE = {
Expand All @@ -29,6 +30,7 @@ const ROW_TYPE_BY_FEATURE_TYPE = {
[DEVICE_FEATURE_TYPES.THERMOSTAT.TARGET_TEMPERATURE]: ThermostatDeviceFeature,
[DEVICE_FEATURE_TYPES.AIR_CONDITIONING.MODE]: AirConditioningModeDeviceFeature,
[DEVICE_FEATURE_TYPES.AIR_CONDITIONING.TARGET_TEMPERATURE]: ThermostatDeviceFeature,
[DEVICE_FEATURE_TYPES.HEATER.PILOT_WIRE_MODE]: PilotWireModeDeviceFeature,
[DEVICE_FEATURE_TYPES.SIREN.LMH_VOLUME]: LMHVolumeDeviceFeature,
[DEVICE_FEATURE_TYPES.SIREN.MELODY]: NumberDeviceFeature,
[DEVICE_FEATURE_TYPES.DURATION.DECIMAL]: MultiLevelDeviceFeature
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const SUPPORTED_FEATURE_TYPES = [
DEVICE_FEATURE_TYPES.THERMOSTAT.TARGET_TEMPERATURE,
DEVICE_FEATURE_TYPES.AIR_CONDITIONING.MODE,
DEVICE_FEATURE_TYPES.AIR_CONDITIONING.TARGET_TEMPERATURE,
DEVICE_FEATURE_TYPES.HEATER.PILOT_WIRE_MODE,
DEVICE_FEATURE_TYPES.SIREN.LMH_VOLUME,
DEVICE_FEATURE_TYPES.SIREN.MELODY,
DEVICE_FEATURE_TYPES.DURATION.DECIMAL
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import get from 'get-value';
import { Text } from 'preact-i18n';

import { DeviceFeatureCategoriesIcon } from '../../../../utils/consts';
import { PILOT_WIRE_MODE } from '../../../../../../server/utils/constants';

const PilotWireModeDeviceFeature = ({ children, ...props }) => {
const { deviceFeature } = props;
const { category, type } = deviceFeature;

function updateValue(e) {
props.updateValueWithDebounce(deviceFeature, e.currentTarget.value);
}

return (
<tr>
<td>
<i class={`fe fe-${get(DeviceFeatureCategoriesIcon, `${category}.${type}`, { default: 'sliders' })}`} />
</td>
<td>{props.rowName}</td>

<td class="py-0">
<div class="justify-content-end">
<div class="form-group mb-0">
<select value={props.deviceFeature.last_value} onChange={updateValue} class="form-control form-control-sm">
<option value={PILOT_WIRE_MODE.OFF}>
<Text id={`deviceFeatureAction.category.${category}.${type}.off`} />
</option>
<option value={PILOT_WIRE_MODE.FROST_PROTECTION}>
<Text id={`deviceFeatureAction.category.${category}.${type}.frost-protection`} />
</option>
<option value={PILOT_WIRE_MODE.ECO}>
<Text id={`deviceFeatureAction.category.${category}.${type}.eco`} />
</option>
<option value={PILOT_WIRE_MODE.COMFORT_2}>
<Text id={`deviceFeatureAction.category.${category}.${type}.comfort_-2`} />
</option>
<option value={PILOT_WIRE_MODE.COMFORT_1}>
<Text id={`deviceFeatureAction.category.${category}.${type}.comfort_-1`} />
</option>
<option value={PILOT_WIRE_MODE.COMFORT}>
<Text id={`deviceFeatureAction.category.${category}.${type}.comfort`} />
</option>
</select>
</div>
</div>
</td>
</tr>
);
};

export default PilotWireModeDeviceFeature;
14 changes: 14 additions & 0 deletions front/src/config/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2769,6 +2769,16 @@
"heating": "Heizen"
}
},
"heater": {
"pilot-wire-mode": {
"comfort": "Komfort",
"eco": "Öko",
"off": "Aus",
"frost-protection": "Frostschutz",
"comfort_-1": "Komfort -1°C",
"comfort_-2": "Komfort -2°C"
}
},
"siren": {
"lmh_volume": {
"low": "Niedrig",
Expand Down Expand Up @@ -3043,6 +3053,10 @@
"mode": "Modus",
"target-temperature": "Temperatur"
},
"heater": {
"shortCategoryName": "Heizung",
"pilot-wire-mode": "Modus"
},
"tamper": {
"shortCategoryName": "Manipulation",
"binary": "Manipulation (ja/nein)"
Expand Down
14 changes: 14 additions & 0 deletions front/src/config/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2769,6 +2769,16 @@
"heating": "Heat"
}
},
"heater": {
"pilot-wire-mode": {
"comfort": "Comfort",
"eco": "Eco",
"off": "Off",
"frost-protection": "Frost Protection",
"comfort_-1": "Comfort -1°C",
"comfort_-2": "Comfort -2°C"
}
},
"siren": {
"lmh_volume": {
"low": "Low",
Expand Down Expand Up @@ -3043,6 +3053,10 @@
"mode": "Mode",
"target-temperature": "Temperature"
},
"heater": {
"shortCategoryName": "Heating",
"pilot-wire-mode": "Mode"
},
"tamper": {
"shortCategoryName": "Tamper",
"binary": "Tamper (yes/no)"
Expand Down
14 changes: 14 additions & 0 deletions front/src/config/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2769,6 +2769,16 @@
"heating": "Chauffage"
}
},
"heater": {
"pilot-wire-mode": {
"comfort": "Confort",
"eco": "Eco",
"off": "Off",
"frost-protection": "Hors Gel",
"comfort_-1": "Confort -1°C",
"comfort_-2": "Confort -2°C"
}
},
"siren": {
"lmh_volume": {
"low": "Faible",
Expand Down Expand Up @@ -3043,6 +3053,10 @@
"mode": "Mode",
"target-temperature": "Température"
},
"heater": {
"shortCategoryName": "Chauffage",
"pilot-wire-mode": "Mode"
},
"tamper": {
"shortCategoryName": "Détecteur de sabotage",
"binary": "Détection sabotage (Oui/Non)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class TurnOnLight extends Component {
return (
<div>
<div class="row">
<div class="col-sm-4">
<div class="col-sm-6">
<div class="form-group">
<div class="form-label">
<Text id="editScene.triggersCard.scheduledTrigger.typeLabel" />
Expand Down Expand Up @@ -267,7 +267,7 @@ class TurnOnLight extends Component {
</div>
)}
{this.props.trigger.scheduler_type === 'every-week' && (
<div class="col-sm-2">
<div class="col-sm-4">
<div class="form-group">
<div class="form-label">
<Text id="editScene.triggersCard.scheduledTrigger.timeLabel" />
Expand Down
3 changes: 3 additions & 0 deletions front/src/utils/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ export const DeviceFeatureCategoriesIcon = {
[DEVICE_FEATURE_TYPES.AIR_CONDITIONING.MODE]: 'settings',
[DEVICE_FEATURE_TYPES.AIR_CONDITIONING.TARGET_TEMPERATURE]: 'thermometer'
},
[DEVICE_FEATURE_CATEGORIES.HEATER]: {
[DEVICE_FEATURE_TYPES.HEATER.PILOT_WIRE_MODE]: 'thermometer'
},
[DEVICE_FEATURE_CATEGORIES.TELEVISION]: {
[DEVICE_FEATURE_TYPES.TELEVISION.BINARY]: 'power',
[DEVICE_FEATURE_TYPES.TELEVISION.SOURCE]: 'airplay',
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gladys",
"version": "4.46.2",
"version": "4.47.0",
"description": "A privacy-first, open-source home assistant",
"main": "index.js",
"engines": {
Expand Down
4 changes: 3 additions & 1 deletion server/lib/gateway/gateway.restoreBackup.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ async function restoreBackup(sqliteBackupFilePath, duckDbBackupFolderPath) {
await new Promise((resolve) => {
db.duckDb.close(() => resolve());
});
// Delete current DuckDB file
// Delete current DuckDB files
const duckDbFilePath = `${this.config.storage.replace('.db', '')}.duckdb`;
const duckDbWalFilePath = `${this.config.storage.replace('.db', '')}.duckdb.wal`;
await fse.remove(duckDbFilePath);
await fse.remove(duckDbWalFilePath);
const duckDb = new duckdb.Database(duckDbFilePath);
const duckDbWriteConnection = duckDb.connect();
const duckDbWriteConnectionAllAsync = promisify(duckDbWriteConnection.all).bind(duckDbWriteConnection);
Expand Down
2 changes: 1 addition & 1 deletion server/lib/scene/scene.checkCalendarTriggers.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dayjs.extend(LocalizedFormat);
async function checkCalendarTriggers() {
// getting a fixed value for now, as soon as possible in the function
const now = dayjs.tz(dayjs(), this.timezone);
logger.info(`Checking calendar triggers at ${now}`);
logger.debug(`Checking calendar triggers at ${now}`);
// First, we try to constitute a list of triggers
// related to calendars events
const calendarEventTriggers = [];
Expand Down
14 changes: 7 additions & 7 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"cross-env": "^7.0.3",
"dayjs": "^1.11.6",
"dockerode": "^3.3.4",
"duckdb": "^1.0.0",
"duckdb": "^1.1.1",
"express": "^4.18.2",
"express-rate-limit": "^6.7.0",
"form-data": "^2.3.3",
Expand Down
28 changes: 26 additions & 2 deletions server/services/homekit/lib/buildAccessory.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,32 @@ function buildAccessory(device) {

const accessory = new this.hap.Accessory(device.name, device.id);
Object.keys(categories).forEach((category) => {
const service = this.buildService(device, categories[category], mappings[category]);
accessory.addService(service);
const serviceConfigs = [];

categories[category].forEach((cat) => {
if (
serviceConfigs.length > 0 &&
!serviceConfigs[serviceConfigs.length - 1].find(
(config) => config.category === cat.category && config.type === cat.type,
)
) {
serviceConfigs[serviceConfigs.length - 1].push(cat);

return;
}

serviceConfigs.push([cat]);
});

serviceConfigs.forEach((config, i) => {
const service = this.buildService(
device,
config,
mappings[category],
serviceConfigs.length > 1 ? `${category} ${i + 1}` : undefined,
);
accessory.addService(service);
});
});

return accessory.services.length <= 1 ? null : accessory;
Expand Down
17 changes: 7 additions & 10 deletions server/services/homekit/lib/buildService.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ const sleep = promisify(setTimeout);
* @param {object} device - Gladys device to format as HomeKit accessory.
* @param {object} features - Device features to associate to service.
* @param {object} categoryMapping - Homekit mapping for the current device category.
* @param {string} subtype - Optional subtype if multiple same service.
* @returns {object} HomeKit service to expose.
* @example
* buildService(device, features, categoryMapping)
*/
function buildService(device, features, categoryMapping) {
function buildService(device, features, categoryMapping, subtype) {
const { Characteristic, CharacteristicEventTypes, Perms, Service } = this.hap;

const service = new Service[categoryMapping.service](device.name);
const service = new Service[categoryMapping.service](subtype ? features[0].name : device.name, subtype);

features.forEach((feature) => {
switch (`${feature.category}:${feature.type}`) {
Expand All @@ -51,8 +52,7 @@ function buildService(device, features, categoryMapping) {
status: ACTIONS_STATUS.PENDING,
value: value ? 1 : 0,
device: device.selector,
feature_category: feature.category,
feature_type: feature.type,
device_feature: feature.selector,
};
this.gladys.event.emit(EVENTS.ACTION.TRIGGERED, action);
callback();
Expand Down Expand Up @@ -107,8 +107,7 @@ function buildService(device, features, categoryMapping) {
),
),
device: device.selector,
feature_category: feature.category,
feature_type: feature.type,
device_feature: feature.selector,
};
this.gladys.event.emit(EVENTS.ACTION.TRIGGERED, action);
callback();
Expand Down Expand Up @@ -136,8 +135,7 @@ function buildService(device, features, categoryMapping) {
status: ACTIONS_STATUS.PENDING,
value: rgbToInt(rgb),
device: device.selector,
feature_category: feature.category,
feature_type: feature.type,
device_feature: feature.selector,
};
this.gladys.event.emit(EVENTS.ACTION.TRIGGERED, action);
callback();
Expand All @@ -161,8 +159,7 @@ function buildService(device, features, categoryMapping) {
status: ACTIONS_STATUS.PENDING,
value: rgbToInt(rgb),
device: device.selector,
feature_category: feature.category,
feature_type: feature.type,
device_feature: feature.selector,
};
this.gladys.event.emit(EVENTS.ACTION.TRIGGERED, action);
callback();
Expand Down
Loading

0 comments on commit f033d05

Please sign in to comment.