You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The error message "Cannot read property 'thermostatMode' of undefined" indicates that the thermostatMode property is being accessed on an undefined object. This suggests that snapshotVal.TemperatureSetting is undefined.
To resolve this , you should first ensure that the TemperatureSetting property exists within your Firebase data structure for the specified deviceId. If it does not exist, you need to handle this case gracefully in your code.
You can modify the queryFirebase function to check if snapshotVal.TemperatureSetting exists before accessing its properties.
i try to using ac_unit with trait like this
app.onSync((body) => {
return {
requestId: body.requestId,
payload: {
agentUserId: USER_ID,
devices: [{
id: '123',
type: 'action.devices.types.AC_UNIT',
traits: [
'action.devices.traits.FanSpeed',
'action.devices.traits.OnOff',
'action.devices.traits.TemperatureSetting',
],
name: {
defaultNames: ['Air Condition'],
name: 'Air Condition',
nicknames: ['Air Condition'],
},
deviceInfo: {
manufacturer: 'smart-home-inc',
model: 'hs1234',
hwVersion: '3.2',
swVersion: '11.4',
},
willReportState: true,
attributes: {
availableThermostatModes: [
'off',
'heat',
'on',
],
thermostatTemperatureRange: {
minThresholdCelsius: 15,
maxThresholdCelsius: 30,
},
pausable: true,
availableFanSpeeds: {
speeds: [{
speed_name: 'speed_low',
speed_values: [{
speed_synonym: ['low'],
lang: 'en',
}],
},
{
speed_name: 'speed_medium',
speed_values: [
{
speed_synonym: ['medium'],
lang: 'en',
},
],
},
{
speed_name: 'speed_high',
speed_values: [
{
speed_synonym: ['high'],
lang: 'en',
},
],
},
],
ordered: true,
},
commandOnlyFanSpeed: true,
supportsFanSpeedPercent: true,
queryOnlyTemperatureSetting: true,
thermostatTemperatureUnit: 'C',
},
}],
},
};
});
const queryFirebase = async (deviceId) => {
const snapshot = await firebaseRef.child(deviceId).once('value');
const snapshotVal = snapshot.val();
return {
on: snapshotVal.OnOff.on,
currentFanSpeedSetting: snapshotVal.FanSpeed.currentFanSpeedSetting,
currentFanSpeedPercent: snapshotVal.FanSpeed.currentFanSpeedPercent,
thermostatMode: snapshotVal.TemperatureSetting.thermostatMode,
};
};
when i running it, its return this error message at firebase
TypeError: Cannot read property 'thermostatMode' of undefined
please help me
The text was updated successfully, but these errors were encountered: