Warning for modification of Categories and Types for Features

Hello the community,

I’m posting this as is, I’ll finish my post after eating.
I would need your opinion on the GIF below before creating a PR. I initially prepared a dev to be able to modify the category/type of the Sonoff which are implemented by default (for the relays) as switches, but for my part, I don’t know about you, I install them on lighting.
By doing so, the modification as I saw it goes a bit further and would require modifying the visibility on all services. I will specify later. Of course, we can do otherwise, hence a request for your opinion ^^ also to avoid wasting time on unnecessary dev.

CategoryTypeFeature in image

I had also thought about being able to modify (only) the category of the device to change a switch to a light. However, the type must not be changed as this would prevent the device from working.
It is therefore necessary to allow the modification of the category that has the same type of feature.

Example: all categories with a type « BINARY ».

I think that’s great for Tasmota yes :slight_smile: After all, it depends on the services. Each service has its own needs, it shouldn’t apply to all services!

To talk about implementation, I advise you to keep a single component to manage the modification of the features, and you just pass it a prop to say « enable category modification ». I do that in a service I don’t remember which one.

You can do it without Tasmota as well, only MQTT has its own editor.

Hello !!

First of all, sorry for the response time, I wanted to finish the development of my proposal before answering. Which is " almost done ^^

Indeed, this is another issue. In the case of BINARY, it is indeed unlikely that it needs to be changed, except for programming errors, which would only occur in integrations where we create the features ourselves. But for the rest, I disagree. We have the choice in the types, to be in decimal or integer for example. Some will want precision to the decimal point, and others will not want to be bothered by it, I think of power for example (in kW the decimal represents hundreds of watts but in Watt, the decimal no longer represents much, except in case of precision measurement) or speed, or temperature, etc. Indeed, today we reference very few units of measurement. But all this will grow. Below, I have added some units and types to the different categories.
Moreover, it is always interesting to be able to modify the units and to be able to reach the largest possible population. Those who have a basic feature °C but who want it in °F or from gram but who want it displayed in ounce. Below, with a warning message, I would like to propose a redesign of the category/type/unit/symbol declaration part. I would therefore like your opinion, especially @pierre-gilles, on my proposal, namely a single and unique variable accessible to retrieve all the data with however a variable for the units as currently but which would contain the name of the unit:

