From 0e8175b38d6b25c661cdb11eb2f4e6bece56cb67 Mon Sep 17 00:00:00 2001 From: Matus Ivanecky Date: Sun, 7 Jul 2019 02:28:43 +0200 Subject: [PATCH] Update input-number-controller.js Hello Thomas, I would like to use unit_of_measurements also for input_number. I would do it this way, if you confortable with this. Later we could refactor also other controllers which are taking it from config, not from entity attributes and combine both approaches. What is your opinion for it ? --- src/input-number-controller.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/input-number-controller.js b/src/input-number-controller.js index cd5005b..9cd065b 100644 --- a/src/input-number-controller.js +++ b/src/input-number-controller.js @@ -14,7 +14,10 @@ export class InputNumberController extends Controller { } get string() { - return `${parseFloat(this.stateObj.state)}`; + if (typeof this.stateObj.attributes.unit_of_measurement === "undefined") { + this.stateObj.attributes.unit_of_measurement = ""; + } + return `${parseFloat(this.stateObj.state)} ${this.stateObj.attributes.unit_of_measurement}`; } get isOff() {