atrovato / Gladys

A privacy-first, open-source home assistant
https://gladysassistant.com
Apache License 2.0
0 stars 0 forks source link

Device feature display name #54

Closed atrovato closed 1 year ago

atrovato commented 2 years ago

Pull Request check-list

To ensure your Pull Request can be accepted as fast as possible, make sure to review and check all of these items:

NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.

Description of change

Please provide a description of the change here. It's always best with screenshots, so don't hesitate to add some!

@VonOx can you try this with Lixee TIC device?

codecov[bot] commented 2 years ago

Codecov Report

Merging #54 (b49f824) into master (3ec8d33) will increase coverage by 0.02%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #54      +/-   ##
==========================================
+ Coverage   96.74%   96.76%   +0.02%     
==========================================
  Files         649      650       +1     
  Lines        9388     9455      +67     
==========================================
+ Hits         9082     9149      +67     
  Misses        306      306              
Impacted Files Coverage Δ
...erver/services/tasmota/lib/features/temperature.js 100.00% <ø> (ø)
server/lib/device/device.destroy.js 100.00% <100.00%> (ø)
server/lib/device/device.newStateEvent.js 81.81% <100.00%> (+4.04%) :arrow_up:
server/lib/device/device.saveHistoricalState.js 100.00% <100.00%> (ø)
server/services/zigbee2mqtt/exposes/enumType.js 100.00% <100.00%> (ø)
...rver/services/zigbee2mqtt/lib/handleMqttMessage.js 100.00% <100.00%> (ø)
server/services/zigbee2mqtt/lib/setValue.js 100.00% <100.00%> (ø)
...erver/services/zigbee2mqtt/utils/convertFeature.js 100.00% <100.00%> (ø)
...rvices/zigbee2mqtt/utils/features/buildFeatures.js 100.00% <100.00%> (ø)
...ices/zigbee2mqtt/utils/features/completeFeature.js 100.00% <100.00%> (ø)
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

VonOx commented 2 years ago

@atrovato seems its not working, no change on my boxs

image

I've patched my container and rebuild the front ( not sure if necessary )

atrovato commented 2 years ago

@VonOx can you send me the Gladys device in json ? The one you retreive from the API, with the browser network debug mode. Thank you.

VonOx commented 2 years ago

Sure

