tp1de / ioBroker.ems-esp

EMS-ESP Adapter
MIT License
18 stars 4 forks source link

Native boolean values are converted into numbers which are written as numbers into database (influxdb) #7

Closed harvey637 closed 2 years ago

harvey637 commented 2 years ago

Hi, the bug: some values are booleans in emsep32 (eg. in emsep32 v3.4b17) but displayed as number

versions: ems-esp32: 3.4b17 (boolean format: true/false, enum format: Index) iobroker admin 5.4.9 iobroker ems-esp: 1.12.1 (not km200 formating) iobroker echarts: 1.0.7

this is an iobroker native datapoint for "hpheatingon":

{
  "_id": "ems-esp.0.boiler.hpheatingon",
  "type": "state",
  "common": {
    "id": "boiler.hpheatingon",
    "name": "ems: hp heating",
    "type": "number",
    "read": true,
    "write": false,
    "role": "value",
    "states": {
      "0": "Off",
      "1": "On"
    },
    "min": 0,
    "max": 1
  },
  "native": {
    "ems_type": "boolean",
    "ems_command": "hpheatingon",
    "ems_device": "boiler",
    "ems_id": "",
    "ems_api": "V3"
  },
  "from": "system.adapter.ems-esp.0",
  "user": "system.user.admin",
  "ts": 1652782708358,
  "acl": {
    "object": 1636,
    "state": 1636,
    "owner": "system.user.admin",
    "ownerGroup": "system.group.administrator"
  }
}

The "ems_type: boolean" is converted into a "type: number" with the states "0: Off", "1: On". With this setting the native boolean values are stored as numbers in influxdb and consequently handled as numbers in following applications like echarts.

It is more or less an optical problem, as true/false or On/Off is also handled as 1/0, so lines/steps in echarts are ok. But the reading of a chart with "Heating On: 0" and "Heating On: 1" is less intuitive as "Heating On: TRUE" or "Heating On: FALSE". (Or even better "Heating: On" and "Heating: Off", as all the info is there.

thank you Harvey

tp1de commented 2 years ago

Yes you are right. I did this to have better way of graphical scaleability within flot graphs. So all ems-esp boolean values are converted into numbers with 2 states: 1:On / 0:Off.

Within adapter readme I wrote that boolean format should be set to 1/0 within ems-esp settings.

I am not sure if I should to change this or make this configurable. This logic is active since more then a year. Do you really need this?

tp1de commented 2 years ago

In the ioBroker Object-Browser you will see On / Off anyhow:

image

... and in vis you can select any text you want.

harvey637 commented 2 years ago

Hi, thank you for the quick response!

Hmmmm, no, I dont really need this and I am not shure about the conversion of my history in influxdb.

As said it is a bit of optical enhancement. Normally I prefer to use variables of best fitting type, which is the native boolean. Otherwise in echarts it does not matter, as everything is numbers, as long as it gets to the graph. If you have the last value as part of the legend it gets tricky to use the right words. Also some On/Off automatism might be used in iobroker-vis for booleans.

As you just edited about the suggested boolean format in emsp32: I was the one who requested the separation of the boolean representation to be handled differently in emsp-dashboard an emsp-api :-) (around ~ 3.4b12)

For the optical reason behind this see: Image 005

You see the "open window: TRUE", but "Heizung an: 0". Same problem elseware, as the WINDOWS.STATE is physically boolean, and converted into numbers :-(

Yes, I see the numbers and the states in the objects. I will add a enhancement request into echarts to change the wording "true/false" into something like "open/closed" or the like. No idea of the impact on code there or the interest of the author. But graphs might look better an more readable.

So you can close this request or keep it in mind, thank you for your explanation! cu Harvey

tp1de commented 2 years ago

verstehe ich .... kann natürlich auch boolean in true / false einbauen - per parameter. Soll ich?

harvey637 commented 2 years ago

Moin, vielleicht besser nicht.

Insbesonders kann ich mir nur schwer vorstellen, wie man ein Konzept inkl. sprachvarianten ENUMS (als noch komplexer als booleans) überall umsetzen will, ist halt viel Engagement und selten gewürdigt.

Keep It Small Simple ... widerspricht all zu vielen Parametern, breaking changes und so.

Danke für Dein Ohr cu Harvey

harvey637 commented 2 years ago

Hi, mache ich mal wegen Unbedeutung zu. Soviele andere Baustellen mit ähnlichem Inhalt, manchmal denke ich fast, das ganze boolean nutzt wenig, als 0/1 wäre es einfacher und wird ja auch so gehandhabt. Es sind vielleicht eher Anpassungen an der Ausgabefront (echarts ...), die die Lesbarkeit und Interpretierbarkeit verbessern und nicht ob in der Datenbank 0/1 oder false/true steht. Siehe meine Konterbunt Legende :-) danke und ciao Harvey