-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #233 from Garfonso/dev
v2.0.1 & dependency updates
- Loading branch information
Showing
27 changed files
with
8,550 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -468,6 +468,20 @@ After that checkout modified version in `./build` folder. Then. | |
PLACEHOLDER for next version: | ||
### **WORK IN PROGRESS** | ||
--> | ||
### **WORK IN PROGRESS** | ||
* (Garfonso) Add support for fan entity (makes fan card working). | ||
* (Garfonso) fix backwards compatibility for input_datetime attributes. | ||
* (Garfonso) fix airconditioner with power mode on mode update | ||
|
||
### 2.0.3 (2021-07-04) | ||
* (Garfonso) fix typo. | ||
|
||
### 2.0.2 (2021-07-04) | ||
* (Garfonso) fixed: Date shift for weather forecast without date state. | ||
|
||
### 2.0.1 (2021-07-01) | ||
* (Garfonso) fixed: Zigbee lights (issue 222). | ||
|
||
### 2.0.0 (2021-06-17) | ||
* (Garfonso) Changed: !Breaking! Battery warning is now binary_sensor instead of sensor (now ui sets icon and translates ok) | ||
* (Garfonso) Fixed: !Breaking! entity_id conflict for low_bat / humidity when part of another device | ||
|
@@ -495,15 +509,6 @@ After that checkout modified version in `./build` folder. Then. | |
* (Garfonso) Fixed: default themes do not show as selected | ||
* (Garfonso) Fixed: Loading themes / custom cards / image-proxy | ||
|
||
### 1.4.3 (2021-02-01) | ||
* (bluefox) Support of lovelace via ioBroker.pro | ||
|
||
### 1.4.2 (2021-01-08) | ||
* (thost96) Fixed: set Theme state type to string instead of text | ||
|
||
### 1.4.1 (2021-01-08) | ||
* (bluefox) Support of new Let's Encrypt (only with js-controller 3.2.x) | ||
|
||
## License | ||
|
||
Copyright 2019-2021, bluefox <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
const utils = require('./utils'); | ||
const adapterData = require('./../dataSingleton'); | ||
|
||
async function fillEntityFromStates(states, objects, entity) { | ||
//'old' fan: | ||
// "modes": { | ||
// "0": "off", | ||
// "1": "low", | ||
// "2": "medium", | ||
// "3": "high" | ||
// } | ||
// -> use either states or this as default. | ||
// 'new' fan: | ||
// preset_mode instead of speed. Can support more modes... | ||
// preset_mode -> will call set_preset_mode. | ||
// support both, we don't care. | ||
|
||
|
||
utils.fillEntityFromStates(states, entity); //already prefills attributes. | ||
|
||
//preset_mode is important: | ||
if (states.preset_mode) { | ||
const attr = entity.context.ATTRIBUTES.find(a => a.attribute === 'preset_mode'); | ||
|
||
const obj = objects[states.preset_mode] || {common: {type: 'number'}}; | ||
if (!obj.common) { | ||
obj.common = {type: 'number', states: {'0': 'off', '1': 'low', '2': 'medium', '3': 'high'}}; | ||
} | ||
if (!obj.common.type) { | ||
obj.common.type = 'number'; | ||
} | ||
if (!obj.common.states) { | ||
obj.common.states = {'0': 'off', '1': 'low', '2': 'medium', '3': 'high'}; | ||
} | ||
|
||
if (obj.common.states) { | ||
if (obj.common.states instanceof Array) { | ||
attr.isStringArray = true; | ||
entity.attributes.preset_modes = obj.common.states; | ||
} else { | ||
if (typeof obj.common.states === 'string') { | ||
adapterData.log.warn(obj._id + ': states is of type string. Problems might occur. Please fix states to be of type object.'); | ||
attr.map2lovelace = {}; | ||
for (const kv of obj.common.states.split(';')) { | ||
const [key, value] = kv.split(':'); | ||
attr.map2lovelace[key] = value; | ||
} | ||
} else { | ||
attr.map2lovelace = obj.common.states; | ||
} | ||
attr.isNumber = obj.common.type && obj.common.type.toLowerCase() === 'number'; | ||
attr.map2iob = {}; | ||
entity.attributes.preset_modes = []; | ||
Object.keys(attr.map2lovelace).forEach(k => { | ||
attr.map2iob[attr.map2lovelace[k]] = k; | ||
entity.attributes.preset_modes.push(attr.map2lovelace[k]); | ||
}); | ||
} | ||
} | ||
|
||
attr.getParser = (entity, attr, state) => { | ||
state = state || {val: null}; | ||
entity.attributes.speed = state.val || 'unknown'; | ||
if (attr.map2lovelace) { | ||
entity.attributes.speed = attr.map2lovelace[state.val] || state.val || 'unknown'; | ||
} | ||
entity.attributes.preset_mode = entity.attributes.speed; | ||
entity.state = entity.attributes.speed !== 'off' ? 'on' : 'off'; | ||
}; | ||
|
||
if (!entity.context.COMMANDS) { | ||
entity.context.COMMANDS = []; | ||
} | ||
const parseCommand = async (entity, command, data, user) => { | ||
let target = data.service_data.speed || data.service_data.preset_mode; | ||
if (!attr.isStringArray) { | ||
if (attr.map2iob) { | ||
target = attr.map2iob[target]; | ||
} | ||
if (attr.isNumber) { | ||
target = Number(target); | ||
} | ||
} | ||
if (!target && target !== 0) { | ||
target = data.service_data.speed || data.service_data.preset_mode; //fallback | ||
} | ||
|
||
return adapterData.adapter.setForeignStateAsync(command.setId, target, false, {user}); | ||
}; | ||
|
||
entity.context.COMMANDS.push({ | ||
service: 'set_speed', | ||
setId: states.preset_mode, | ||
parseCommand | ||
}); | ||
entity.context.COMMANDS.push({ | ||
service: 'set_preset_mode', | ||
setId: states.preset_mode, | ||
parseCommand | ||
}); | ||
entity.context.COMMANDS.push({ | ||
service: 'turn_off', | ||
setId: states.preset_mode, | ||
parseCommand: async (entity, command, data, user) => { | ||
await parseCommand(entity, command, {service_data: {preset_mode: 'off'}}, user); | ||
if (states.state) { | ||
await adapterData.adapter.setForeignStateAsync(states.state, false, false, {user}); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
return [entity]; | ||
} | ||
|
||
/** | ||
* Create manual input_select entity. | ||
* @param id - id of "main" object, i.e. state. | ||
* @param obj - iobroker object of id param | ||
* @param entity - already created entity | ||
* @param objects - id object cache | ||
* @param custom - custom part of object | ||
* @returns {Promise<[entity]>} | ||
*/ | ||
exports.processManualEntity = async function(id, obj, entity, objects, custom) { | ||
const states = custom.states || { | ||
preset_mode: id | ||
}; | ||
if (!states.preset_mode) { | ||
states.speed = states.speed || id; | ||
} | ||
delete states.speed; //want only one attribute. | ||
|
||
|
||
return fillEntityFromStates(states, objects, entity); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.