{
  "id": "104f95d5-e664-4613-862d-bc4effe7fd35",
  "house_id": "b41ab838-d72b-4d29-9448-0b82c8f0f412",
  "name": "linky",
  "selector": "linky",
  "created_at": "2022-05-04T12:33:23.596Z",
  "updated_at": "2022-05-04T12:33:23.596Z",
  "devices": [
    {
      "name": "Lixee TIC",
      "selector": "lixee-tic",
      "features": [
        {
          "name": "Index",
          "selector": "zigbee2mqtt-lixee-tic-energy-sensor-index-current-index-tarif",
          "category": "energy-sensor",
          "type": "index",
          "read_only": true,
          "unit": null,
          "min": 0,
          "max": 10000,
          "last_value": 2,
          "last_value_changed": "2022-07-20T11:38:17.776Z"
        },
        {
          "name": "Power",
          "selector": "zigbee2mqtt-lixee-tic-energy-sensor-power-apparent-power",
          "category": "energy-sensor",
          "type": "power",
          "read_only": true,
          "unit": "volt-ampere",
          "min": 0,
          "max": 10000,
          "last_value": 324,
          "last_value_changed": "2022-07-20T11:38:17.776Z"
        },
        {
          "name": "Index",
          "selector": "zigbee2mqtt-lixee-tic-energy-sensor-index-current-summ-delivered",
          "category": "energy-sensor",
          "type": "index",
          "read_only": true,
          "unit": "kilowatt-hour",
          "min": 0,
          "max": 1000000,
          "last_value": 29293,
          "last_value_changed": "2022-07-20T11:38:17.776Z"
        },
        {
          "name": "Index",
          "selector": "zigbee2mqtt-lixee-tic-energy-sensor-index-current-tier1-summ-delivered",
          "category": "energy-sensor",
          "type": "index",
          "read_only": true,
          "unit": "kilowatt-hour",
          "min": 0,
          "max": 1000000,
          "last_value": 12468,
          "last_value_changed": "2022-07-20T11:38:17.776Z"
        },
        {
          "name": "Index",
          "selector": "zigbee2mqtt-lixee-tic-energy-sensor-index-current-tier2-summ-delivered",
          "category": "energy-sensor",
          "type": "index",
          "read_only": true,
          "unit": "kilowatt-hour",
          "min": 0,
          "max": 1000000,
          "last_value": 16825,
          "last_value_changed": "2022-07-20T11:38:17.777Z"
        },
        {
          "name": "Index",
          "selector": "zigbee2mqtt-lixee-tic-energy-sensor-index-active-enerfy-out-d01",
          "category": "energy-sensor",
          "type": "index",
          "read_only": true,
          "unit": "kilowatt-hour",
          "min": 0,
          "max": 1000000,
          "last_value": 8387,
          "last_value_changed": "2022-07-20T11:38:17.775Z"
        },
        {
          "name": "Index",
          "selector": "zigbee2mqtt-lixee-tic-energy-sensor-index-active-enerfy-out-d02",
          "category": "energy-sensor",
          "type": "index",
          "read_only": true,
          "unit": "kilowatt-hour",
          "min": 0,
          "max": 1000000,
          "last_value": 10819,
          "last_value_changed": "2022-07-20T11:38:17.775Z"
        },
        {
          "name": "Current",
          "selector": "zigbee2mqtt-lixee-tic-energy-sensor-current-rms-current",
          "category": "energy-sensor",
          "type": "current",
          "read_only": true,
          "unit": "ampere",
          "min": 0,
          "max": 10000,
          "last_value": 1,
          "last_value_changed": "2022-07-20T11:38:17.777Z"
        },
        {
          "name": "Voltage",
          "selector": "zigbee2mqtt-lixee-tic-energy-sensor-voltage-rms-voltage",
          "category": "energy-sensor",
          "type": "voltage",
          "read_only": true,
          "unit": "volt",
          "min": 0,
          "max": 10000,
          "last_value": 233,
          "last_value_changed": "2022-07-20T11:38:17.777Z"
        },
        {
          "name": "Current",
          "selector": "zigbee2mqtt-lixee-tic-energy-sensor-current-available-power",
          "category": "energy-sensor",
          "type": "current",
          "read_only": true,
          "unit": "kilovolt-ampere",
          "min": 0,
          "max": 10000,
          "last_value": 6,
          "last_value_changed": "2022-07-20T11:38:17.776Z"
        },
        {
          "name": "Current",
          "selector": "zigbee2mqtt-lixee-tic-energy-sensor-current-power-threshold",
          "category": "energy-sensor",
          "type": "current",
          "read_only": true,
          "unit": "kilovolt-ampere",
          "min": 0,
          "max": 10000,
          "last_value": 6,
          "last_value_changed": "2022-07-20T11:38:17.777Z"
        },
        {
          "name": "Power",
          "selector": "zigbee2mqtt-lixee-tic-energy-sensor-power-active-power",
          "category": "energy-sensor",
          "type": "power",
          "read_only": true,
          "unit": "watt",
          "min": 0,
          "max": 10000,
          "last_value": 398,
          "last_value_changed": "2022-07-20T11:38:17.775Z"
        },
        {
          "name": "Power",
          "selector": "zigbee2mqtt-lixee-tic-energy-sensor-power-active-power-ph-b",
          "category": "energy-sensor",
          "type": "power",
          "read_only": true,
          "unit": "watt",
          "min": 0,
          "max": 10000,
          "last_value": 394,
          "last_value_changed": "2022-07-20T11:38:17.776Z"
        },
        {
          "name": "Voltage",
          "selector": "zigbee2mqtt-lixee-tic-energy-sensor-voltage-average-rms-voltage-meas-period",
          "category": "energy-sensor",
          "type": "voltage",
          "read_only": true,
          "unit": "volt",
          "min": 0,
          "max": 10000,
          "last_value": 231,
          "last_value_changed": "2022-07-20T11:38:17.776Z"
        },
        {
          "name": "Power",
          "selector": "zigbee2mqtt-lixee-tic-energy-sensor-power-active-power-max",
          "category": "energy-sensor",
          "type": "power",
          "read_only": true,
          "unit": "volt-ampere",
          "min": 0,
          "max": 10000,
          "last_value": 3090,
          "last_value_changed": "2022-07-20T11:38:17.776Z"
        },
        {
          "name": "Power",
          "selector": "zigbee2mqtt-lixee-tic-energy-sensor-power-drawn-v-a-max-n1",
          "category": "energy-sensor",
          "type": "power",
          "read_only": true,
          "unit": "volt-ampere",
          "min": 0,
          "max": 10000,
          "last_value": 2940,
          "last_value_changed": "2022-07-20T11:38:17.777Z"
        },
        {
          "name": "Switch",
          "selector": "zigbee2mqtt-lixee-tic-energy-sensor-binary-relais",
          "category": "energy-sensor",
          "type": "binary",
          "read_only": true,
          "unit": null,
          "min": 0,
          "max": 10000,
          "last_value": 1,
          "last_value_changed": "2022-07-20T11:38:17.777Z"
        }
      ],
      "service": {
        "name": "zigbee2mqtt"
      }
    }
  ]
}
atrovato commented 2 years ago

