RodBr / miflora-card

A Home Assistant Lovelace card to report MiFlora plant sensors based on the HA Plant Card.
23 stars 32 forks source link

Russian Lang #5

Open aleksandrdobrynin opened 5 years ago

aleksandrdobrynin commented 5 years ago

Please add support Russian language.

Olen commented 4 years ago

Made a small patch that allows you to name the elements as you like:

-- miflora-card.js.orig        2020-03-14 16:14:42.086382421 +0100
+++ miflora-card.js     2020-03-14 17:20:32.828731909 +0100
@@ -67,6 +67,12 @@
         for (var i = 0; i < _sensors.length; i++) {
             var _name = _sensors[i][0];
             var _sensor = _sensors[i][1];
+            if (_sensors[i].length == 3) {
+                var _display_name = _sensors[i][2];
+            }
+            else {
+                var _display_name = _name[0].toUpperCase() + _name.slice(1);
+            }
             var _state = '';
             var _uom = '';
             if (hass.states[_sensor]) {
@@ -103,7 +109,7 @@
             this.shadowRoot.getElementById('sensors').innerHTML += `
                 <div id="sensor${i}" class="sensor">
                     <div class="icon"><ha-icon icon="${_icon}"></ha-icon></div>
-                    <div class="name">${_name}</div>
+                    <div class="name">${_display_name}</div>
                     <div class="state" style="${_alertStyle}">${_alertIcon}${_state}${_uom}</div>
                 </div>

Not in any way the perfect solution but now you can specify whatever name you want in the config by adding a second ":" and a custom name to the "entity"

entities:
  - moisture:sensor.mi_moisture:Moist
  - intensity:sensor.mi_intensity:Light
  - temperature:sensor.mi_temperature
  - conductivity:sensor.mi_conductivity:Fertilizer
Olen commented 4 years ago

I have cleaned this up and created a PR Be aware that this will BREAK current configs as I changed it to a more common format:

entities:
  - entity: sensor.foo
    type: moisture
    name: Custom Name
  - entity: sensor.bar
    type: intensity
    name: Other Name
Nikolay-Ch commented 4 years ago

Russian language is working now... Just create right entities configuration section:

entities:
  - 'Влажность:sensor.miflora_moi_3'
  - 'Освещение:sensor.miflora_lux_3'
  - 'Температура:sensor.miflora_tem_3'
  - 'Плодородие:sensor.miflora_fer_3'