41 Units
const DEVICE_FEATURE_UNITS_NEW = {
  LUXMEN: {
    TITLE: 'luxmen',
    SYMBOL: 'lux',
  },
  CANDELA: {
    TITLE: 'candela',
    SYMBOL: 'cd',
  },
  LUMEN: {
    TITLE: 'lumen',
    SYMBOL: 'lm',
  },
  RVB: {
    TITLE: 'RVB',
    SYMBOL: 'RVB',
  },
  HEXA: {
    TITLE: 'hexa',
    SYMBOL: 'Hex',
  },
  PERCENT: {
    TITLE: 'percent',
    SYMBOL: '%',
  },
  CELSIUS: {
    TITLE: 'celsius',
    SYMBOL: '°C',
  },
  FAHRENHEIT: {
    TITLE: 'fahrenheit',
    SYMBOL: '°F',
  },
  KELVIN: {
    TITLE: 'kelvin',
    SYMBOL: 'K',
  },
  PASCAL: {
    TITLE: 'pascal',
    SYMBOL: 'Pa',
  },
  MILLIBAR: {
    TITLE: 'millibar',
    SYMBOL: 'mbar',
  },
  BAR: {
    TITLE: 'bar',
    SYMBOL: 'bar',
  },
  WATT: {
    TITLE: 'watt',
    SYMBOL: 'W',
  },
  KILOWATT: {
    TITLE: 'kilowatt',
    SYMBOL: 'kW',
  },
  JOULE: {
    TITLE: 'joule',
    SYMBOL: 'J',
  },
  KILOJOULE: {
    TITLE: 'kilojoule',
    SYMBOL: 'kJ',
  },
  WATT_HOUR: {
    TITLE: 'watt-hour',
    SYMBOL: 'Wh',
  },
  KILOWATT_HOUR: {
    TITLE: 'kilowatt-hour',
    SYMBOL: 'kWh',
  },
  MILLIAMPERE: {
    TITLE: 'milliampere',
    SYMBOL: 'mA',
  },
  AMPERE: {
    TITLE: 'ampere',
    SYMBOL: 'A',
  },
  VOLT: {
    TITLE: 'volt',
    SYMBOL: 'V',
  },
  PPM: {
    TITLE: 'ppm',
    SYMBOL: 'ppm',
  },
  MOLE: {
    TITLE: 'mole',
    SYMBOL: 'mol',
  },
  INCH: {
    TITLE: 'inch',
    SYMBOL: 'in',
  },
  FOOT: {
    TITLE: 'foot',
    SYMBOL: 'ft',
  },
  CENTIMETER: {
    TITLE: 'centimeter',
    SYMBOL: 'cm',
  },
  METER: {
    TITLE: 'meter',
    SYMBOL: 'm',
  },
  METER_SECOND: {
    TITLE: 'meter-second',
    SYMBOL: 'm/s',
  },
  FEET_SECOND: {
    TITLE: 'feet-second',
    SYMBOL: 'fps',
  },
  MILES_HOUR: {
    TITLE: 'miles-hour',
    SYMBOL: 'mph',
  },
  KILOMETER_HOUR: {
    TITLE: 'kilometer-hour',
    SYMBOL: 'km/h',
  },
  NAUTICAL_KNOT: {
    TITLE: 'nautical-knot',
    SYMBOL: 'kn',
  },
  US_QUART: {
    TITLE: 'US-quart',
    SYMBOL: 'qt',
  },
  US_GALLON: {
    TITLE: 'US-gallon',
    SYMBOL: 'gal',
  },
  LITRE: {
    TITLE: 'litre',
    SYMBOL: 'L',
  },
  CUBIC_METER: {
    TITLE: 'cubic-meter',
    SYMBOL: 'm3',
  },
  OUNCE: {
    TITLE: 'ounce',
    SYMBOL: 'oz',
  },
  POUND: {
    TITLE: 'pound',
    SYMBOL: 'lbs',
  },
  GRAMME: {
    TITLE: 'gramme',
    SYMBOL: 'g',
  },
  KILOGRAMME: {
    TITLE: 'kilogramme',
    SYMBOL: 'kg',
  },
  UNKNOWN: {
    TITLE: 'no-unit',
    SYMBOL: ' ',
  },
};
Categories_Types_Unit
const DEVICE_FEATURE_CATEGORIES_TYPES_UNITS = {
  LIGHT: {
    TITLE: 'light',
    BINARY: {
      TITLE: 'binary',
      ICON: 'sun',
      UNITS: {},
    },
    BRIGHTNESS: {
      TITLE: 'brightness',
      ICON: 'sun',
      UNITS: {
        LUXMEN: DEVICE_FEATURE_UNITS_NEW.LUXMEN,
        CANDELA: DEVICE_FEATURE_UNITS_NEW.CANDELA,
        LUMEN: DEVICE_FEATURE_UNITS_NEW.LUMEN,
      },
    },
    HUE: {
      TITLE: 'hue',
      ICON: 'sun',
      UNITS: {
        RGB: DEVICE_FEATURE_UNITS_NEW.RGB,
        HEX: DEVICE_FEATURE_UNITS_NEW.HEX,
      },
    },
    SATURATION: {
      TITLE: 'saturation',
      ICON: 'sun',
      UNITS: {
        PERCENT: DEVICE_FEATURE_UNITS_NEW.PERCENT,
      },
    },
    COLOR: {
      TITLE: 'color',
      ICON: 'sun',
      UNITS: {
        RGB: DEVICE_FEATURE_UNITS_NEW.RGB,
        HEX: DEVICE_FEATURE_UNITS_NEW.HEX,
      },
    },
    TEMPERATURE: {
      TITLE: 'temperature',
      ICON: 'sun',
      UNITS: {
        KELVIN: DEVICE_FEATURE_UNITS_NEW.KELVIN,
      },
    },
    POWER: {
      TITLE: 'power',
      ICON: 'zap',
      UNITS: {
        JOULE: DEVICE_FEATURE_UNITS_NEW.JOULE,
        KILOJOULE: DEVICE_FEATURE_UNITS_NEW.KILOJOULE,
        WATT_HOUR: DEVICE_FEATURE_UNITS_NEW.WATT_HOUR,
        WATT: DEVICE_FEATURE_UNITS_NEW.WATT,
      },
    },
    EFFECT_MODE: {
      TITLE: 'effect-mode',
      ICON: 'play',
      UNITS: {},
    },
    EFFECT_SPEED: {
      TITLE: 'effect-speed',
      ICON: 'activity',
      UNITS: {},
    },
  },
  SWITCH: {
    TITLE: 'switch',
    BINARY: {
      TITLE: 'binary',
      ICON: 'power',
      UNITS: {},
    },
    BURGLAR: {
      TITLE: 'burglar',
      ICON: 'users',
      UNITS: {},
    },
    VOLTAGE: {
      TITLE: 'voltage',
      ICON: 'zap',
      UNITS: {
        VOLT: DEVICE_FEATURE_UNITS_NEW.VOLT,
        UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
      },
    },
    CURRENT: {
      TITLE: 'current',
      ICON: 'zap',
      UNITS: {
        MILLIAMPERE: DEVICE_FEATURE_UNITS_NEW.MILLIAMPERE,
        AMPERE: DEVICE_FEATURE_UNITS_NEW.AMPERE,
        UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
      },
    },
    POWER: {
      TITLE: 'power',
      ICON: 'zap',
      UNITS: {
        JOULE: DEVICE_FEATURE_UNITS_NEW.JOULE,
        KILOJOULE: DEVICE_FEATURE_UNITS_NEW.KILOJOULE,
        WATT: DEVICE_FEATURE_UNITS_NEW.WATT,
        KILOWATT: DEVICE_FEATURE_UNITS_NEW.KILOWATT,
        UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
      },
    },
    ENERGY: {
      TITLE: 'energy',
      ICON: 'zap',
      UNITS: {
        JOULE: DEVICE_FEATURE_UNITS_NEW.JOULE,
        KILOJOULE: DEVICE_FEATURE_UNITS_NEW.KILOJOULE,
        WATT_HOUR: DEVICE_FEATURE_UNITS_NEW.WATT_HOUR,
        KILOWATT_HOUR: DEVICE_FEATURE_UNITS_NEW.KILOWATT_HOUR,
        UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
      },
    },
    DIMMER: {
      TITLE: 'dimmer',
      ICON: 'bar-chart-2',
      UNITS: {
        PERCENT: DEVICE_FEATURE_UNITS_NEW.PERCENT,
        UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
      },
    },
    UNKNOWN: {
      TITLE: 'unknown',
      ICON: 'help-circle',
      UNITS: {
        UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
      },
    },
  },
  SIREN: {
    TITLE: 'siren',
    BINARY: {
      TITLE: 'binary',
      ICON: 'bell',
      UNITS: {},
    },
    UNKNOWN: {
      TITLE: 'unknown',
      ICON: 'bell',
      UNITS: {
        UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
      },
    },
  },
  ACCESS_CONTROL: {
    TITLE: 'access-control',
    MODE: {
      TITLE: 'mode',
      ICON: 'lock',
      UNITS: {},
    },
    UNKNOWN: {
      TITLE: 'unknown',
      ICON: 'lock',
      UNITS: {
        UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
      },
    },
  },
  CUBE: {
    TITLE: 'cube',
    MODE: {
      TITLE: 'mode',
      ICON: 'activity',
      UNITS: {},
    },
    ROTATION: {
      TITLE: 'rotation',
      ICON: 'rotate-cw',
      UNITS: {
        UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
      },
    },
    UNKNOWN: {
      TITLE: 'unknown',
      ICON: 'help-circle',
      UNITS: {
        UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
      },
    },
  },
  BUTTON: {
    TITLE: 'button',
    CLICK: {
      TITLE: 'click',
      ICON: 'circle',
      UNITS: {},
    },
    UNKNOWN: {
      TITLE: 'unknown',
      ICON: 'circle',
      UNITS: {
        UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
      },
    },
  },
  BATTERY: {
    TITLE: 'battery',
    INTEGER: {
      TITLE: 'integer',
      ICON: 'battery',
      UNITS: {
        PERCENT: DEVICE_FEATURE_UNITS_NEW.PERCENT,
      },
    },
    DECIMAL: {
      TITLE: 'decimal',
      ICON: 'battery',
      UNITS: {
        PERCENT: DEVICE_FEATURE_UNITS_NEW.PERCENT,
      },
    },
  },
  CAMERA: {
    TITLE: 'camera',
    IMAGE: {
      TITLE: 'image',
      ICON: 'camera',
      UNITS: {},
    },
  },
  // Sensors
  TEMPERATURE_SENSOR: {
    TITLE: 'temperature-sensor',
    BINARY: {
      TITLE: 'binary',
      ICON: 'thermometer',
      UNITS: {},
    },
    DECIMAL: {
      TITLE: 'decimal',
      ICON: 'thermometer',
      UNITS: {
        CELSIUS: DEVICE_FEATURE_UNITS_NEW.CELSIUS,
        FAHRENHEIT: DEVICE_FEATURE_UNITS_NEW.FAHRENHEIT,
        KELVIN: DEVICE_FEATURE_UNITS_NEW.KELVIN,
      },
    },
    INTEGER: {
      TITLE: 'integer',
      ICON: 'thermometer',
      UNITS: {
        CELSIUS: DEVICE_FEATURE_UNITS_NEW.CELSIUS,
        FAHRENHEIT: DEVICE_FEATURE_UNITS_NEW.FAHRENHEIT,
        KELVIN: DEVICE_FEATURE_UNITS_NEW.KELVIN,
      },
    },
    UNKNOWN: {
      TITLE: 'unknown',
      ICON: 'thermometer',
      UNITS: {
        UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
      },
    },
  },
  MOTION_SENSOR: {
    TITLE: 'motion-sensor',
    BINARY: {
      TITLE: 'binary',
      ICON: 'eye',
      UNITS: {},
    },
    PUSH: {
      TITLE: 'push',
      ICON: 'eye',
      UNITS: {},
    },
    UNKNOWN: {
      TITLE: 'unknown',
      ICON: 'eye',
      UNITS: {
        UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
      },
    },
  },
  LIGHT_SENSOR: {
    TITLE: 'light-sensor',
    BINARY: {
      TITLE: 'binary',
      ICON: 'sun',
      UNITS: {},
    },
    DECIMAL: {
      TITLE: 'decimal',
      ICON: 'sun',
      UNITS: {
        LUXMEN: DEVICE_FEATURE_UNITS_NEW.LUXMEN,
        CANDELA: DEVICE_FEATURE_UNITS_NEW.CANDELA,
        LUMEN: DEVICE_FEATURE_UNITS_NEW.LUMEN,
        PERCENT: DEVICE_FEATURE_UNITS_NEW.PERCENT,
      },
    },
    INTEGER: {
      TITLE: 'integer',
      ICON: 'sun',
      UNITS: {
        LUXMEN: DEVICE_FEATURE_UNITS_NEW.LUXMEN,
        CANDELA: DEVICE_FEATURE_UNITS_NEW.CANDELA,
        LUMEN: DEVICE_FEATURE_UNITS_NEW.LUMEN,
        PERCENT: DEVICE_FEATURE_UNITS_NEW.PERCENT,
      },
    },
    UNKNOWN: {
      TITLE: 'unknown',
      ICON: 'sun',
      UNITS: {
        UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
      },
    },
  },
  MASS_SENSOR: {
    TITLE: 'mass-sensor',
    BINARY: {
      TITLE: 'binary',
      ICON: 'trending-up',
      UNITS: {},
    },
    DECIMAL: {
      TITLE: 'decimal',
      ICON: 'trending-up',
      UNITS: {
        OUNCE: DEVICE_FEATURE_UNITS_NEW.OUNCE,
        POUND: DEVICE_FEATURE_UNITS_NEW.POUND,
        GRAM: DEVICE_FEATURE_UNITS_NEW.GRAM,
        KILOGRAM: DEVICE_FEATURE_UNITS_NEW.KILOGRAM,
        US_GALLON: DEVICE_FEATURE_UNITS_NEW.US_GALLON,
        US_QUART: DEVICE_FEATURE_UNITS_NEW.US_QUART,
        LITRE: DEVICE_FEATURE_UNITS_NEW.LITRE,
        CUBIC_METER: DEVICE_FEATURE_UNITS_NEW.CUBIC_METER,
      },
    },
    INTEGER: {
      TITLE: 'integer',
      ICON: 'trending-up',
      UNITS: {
        OUNCE: DEVICE_FEATURE_UNITS_NEW.OUNCE,
        POUND: DEVICE_FEATURE_UNITS_NEW.POUND,
        GRAM: DEVICE_FEATURE_UNITS_NEW.GRAM,
        KILOGRAM: DEVICE_FEATURE_UNITS_NEW.KILOGRAM,
        US_GALLON: DEVICE_FEATURE_UNITS_NEW.US_GALLON,
        US_QUART: DEVICE_FEATURE_UNITS_NEW.US_QUART,
        LITRE: DEVICE_FEATURE_UNITS_NEW.LITRE,
        CUBIC_METER: DEVICE_FEATURE_UNITS_NEW.CUBIC_METER,
      },
    },
    UNKNOWN: {
      TITLE: 'unknown',
      ICON: 'trending-up',
      UNITS: {
        UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
      },
    },

[/details],
},
SPEED_SENSOR: {
TITLE: ‹ speed-sensor ›,
BINARY: {
TITLE: ‹ binary ›,
ICON: ‹ wind ›,
UNITS: {},
},
DECIMAL: {
TITLE: ‹ decimal ›,
ICON: ‹ wind ›,
UNITS: {
FEET_SECOND: DEVICE_FEATURE_UNITS_NEW.FEET_SECOND,
MILES_HOUR: DEVICE_FEATURE_UNITS_NEW.MILES_HOUR,
METER_SECOND: DEVICE_FEATURE_UNITS_NEW.METER_SECOND,
KILOMETER_HOUR: DEVICE_FEATURE_UNITS_NEW.KILOMETER_HOUR,
NAUTICAL_KNOT: DEVICE_FEATURE_UNITS_NEW.NAUTICAL_KNOT,
},
},
INTEGER: {
TITLE: ‹ integer ›,
ICON: ‹ wind ›,
UNITS: {
FEET_SECOND: DEVICE_FEATURE_UNITS_NEW.FEET_SECOND,
MILES_HOUR: DEVICE_FEATURE_UNITS_NEW.MILES_HOUR,
METER_SECOND: DEVICE_FEATURE_UNITS_NEW.METER_SECOND,
KILOMETER_HOUR: DEVICE_FEATURE_UNITS_NEW.KILOMETER_HOUR,
NAUTICAL_KNOT: DEVICE_FEATURE_UNITS_NEW.NAUTICAL_KNOT,
},
},
UNKNOWN: {
TITLE: ‹ unknown ›,
ICON: ‹ wind ›,
UNITS: {
UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
},
},
},
LEVEL_SENSOR: {
TITLE: ‹ level-sensor ›,
BINARY: {
TITLE: ‹ binary ›,
ICON: ‹ list ›,
UNITS: {},
},
DECIMAL: {
TITLE: ‹ decimal ›,
ICON: ‹ list ›,
UNITS: {
INCH: DEVICE_FEATURE_UNITS_NEW.INCH,
FOOT: DEVICE_FEATURE_UNITS_NEW.FOOT,
CENTIMETER: DEVICE_FEATURE_UNITS_NEW.CENTIMETER,
METER: DEVICE_FEATURE_UNITS_NEW.METER,
},
},
INTEGER: {
TITLE: ‹ integer ›,
ICON: ‹ list ›,
UNITS: {
INCH: DEVICE_FEATURE_UNITS_NEW.INCH,
FOOT: DEVICE_FEATURE_UNITS_NEW.FOOT,
CENTIMETER: DEVICE_FEATURE_UNITS_NEW.CENTIMETER,
METER: DEVICE_FEATURE_UNITS_NEW.METER,
},
},
UNKNOWN: {
TITLE: ‹ unknown ›,
ICON: ‹ list ›,
UNITS: {
UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
},
},
},
SMOKE_SENSOR: {
TITLE: ‹ smoke-sensor ›,
BINARY: {
TITLE: ‹ binary ›,
ICON: ‹ wind ›,
UNITS: {},
},
DECIMAL: {
TITLE: ‹ decimal ›,
ICON: ‹ wind ›,
UNITS: {
PERCENT: DEVICE_FEATURE_UNITS_NEW.PERCENT,
UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
},
},
INTEGER: {
TITLE: ‹ integer ›,
ICON: ‹ wind ›,
UNITS: {
PERCENT: DEVICE_FEATURE_UNITS_NEW.PERCENT,
UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
},
},
UNKNOWN: {
TITLE: ‹ unknown ›,
ICON: ‹ wind ›,
UNITS: {
UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
},
},
},
SEISMIC_SENSOR: {
TITLE: ‹ seismic-sensor ›,
BINARY: {
TITLE: ‹ binary ›,
ICON: ‹ activity ›,
UNITS: {},
},
DECIMAL: {
TITLE: ‹ decimal ›,
ICON: ‹ activity ›,
UNITS: {
PERCENT: DEVICE_FEATURE_UNITS_NEW.PERCENT,
UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
},
},
INTEGER: {
TITLE: ‹ integer ›,
ICON: ‹ activity ›,
UNITS: {
PERCENT: DEVICE_FEATURE_UNITS_NEW.PERCENT,
UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
},
},
UNKNOWN: {
TITLE: ‹ unknown ›,
ICON: ‹ activity ›,
UNITS: {
UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
},
},
},
PRESSURE_SENSOR: {
TITLE: ‹ pressure-sensor ›,
BINARY: {
TITLE: ‹ binary ›,
ICON: ‹ cloud ›,
UNITS: {},
},
DECIMAL: {
TITLE: ‹ decimal ›,
ICON: ‹ cloud ›,
UNITS: {
MILLIBAR: DEVICE_FEATURE_UNITS_NEW.MILLIBAR,
BAR: DEVICE_FEATURE_UNITS_NEW.BAR,
PASCAL: DEVICE_FEATURE_UNITS_NEW.PASCAL,
PERCENT: DEVICE_FEATURE_UNITS_NEW.PERCENT,
UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
},
},
INTEGER: {
TITLE: ‹ integer ›,
ICON: ‹ cloud ›,
UNITS: {
MILLIBAR: DEVICE_FEATURE_UNITS_NEW.MILLIBAR,
BAR: DEVICE_FEATURE_UNITS_NEW.BAR,
PASCAL: DEVICE_FEATURE_UNITS_NEW.PASCAL,
PERCENT: DEVICE_FEATURE_UNITS_NEW.PERCENT,
UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
},
},
UNKNOWN: {
TITLE: ‹ unknown ›,
ICON: ‹ cloud ›,
UNITS: {
UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
},
},
},
OPENING_SENSOR: {
TITLE: ‹ opening-sensor ›,
BINARY: {
TITLE: ‹ binary ›,
ICON: ‹ lock ›,
UNITS: {},
},
},
HUMIDITY_SENSOR: {
TITLE: ‹ humidity-sensor ›,
BINARY: {
TITLE: ‹ binary ›,
ICON: ‹ droplet ›,
UNITS: {},
},
DECIMAL: {
TITLE: ‹ decimal ›,
ICON: ‹ droplet ›,
UNITS: {
PERCENT: DEVICE_FEATURE_UNITS_NEW.PERCENT,
UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
},
},
INTEGER: {
TITLE: ‹ integer ›,
ICON: ‹ droplet ›,
UNITS: {
PERCENT: DEVICE_FEATURE_UNITS_NEW.PERCENT,
UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
},
},
UNKNOWN: {
TITLE: ‹ unknown ›,
ICON: ‹ droplet ›,
UNITS: {
UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
},
},
},
VIBRATION_SENSOR: {
TITLE: ‹ vibration-sensor ›,
STATUS: {
TITLE: ‹ status ›,
ICON: ‹ alert-circle ›,
UNITS: {},
},
TILT_ANGLE: {
TITLE: ‹ tilt-angle ›,
ICON: ‹ rotate-cw ›,
UNITS: {},
},
ACCELERATION_X: {
TITLE: ‹ acceleration-x ›,
ICON: ‹ zap ›,
UNITS: {},
},
ACCELERATION_Y: {
TITLE: ‹ acceleration-y ›,
ICON: ‹ zap ›,
UNITS: {},
},
ACCELERATION_Z: {
TITLE: ‹ acceleration-z ›,
ICON: ‹ zap ›,
UNITS: {},
},
BED_ACTIVITY: {
TITLE: ‹ bed-activity ›,
ICON: ‹ moon ›,
UNITS: {},
},
UNKNOWN: {
TITLE: ‹ unknown ›,
ICON: ‹ droplet ›,
UNITS: {
UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
},
},
},
CO2_SENSOR: {
TITLE: ‹ co2-sensor ›,
BINARY: {
TITLE: ‹ binary ›,
ICON: ‹ bar-chart-2 ›,
UNITS: {},
},
DECIMAL: {
TITLE: ‹ decimal ›,
ICON: ‹ bar-chart-2 ›,
UNITS: {
PPM: DEVICE_FEATURE_UNITS_NEW.PPM,
PERCENT: DEVICE_FEATURE_UNITS_NEW.PERCENT,
UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
},
},
INTEGER: {
TITLE: ‹ integer ›,
ICON: ‹ bar-chart-2 ›,
UNITS: {
PPM: DEVICE_FEATURE_UNITS_NEW.PPM,
PERCENT: DEVICE_FEATURE_UNITS_NEW.PERCENT,
UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
},
},
UNKNOWN: {
TITLE: ‹ unknown ›,
ICON: ‹ bar-chart-2 ›,
UNITS: {
UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
},
},
},
COUNTER_SENSOR: {
TITLE: ‹ counter-sensor ›,
BINARY: {
TITLE: ‹ binary ›,
ICON: ‹ plus ›,
UNITS: {},
},
INTEGER: {
TITLE: ‹ integer ›,
ICON: ‹ plus ›,
UNITS: {
UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
},
},
},
LEAK_SENSOR: {
TITLE: ‹ leak-sensor ›,
BINARY: {
TITLE: ‹ binary ›,
ICON: ‹ droplet ›,
UNITS: {},
},
UNKNOWN: {
TITLE: ‹ unknown ›,
ICON: ‹ droplet ›,
UNITS: {
UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
},
},
},
// Other
UNKNOWN: {
TITLE: ‹ unknown ›,
UNKNOWN: {
TITLE: ‹ unknown ›,
ICON: ‹ help-circle ›,
UNITS: {
UNKNOWN: DEVICE_FEATURE_UNITS_NEW.UNKNOWN,
},
},
},
};