@VonOx Ok this is not enough, do you have to z2m mqtt payload too? Every features is called Index or Power... don't you overwrite it manually?

VonOx commented 2 years ago

Yes but every time I update the device in Gladys all customized features are overrided ( I'm a little bit bored for now)

atrovato commented 2 years ago

I'm fixing the update device keeping name.. incoming soon. Here the purpose of this PR is to display the feature name if there is multiple "equivalent" features (same category and type). But if you override the feature name qith the same name on each, you won't be able to differenciate them. Do you have to original z2m payload? (to try on my side from real situation).

VonOx commented 2 years ago

Yes I will ASAP ( not at home for now)

Thank you Alex

In my previous comment feature is unedited.

VonOx commented 2 years ago

Here the payload

{
  "active_enerfy_out_d01": 8459,
  "active_enerfy_out_d02": 10819,
  "active_enerfy_out_d03": 4081,
  "active_enerfy_out_d04": 5549,
  "active_power": 670,
  "active_power_max": 1870,
  "active_power_ph_b": 1486,
  "apparent_power": 388,
  "available_power": 6,
  "average_rms_voltage_meas_period": 233,
  "current_date": "E220524164514",
  "current_index_tarif": 2,
  "current_price": "HEURE PLEINE",
  "current_summ_delivered": 29948,
  "current_tarif": "H PLEINE/CREUSE",
  "current_tier10_summ_delivered": 0,
  "current_tier1_summ_delivered": 12765,
  "current_tier2_summ_delivered": 17182,
  "current_tier3_summ_delivered": 0,
  "current_tier4_summ_delivered": 0,
  "current_tier5_summ_delivered": 0,
  "current_tier6_summ_delivered": 0,
  "current_tier7_summ_delivered": 0,
  "current_tier8_summ_delivered": 0,
  "current_tier9_summ_delivered": 0,
  "device": {
    "applicationVersion": 4,
    "dateCode": "20220217",
    "friendlyName": "Lixee TIC",
    "hardwareVersion": 1,
    "ieeeAddr": "0x00158d0005d29aa0",
    "manufacturerID": 4151,
    "manufacturerName": "LiXee",
    "model": "ZLinky_TIC",
    "networkAddress": 32871,
    "powerSource": "Mains (single phase)",
    "softwareBuildID": "4000-0005",
    "stackVersion": 2,
    "type": "Router",
    "zclVersion": 3
  },
  "drawn_v_a_max_n1": 2940,
  "last_seen": "2022-09-08T10:02:32+00:00",
  "linkquality": 66,
  "message1": "PAS DE MESSAGE",
  "message2": "",
  "meter_serial_number": "XXXXXXXXXXXX",
  "power_threshold": 6,
  "relais": 1,
  "rms_current": 2,
  "rms_voltage": 235,
  "site_id": "XXXXXXXXXXXX",
  "software_revision": 2,
  "status_register": "003A4401",
  "update": {
    "state": "available"
  },
  "update_available": false
}
atrovato commented 2 years ago

@VonOx is that the payload from zigbee2mqtt/bridge/devices mqtt topic? I want to reproduce the device creation in Gladys, to see why you have "index" every where.

VonOx commented 2 years ago

My mqtt client cannot handle json length but Z2M provide a state json files to download. Hope it's helping. image

{
    "devices": {
        "0x00158d0005d29aa0": {
            "date_code": "20220217",
            "definition": {
                "description": "Lixee ZLinky",
                "exposes": [
                    {
                        "access": 1,
                        "description": "Current tariff index number",
                        "name": "NTARF",
                        "property": "current_index_tarif",
                        "type": "numeric"
                    },
                    {
                        "access": 1,
                        "description": "Total active power delivered",
                        "name": "EAST",
                        "property": "current_summ_delivered",
                        "type": "numeric",
                        "unit": "kWh"
                    },
                    {
                        "access": 1,
                        "description": "Total provider active power delivered (index 01)",
                        "name": "EASF01",
                        "property": "current_tier1_summ_delivered",
                        "type": "numeric",
                        "unit": "kWh"
                    },
                    {
                        "access": 1,
                        "description": "Total provider active power delivered (index 02)",
                        "name": "EASF02",
                        "property": "current_tier2_summ_delivered",
                        "type": "numeric",
                        "unit": "kWh"
                    },
                    {
                        "access": 1,
                        "description": "Immediate apparent power delivered",
                        "name": "SINSTS",
                        "property": "apparent_power",
                        "type": "numeric",
                        "unit": "VA"
                    },
                    {
                        "access": 1,
                        "description": "Link quality (signal strength)",
                        "name": "linkquality",
                        "property": "linkquality",
                        "type": "numeric",
                        "unit": "lqi",
                        "value_max": 255,
                        "value_min": 0
                    }
                ],
                "model": "ZLinky_TIC",
                "options": [
                    {
                        "access": 2,
                        "description": "This device does not support reporting electric measurements so it is polled instead. The default poll interval is 60 seconds, set to -1 to disable.",
                        "name": "measurement_poll_interval",
                        "property": "measurement_poll_interval",
                        "type": "numeric",
                        "value_min": -1
                    },
                    {
                        "access": 2,
                        "description": "Counter with TIC in mode standard or historique. May require restart (default: auto)",
                        "name": "linky_mode",
                        "property": "linky_mode",
                        "type": "enum",
                        "values": [
                            "auto",
                            "historique",
                            "standard"
                        ]
                    },
                    {
                        "access": 2,
                        "description": "Power with single or three phase. May require restart (default: auto)",
                        "name": "energy_phase",
                        "property": "energy_phase",
                        "type": "enum",
                        "values": [
                            "auto",
                            "single_phase",
                            "three_phase"
                        ]
                    },
                    {
                        "access": 2,
                        "description": "If you produce energy back to the grid (works ONLY when linky_mode: standard, default: auto)",
                        "name": "production",
                        "property": "production",
                        "type": "enum",
                        "values": [
                            "auto",
                            "true",
                            "false"
                        ]
                    },
                    {
                        "access": 2,
                        "description": "Overrides the automatic current tarif. This option will exclude unnecesary attributes. Open a issue to support more of them. Default: auto",
                        "name": "tarif",
                        "property": "tarif",
                        "type": "enum",
                        "values": [
                            "Historique - BASE",
                            "Historique - HCHP",
                            "Historique - EJP",
                            "Historique - BBR",
                            "Standard - Sem WE Mercredi",
                            "Standard - BASE",
                            "Standard - Heure Pleine Heure Creuse",
                            "auto"
                        ]
                    },
                    {
                        "access": 2,
                        "description": "Number of digits after decimal point for kWh, takes into effect on next report of device.",
                        "name": "kWh_precision",
                        "property": "kWh_precision",
                        "type": "numeric",
                        "value_max": 3,
                        "value_min": 0
                    },
                    {
                        "access": 2,
                        "description": "During the poll, request multiple exposes to the Zlinky at once for reducing Zigbee network overload. Too much request at once could exceed device limit. Requieres Z2M restart. Default: 1",
                        "name": "measurement_poll_chunk",
                        "property": "measurement_poll_chunk",
                        "type": "numeric",
                        "value_min": 1
                    },
                    {
                        "access": 2,
                        "description": "List of TIC commands to be exposed (separated by comma). Reconfigure device after change. Default: all",
                        "name": "tic_command_whitelist",
                        "property": "tic_command_whitelist",
                        "type": "text"
                    }
                ],
                "supports_ota": true,
                "vendor": "LiXee"
            },
            "endpoints": {
                "1": {
                    "bindings": [
                        {
                            "cluster": "haElectricalMeasurement",
                            "target": {
                                "endpoint": 1,
                                "ieee_address": "0x00124b0021b95104",
                                "type": "endpoint"
                            }
                        },
                        {
                            "cluster": "seMetering",
                            "target": {
                                "endpoint": 1,
                                "ieee_address": "0x00124b0021b95104",
                                "type": "endpoint"
                            }
                        },
                        {
                            "cluster": "haMeterIdentification",
                            "target": {
                                "endpoint": 1,
                                "ieee_address": "0x00124b0021b95104",
                                "type": "endpoint"
                            }
                        },
                        {
                            "cluster": "liXeePrivate",
                            "target": {
                                "endpoint": 1,
                                "ieee_address": "0x00124b0021b95104",
                                "type": "endpoint"
                            }
                        }
                    ],
                    "clusters": {
                        "input": [
                            "genBasic",
                            "genIdentify",
                            "seMetering",
                            "haElectricalMeasurement",
                            "haMeterIdentification",
                            "liXeePrivate"
                        ],
                        "output": [
                            "genOta"
                        ]
                    },
                    "configured_reportings": [
                        {
                            "attribute": "currentSummDelivered",
                            "cluster": "seMetering",
                            "maximum_report_interval": 900,
                            "minimum_report_interval": 60,
                            "reportable_change": 100
                        },
                        {
                            "attribute": "currentTier1SummDelivered",
                            "cluster": "seMetering",
                            "maximum_report_interval": 900,
                            "minimum_report_interval": 60,
                            "reportable_change": 100
                        },
                        {
                            "attribute": "currentTier2SummDelivered",
                            "cluster": "seMetering",
                            "maximum_report_interval": 900,
                            "minimum_report_interval": 60,
                            "reportable_change": 100
                        },
                        {
                            "attribute": "apparentPower",
                            "cluster": "haElectricalMeasurement",
                            "maximum_report_interval": 900,
                            "minimum_report_interval": 60,
                            "reportable_change": 1
                        }
                    ],
                    "scenes": []
                },
                "242": {
                    "bindings": [],
                    "clusters": {
                        "input": [
                            "greenPower"
                        ],
                        "output": [
                            "greenPower"
                        ]
                    },
                    "configured_reportings": [],
                    "scenes": []
                }
            },
            "friendly_name": "Lixee TIC",
            "ieee_address": "0x00158d0005d29aa0",
            "interview_completed": true,
            "interviewing": false,
            "manufacturer": "LiXee",
            "model_id": "ZLinky_TIC\u0000",
            "network_address": 32871,
            "power_source": "Mains (single phase)",
            "software_build_id": "4000-0005",
            "supported": true,
            "type": "Router"
        }
    }
}

Features index: ( TOTAL, Heures pleines, Heures Creuses)

 {
                        "access": 1,
                        "description": "Total active power delivered",
                        "name": "EAST",
                        "property": "current_summ_delivered",
                        "type": "numeric",
                        "unit": "kWh"
                    },
                    {
                        "access": 1,
                        "description": "Total provider active power delivered (index 01)",
                        "name": "EASF01",
                        "property": "current_tier1_summ_delivered",
                        "type": "numeric",
                        "unit": "kWh"
                    },
                    {
                        "access": 1,
                        "description": "Total provider active power delivered (index 02)",
                        "name": "EASF02",
                        "property": "current_tier2_summ_delivered",
                        "type": "numeric",
                        "unit": "kWh"
                    },
atrovato commented 2 years ago

@VonOx According to exposes, z2m service generates those features:

{
  name: "0x00158d00045b2740",
  model: "WSDCGQ11LM",
  external_id: "zigbee2mqtt:0x00158d00045b2740",
  features: [
    {
      name: "Current index tarif",
      read_only: true,
      has_feedback: false,
      min: 0,
      max: 10000,
      category: "energy-sensor",
      type: "index",
      unit: null,
      external_id: "zigbee2mqtt:0x00158d00045b2740:energy-sensor:index:current_index_tarif",
      selector: "zigbee2mqtt-0x00158d00045b2740-energy-sensor-index-current-index-tarif",
    },
    {
      name: "Current summ delivered",
      read_only: true,
      has_feedback: false,
      min: 0,
      max: 1000000,
      category: "energy-sensor",
      type: "index",
      unit: "kilowatt-hour",
      external_id: "zigbee2mqtt:0x00158d00045b2740:energy-sensor:index:current_summ_delivered",
      selector: "zigbee2mqtt-0x00158d00045b2740-energy-sensor-index-current-summ-delivered",
    },
    {
      name: "Current tier1 summ delivered",
      read_only: true,
      has_feedback: false,
      min: 0,
      max: 1000000,
      category: "energy-sensor",
      type: "index",
      unit: "kilowatt-hour",
      external_id: "zigbee2mqtt:0x00158d00045b2740:energy-sensor:index:current_tier1_summ_delivered",
      selector: "zigbee2mqtt-0x00158d00045b2740-energy-sensor-index-current-tier1-summ-delivered",
    },
    {
      name: "Current tier2 summ delivered",
      read_only: true,
      has_feedback: false,
      min: 0,
      max: 1000000,
      category: "energy-sensor",
      type: "index",
      unit: "kilowatt-hour",
      external_id: "zigbee2mqtt:0x00158d00045b2740:energy-sensor:index:current_tier2_summ_delivered",
      selector: "zigbee2mqtt-0x00158d00045b2740-energy-sensor-index-current-tier2-summ-delivered",
    },
    {
      name: "Apparent power",
      read_only: true,
      has_feedback: false,
      min: 0,
      max: 10000,
      category: "energy-sensor",
      type: "power",
      unit: "volt-ampere",
      external_id: "zigbee2mqtt:0x00158d00045b2740:energy-sensor:power:apparent_power",
      selector: "zigbee2mqtt-0x00158d00045b2740-energy-sensor-power-apparent-power",
    },
    {
      name: "Linkquality",
      read_only: true,
      has_feedback: false,
      min: 0,
      max: 5,
      category: "signal",
      type: "integer",
      unit: null,
      external_id: "zigbee2mqtt:0x00158d00045b2740:signal:integer:linkquality",
      selector: "zigbee2mqtt-0x00158d00045b2740-signal-integer-linkquality",
    },
  ],
  should_poll: false,
  service_id: "f87b7af2-ca8e-44fc-b754-444354b42fee",
}

So names don't looks like "Index". I'm a bit confused :/

VonOx commented 2 years ago

Me too 😅, my bad.

I don't know why, but I was thinking this PR is showing features name for example in dashboard edit.

Screenshot_2022-09-16-20-42-08-644_com.android.chrome.jpg

atrovato commented 2 years ago

Ok, I miss the device feature dropdown selector.

atrovato commented 2 years ago

@VonOx new commit for select field (dashboad device in room and scenes). Can you please test it?

VonOx commented 2 years ago

IMG_20220918_162931.jpg

atrovato commented 2 years ago

@VonOx are you sure you get also the last commit of this branch?

VonOx commented 2 years ago

Yeah sure, I've also tried to add zigbee2mqtt as service in device.js without success

https://github.com/atrovato/Gladys/pull/54/files#diff-7e0a50e4f2db4923b9884a4f1ecae7721e77363d4451a79e74e8b3a32025648eL17

atrovato commented 2 years ago

@VonOx are you really sure to have these changes https://github.com/atrovato/Gladys/pull/54/commits/6d4d4e2204878fc7016d23ec4d93a3c3e71f9cab ?

Is your screen related to scene Triggers box? Sorry but it looks fine on my side...

VonOx commented 2 years ago

I trust you don't worry 😉

I've checked all files individually and rebuilded the front, no luck and I don't understand why.

Yes screenshot come from scene edit screen.

Can you post a screenshot of the result on your side?

atrovato commented 2 years ago

I paste the generated device from https://github.com/atrovato/Gladys/pull/54#issuecomment-1249650132 into demo.js:

image

atrovato commented 1 year ago

Merged