Skip to content

Commit

Permalink
Merge pull request #605 from PiotrMachowski/dev
Browse files Browse the repository at this point in the history
v2.2.1
  • Loading branch information
PiotrMachowski authored Jun 4, 2023
2 parents 0719cd3 + 965cf8c commit d610bf0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xiaomi-vacuum-map-card",
"version": "v2.2.0",
"version": "v2.2.1",
"description": "Xiaomi Vacuum Map Card",
"keywords": [
"home-assistant",
Expand Down
8 changes: 6 additions & 2 deletions src/components/tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,19 @@ export class Tile extends RootlessLitElement {
stateObject?: HassEntity,
) {
let value: ReplacedKey = "";
const unit = this.getUnit();
const processNumber = this.config.multiplier !== undefined || this.config.precision !== undefined;
if (this.config.entity && stateObject) {
if (processNumber) {
value = this.config.attribute
? stateObject.attributes[this.config.attribute]
: stateObject.state;
} else {
value = localizeEntity(this.hass, this.config as EntityConfig, this.hass.states[this.config.entity]);
value = localizeEntity(this.hass, this.config as EntityConfig, stateObject);
const originalUnit = stateObject.attributes.unit_of_measurement;
if (unit !== "" && originalUnit && value.endsWith(originalUnit)) {
value = value.substring(0, value.length - originalUnit.length).trimEnd();
}
}
} else if (this.config.internal_variable && this.config.internal_variable in this.internalVariables) {
value = this.internalVariables[this.config.internal_variable];
Expand All @@ -116,7 +121,6 @@ export class Tile extends RootlessLitElement {
if (`${value}`.toLowerCase() in translations) {
value = translations[`${value}`.toLowerCase()];
}
const unit = this.getUnit();
return `${value}${unit}`;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"coordinates_to_meters_divider": -1,
"repeats_type": "NONE",
"service_call_schema": {
"service": "xiaomi_miio.vacuum_clean_zone",
"service": "vacuum.send_command",
"service_data": {
"entity_id": "[[entity_id]]",
"command": "custom_area",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
"name": "map_mode.vacuum_clean_segment",
"icon": "mdi:floor-plan",
"selection_type": "ROOM",
"repeats_type": "REPEAT",
"repeats_type": "EXTERNAL",
"max_repeats": 3,
"service_call_schema": {
"service": "roborock.vacuum_clean_segment",
"service_data": {
"segments": "[[selection]]",
"entity_id": "[[entity_id]]"
"entity_id": "[[entity_id]]",
"repeats": "[[repeats]]"
}
}
},
Expand Down

0 comments on commit d610bf0

Please sign in to comment.