Skip to content

Commit

Permalink
repair HVAC Mode display.
Browse files Browse the repository at this point in the history
  • Loading branch information
Garfonso committed Aug 24, 2023
1 parent 3ffa8ca commit d165f4c
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions lib/converters/climate.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const typeDetector = require('iobroker.type-detector');

// ],

//DO NOT set unit_of_measurement attribute for climate entity, otherwise HVAC Modes won't be translated..
//export type HvacMode =
// | "off"
// | "heat"
Expand All @@ -62,7 +63,23 @@ const typeDetector = require('iobroker.type-detector');
// off: 7,

// reports state?
// export type HvacAction = "off" | "heating" | "cooling" | "drying" | "idle";
/*export type HvacAction =
| "off"
| "preheating"
| "heating"
| "cooling"
| "drying"
| "idle"
| "fan";*/
/*const HvacModeToAction = {
off: 'off',
//heat: "preheating"
heat: 'heating',
cool: 'cooling',
dry: 'drying',
//off: "idle",
fan_only: 'fan'
};*/

// Build in presets:
// ECO Device is running an energy-saving mode
Expand All @@ -73,7 +90,6 @@ const typeDetector = require('iobroker.type-detector');
// SLEEP Device is prepared for sleep
// ACTIVITY Device is reacting to activity (e.g. movement sensors)


// Supported Features:
const CLIMATE_SUPPORT_TARGET_TEMPERATURE = 1;
//const CLIMATE_SUPPORT_TARGET_TEMPERATURE_RANGE = 2;
Expand Down Expand Up @@ -219,14 +235,6 @@ function fillClimateEntityFromStates(states, objects, entity, iobType) {
});
}

//displays temperature.
if (states.current_temperature) {
const obj = objects[states.current_temperature];
if (obj && obj.common && obj.common.unit) {
entity.attributes.unit_of_measurement = obj.common.unit;
}
}

//controls hvac_mode which can be 'off' but not 'on', so translate 'on' to heat / cool depending on type.
if (states.state || states.stateRead) {
if (!states.hvac_mode) {
Expand Down Expand Up @@ -489,9 +497,6 @@ function fillClimateEntityFromStates(states, objects, entity, iobType) {
});

if (objects[states.temperature] && objects[states.temperature].common) {
if (!entity.attributes.unit_of_measurement && objects[states.temperature].common.unit) {
entity.attributes.unit_of_measurement = objects[states.temperature].common.unit;
}
entity.attributes.min_temp = objects[states.temperature].common.min || 7;
entity.attributes.max_temp = objects[states.temperature].common.max || 35;
entity.attributes.target_temp_step = objects[states.temperature].common.step || 1;
Expand Down

0 comments on commit d165f4c

Please sign in to comment.