And here’s what it looks like so far :slight_smile:
CategoryTypeUnitFeature as an image
I added conversions for devices returning a value, for example in °C, and you would like to see it in °F or vice versa to reach as many people as possible and above all not to have to make modifications on the device outside of Gladys. But it could be for data in watts to be converted to kWh or vice versa, etc. However, I simulated the base value in a props variable, but my vision was that when creating the feature, all the first unit values would be pushed to the t_device_param DB to, on the one hand, be able to return to the original configuration with a single click, and on the other hand to take the starting unit as a reference for subsequent conversions.
Of course, this is certainly something to revisit, but do you like the idea?

I’ll try to present an idea for the barriers/gates quickly.

I agree that we can improve unit management in Gladys 4, but in my opinion, it’s not in this direction that we should do it.

In Gladys 4, here’s how I thought about units/display:

  • The unit of a deviceFeature is only the unit returned by the device, depending on the hardware and what the manufacturer has coded. This is not the display unit. That’s why it is mainly fixed.
  • The display unit depends on the person looking at the dashboard. I don’t know if you remember, but when configuring your Gladys instance, you specified the units you wanted to see:

  • These units are specific to your user account. When we have multi-user in Gladys 4, everyone will be able to specify their unit preferences. If you have multiple users of your Gladys from different nationalities, it’s practical. Everyone can do their config :slight_smile:

  • On display (in the dashboard, or in a message on the chat), each device value is converted to the unit the user requests.

More generally

In Gladys 4, we have the opposite paradigm of v3. We manage everything related to each user’s display preferences on the display side.

The « compatibility » layer (the services) is minimalist: it simply records the data returned by the sensors, raw, that’s all, with the maximum « accuracy » (no conversion, no reduction in precision).

The display side is separate, this is where we will choose exactly which devices we want to display, and depending on the user and their preferences we convert or remove precision, if the user wishes.

After good work on the search for possibilities to improve the units managed, I am 100% for managing more units, but in the other direction :slight_smile: