dresden-elektronik / deconz-rest-plugin

deCONZ REST-API plugin to control ZigBee devices
BSD 3-Clause "New" or "Revised" License
1.88k stars 485 forks source link

LiXee ZLinky_TIC #5459

Closed chpego closed 2 years ago

chpego commented 2 years ago

Device

Screenshots

Simple Metering

image

Electrical Measurement

image

Smanar commented 2 years ago

Ok so if I make a resume.

Cluster to bind

Usefull Attributes.

Edit: Ok, I give up, not comprehensible, not possible make a clear tutorial ? I haven't found how to set the OPTARIF Values for exemple.

OPTARIF | 0xFF66 | 0x0000 | RO |   | String | 4 car | - | Option tarifaire | BASE -- | -- | -- | -- | -- | -- | -- | -- | -- | --

And ? What are the possibles values ?

Seriously a classic user (that use base or HP/HC) need 20 attributes on 3 endpoints to have 3/4 consumption values ? Will be fine having Basic Attributes for basic uses, and Advanced Attributes for advanced use in the help page.

chpego commented 2 years ago

@fairecasoimeme author of project, may be able to answer these questions ?

fairecasoimeme commented 2 years ago

@Smanar seriously, did you really read https://github.com/fairecasoimeme/Zlinky_TIC ?

There is 1 endpoint , the optarif values are listed and the optarif is given by Linky.

Mimiix commented 2 years ago

@Smanar seriously, did you really read https://github.com/fairecasoimeme/Zlinky_TIC ?

There is 1 endpoint , the optarif values are listed and the optarif is given by Linky.

No need to become hostile.

Smanar commented 2 years ago

My bad. For the 3 Endpoints, it s from a project that already support it (have usefull comment on code to explain), but IDK if his code is still in date, as on the capture the device use effectively only 1 endpoint, the second one is only for GP.

And haven't see the value for optarif was read only.

fairecasoimeme commented 2 years ago

@Smanar seriously, did you really read https://github.com/fairecasoimeme/Zlinky_TIC ? There is 1 endpoint , the optarif values are listed and the optarif is given by Linky.

No need to become hostile.

?

Smanar commented 2 years ago

Ok, I undertand better, For exemple If I m right

If you use the "mode historique" with the opt tarif = "BASE" and MonoPhase you need only

BASE | 0x0702 | 0x0000 | RP |   | Uint32 | 9 car | Wh | Index Base | 0 -- | -- | -- | -- | -- | -- | -- | -- | -- | --

@chpego Can I have some information on your electricity contract ?

fairecasoimeme commented 2 years ago

Ok, I undertand better, For exemple If I m right

If you use the "mode historique" with the opt tarif = "BASE" you need only

BASE 0x0702 0x0000 RP   Uint32 9 car Wh Index Base 0 @chpego Can I have some information on your electricity contract ?

Yes, you can observe the color to know what attributes are used

Smanar commented 2 years ago

And usefull too

IINST | 0x0B04 | 0x0508 | RP |   | Uint16 | 3 car | A | Courant efficace | 0xFFFF -- | -- | -- | -- | -- | -- | -- | -- | -- | --

And some alarm on Cluster 0xFF66

ADPS | 0xFF66 | 0x0005 | RP |   | Uint16 | 3 car | A | Avertissement de Dépassement De Puissance Souscrite | 0 -- | -- | -- | -- | -- | -- | -- | -- | -- | --

And some other informations in Read Only mode.

fairecasoimeme commented 2 years ago

You can get the protocol here : https://www.enedis.fr/media/2035/download

Smanar commented 2 years ago

So in reality was not as terrifying than the table size, sorry for my reaction @fairecasoimeme . I still hope that no one will use the "Mode standard" soon.

fairecasoimeme commented 2 years ago

And usefull too

IINST 0x0B04 0x0508 RP   Uint16 3 car A Courant efficace 0xFFFF And some alarm on Cluster 0xFF66

ADPS 0xFF66 0x0005 RP   Uint16 3 car A Avertissement de Dépassement De Puissance Souscrite 0 And some other informations in Read Only mode. So in reality was not as terrifying than the table size, sorry for my reaction @fairecasoimeme . I still hope that no one will use the "Mode standard" soon.

No PB @Smanar. Standard mode is not used a lot.

Smanar commented 2 years ago

@chpego Can I have some information on your electricity contract ?

We will first add the new cluster/attribute to the XML file, for you will be able to write and read data according to your contract. This is easy part, just need to edit an xml file.

chpego commented 2 years ago

@chpego Can I have some information on your electricity contract ?

We will first add the new cluster/attribute to the XML file, for you will be able to write and read data according to your contract. This is easy part, just need to edit an xml file.

yes , this is information of contract : image

Smanar commented 2 years ago

Ok so I think it s possible adding this device without editing the c++ code.

I presume you are using "Mode historique" ?

Here you have some change to try on the xml file (/usr/share/deCONZ/zcl/general.xml on raspbian) https://github.com/Smanar/deconz-rest-plugin/blob/zlinky/general.xml

The code to try is just that (but can use the complete file)

    <!-- LiXee -->
    <cluster id="0xff66" name="LiXee specific cluster" mfcode="0x1037">
      <description>LiXee specific cluster.</description>
      <server>
        <attribute id="0x0000" type="cstring" name="Option tarifaire" access="r" required="m"/>
        <attribute id="0x0002" type="u8" name="Horaire HP-HC" access="r" required="m" default="0x00"/>
        <attribute id="0x0003" type="u8" name="Présence des potentiels" access="r" required="m" default="0x00"/>
        <attribute id="0x0004" type="u8" name="Préavis début EJP" access="r" required="m" default="0x00"/>
        <attribute id="0x0005" type="u16" name="Avertissement de Dépassement De Puissance Souscrite" access="r" required="m" default="0x00"/>
        <attribute id="0x0006" type="u16" name="Avertissement de Dépassement D'intensité P1" access="r" required="m" default="0x00"/>
        <attribute id="0x0007" type="u16" name="Avertissement de Dépassement D'intensité P2" access="r" required="m" default="0x00"/>
        <attribute id="0x0008" type="u16" name="Avertissement de Dépassement D'intensité P3" access="r" required="m" default="0x00"/>
      </server>
    </cluster>

The only ones availables for you will be 0x0000 an perhaps 0x0005, but you will have LiXee cluster instead of unknow. There is some problem on the cluster 0x0B01 but you don't need it yet.

For the second part, do you know what is DDF file on deconz ? You have a sample here https://github.com/dresden-elektronik/deconz-rest-plugin/issues/5248#issuecomment-945174475

For your device :

If I m right at least 2 values are native,

If it not working can you show your DDF file ?

chpego commented 2 years ago

Hi @Smanar , Edit: I'm using deconz addon on Home Assistant, I don't know if I can upload the XML file right now, unless you have a procedure Okay, i push the general.xml and reload deconz :
image

chpego commented 2 years ago

Meter Identification

image

Smanar commented 2 years ago

Nice, thx. "Intensité souscrite" can be 30A, seem normal. I have added more field, but they are not mandatory (and some of them not used for you). I think it s for that your have 0

Have you tried to make a DDF file ? So you need more explanation ?

chpego commented 2 years ago

For DDF file, i think i can't because i'm on 2.12.6 deconz version, right ?

Smanar commented 2 years ago

Ha yep, you need a recent version. I haven't asked, what is your OS ? Can you update deconz ?

chpego commented 2 years ago

I'm usinge HA with the addon deconz

Smanar commented 2 years ago

Ha bad luck. HA use only stable version of deconz ? Using DDF don't need to recompile the code (nice for HA users), but you need a recent version.

chpego commented 2 years ago

Ha bad luck. HA use only stable version of deconz ? Using DDF don't need to recompile the code (nice for HA users), but you need a recent version.

Yes, only stable. I'll waiting 🤷🏼‍♂️

chpego commented 2 years ago

@Smanar , i'm curious , how will the device be detected in the Phoscon Web App afterwards as a sensor?

Smanar commented 2 years ago

Yep, sensor, but it will work too with light for detection (there is not a big difference on the 2 mode)

Phoscon don't support power measurement, you will have it in HA after that, same result than a simple plug that display current and consumption (to start, this device have some options)

AdrienBigot commented 2 years ago

I've just receive today a Lixee Zlinky_TIC. I'm running deconZ outside of HomeAssitant OS so I have : ii deconz 2.13.02-raspbian-buster-beta armhf A generic ZigBee monitoring and control tool

Tomorrow, I'll try to modify general.xml file with the config you provided above and I can help with an DDF file if you still need one. Let me know.

Adrien

chpego commented 2 years ago

I've just receive today a Lixee Zlinky_TIC. I'm running deconZ outside of HomeAssitant OS so I have : ii deconz 2.13.02-raspbian-buster-beta armhf A generic ZigBee monitoring and control tool

Tomorrow, I'll try to modify general.xml file with the config you provided above and I can help with an DDF file if you still need one. Let me know.

Adrien

Yes , please 💪

Smanar commented 2 years ago

Yep pls, for DDF you have a starting point here https://github.com/dresden-elektronik/deconz-rest-plugin/issues/5248#issuecomment-945174475

But I can explain better, I think you will need only ZHAPower and ZHAConsumption.

AdrienBigot commented 2 years ago

Is it what you need ?

{
  "schema": "devcap1.schema.json",
  "manufacturername": "LiXee",
  "modelid": "ZLinky_TIC",
  "product": "ZLinky_TIC",
  "sleeper": false,
  "status": "Bronze",
  "subdevices": [
    {
      "type": "$TYPE_CONSUMPTION_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x01",
        "0x0702"
      ],
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid"
        },
        {
          "name": "attr/name"
        },
        {
          "name": "attr/swversion"
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/consumption",
          "description": "The measured consumption (in Wh).",
          "refresh.interval": 300
        },
        {
          "name": "state/lastupdated"
        }
      ]
    },
    {
      "type": "$TYPE_POWER_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x01",
        "0x0b04"
      ],
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid"
        },
        {
          "name": "attr/name"
        },
        {
          "name": "attr/swversion"
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/current",
          "description": "The measured current (in mA).",
          "refresh.interval": 300
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "state/power",
          "description": "The measured power (in W).",
          "refresh.interval": 300
        },
        {
          "name": "state/voltage",
          "description": "The measured voltage (in V).",
          "refresh.interval": 300
        }
      ]
    }
  ]
}

After hot reload, my device name changed to "Power 6"

Capture d’écran du 2021-11-18 21-36-15

And sincerly , I'm a bit confused about what you need exactly and what information is missing. :-D

Smanar commented 2 years ago

If the name was changed it's fine, it s mean the device was added in the API. Are you using third app ? Else you can use the beta phoscon http://phoscon.de/pwabeta in help / API information.

If all is fine you will have 2 new sensor in it.

For information, as DDF are still beta, for the moment it s disabled at every restart, so don't forget to save the file.

AdrienBigot commented 2 years ago

I'm using deconz with the home Assitant integration. For the moment, I think this device is not supported by integration so not visible in HA. But I also have Phoscon installed and I confirm that in the Help / API info I can see 2 new sensors (Power 6 and Consumption 5) Capture d’écran du 2021-11-19 19-33-38

 "5": {
    "config": {
      "on": true,
      "reachable": true
    },
    "etag": "57689bdbea80225c741004f532ed4ed5",
    "lastannounced": null,
    "lastseen": "2021-11-18T19:06Z",
    "manufacturername": "LiXee",
    "modelid": "ZLinky_TIC",
    "name": "Consumption 5",
    "state": {
      "consumption": null,
      "lastupdated": "none"
    },
    "swversion": "4000",
    "type": "ZHAConsumption",
    "uniqueid": "00:15:8d:00:05:be:9b:92-ff-0702"
  },
  "6": {
    "config": {
      "on": true,
      "reachable": true
    },
    "etag": "af89342494e1234c8957f64f8d9b5b15",
    "lastannounced": null,
    "lastseen": "2021-11-18T19:06Z",
    "manufacturername": "LiXee",
    "modelid": "ZLinky_TIC",
    "name": "Power 6",
    "state": {
      "current": null,
      "lastupdated": "none",
      "power": null,
      "voltage": null
    },
    "swversion": "4000",
    "type": "ZHAPower",
    "uniqueid": "00:15:8d:00:05:be:9b:92-ff-0b04"
  }

Could you please give me more informations about what is Devices Description Files ? Why do I need to generate it ?

Thanks !

Adrien

Smanar commented 2 years ago

I think this device is not supported by integration so not visible in HA.

No problem, for the base, it s already used sensor, a ZHAPower and a ZHAConsumption, thoses one are used for exemple for plugs. And you have it in the API, so there is no reason to don't see them in HA. I will ask to Robban if you still have problem with it. Will be another problem for advanced features, but I think the basics features can work natively on HA.

Could you please give me more informations about what is Devices Description Files ? Why do I need to generate it ?

But you have already started. You have saved the file ? DDF file are the future deconz feature, every devices will have one, it will help for device reconization, and make the support easier, as it will be json file, so less work to do on c++ code (and less problem for us, new devices will not broke olders for exemple). Just using a text editor (if you don't have the GUI and the editor) you will be able to make almost all you want on devices (setting reporting, binds, reverse covering, ect ...)

For the moment it still on beta, so for exemple DDF are disabled at every deconz restart.

For your device, it seem value are not filled, so we will continue the DDF file (and don't forget to save the file)

It's possible you have some value auto filled, so idk exactly values your need or not, if you are not sure, just show how look the DDF editor for the device.

AdrienBigot commented 2 years ago

Hi,

Thank you for your explanations. I confirm that Power 6 appears in Home Assitant but are values for sensors "Consumption 5" and "Power 6" are empty.

I continue the DDF file by adding bindings as you asked and you were right when you said "It's possible you have some values auto filled". I think all is automatically auto filled without errors. See screenshots :

electrical_mesurement simple_metering

I saved the DDF File and hot reload (multiple times) but I still don't see any value when I request the API, even after waiting for more than 300 seconds.

curl -s -X GET -H "Content-Type: application/json" http://xxxxxxxxxxxxxxxxxxx/api/XXXXXXXXX/sensors/5 | jq .
{
  "config": {
    "on": true,
    "reachable": true
  },
  "etag": "9aef951c6ca18eed9bb2438d49f5a1e7",
  "lastannounced": null,
  "lastseen": "2021-11-18T19:06Z",
  "manufacturername": "LiXee",
  "modelid": "ZLinky_TIC",
  "name": "Consumption 5",
  "state": {
    "consumption": null,
    "lastupdated": "none"
  },
  "swversion": "4000",
  "type": "ZHAConsumption",
  "uniqueid": "00:15:8d:00:05:be:9b:92-ff-0702"
}
curl -s -X GET -H "Content-Type: application/json" http://xxxxxxxxxxxxxxxxxxx/api/XXXXXXXXX/sensors/6 | jq .
{
  "config": {
    "on": true,
    "reachable": true
  },
  "etag": "d01530209e0f1f4a5bed1d75698c45a6",
  "lastannounced": null,
  "lastseen": "2021-11-18T19:06Z",
  "manufacturername": "LiXee",
  "modelid": "ZLinky_TIC",
  "name": "Power 6",
  "state": {
    "current": null,
    "lastupdated": "none",
    "power": null,
    "voltage": null
  },
  "swversion": "4000",
  "type": "ZHAPower",
  "uniqueid": "00:15:8d:00:05:be:9b:92-ff-0b04"
}

Maybe there is a problem with bindings ? What the endpoint address means ?

bindings

One interesting thing, is that I'm able to verify that the "Apparent power" value in the cluster 0x0b04 is updated regularly and reflect the value I can read directly on the LCD screen of my Linky electric meter .

apparent_power IMG_20211120_225404

Smanar commented 2 years ago

Maybe there is a problem with bindings ? What the endpoint address means ?

The endpoint is the number "01" and "F2" on your capture. This device use only "01"

And yes sorry, my bad. On the second tab "bindings"

And use this setting for exemple (it s the defaut value in c++ code)

        rq.minInterval = 1;
        rq.maxInterval = 300;
       rq.reportableChange48bit = 1;

Datatype are u16

And yes have forget the power too. Cluster 0x0b04 attribute 0x050F

AdrienBigot commented 2 years ago

Great, it works !

Current, power and consumption are now visible through the API. IDK why the lastupdated attribute is never updated.

Now I have to understand why these values are not visible in Home Assitant. I think it's related to a starnge thing I noticed. When I curl the /sensors endpoint API All values are OK. But when I curl each sensors directly values are null. It's the same behaviour with curl and in the Phoscon app.

OK :

curl -s -X GET -H "Content-Type: application/json" http://xxxxxxxxxxxxxxxxxxx/api/XXXXXXXXX/sensors/ | jq .
"5": {
    "config": {
      "on": true,
      "reachable": true
    },
    "etag": null,
    "lastannounced": null,
    "lastseen": "2021-11-21T10:36Z",
    "manufacturername": "LiXee",
    "modelid": "ZLinky_TIC",
    "name": "Consumption 5",
    "state": {
      "consumption": 1.02747E+7,
      "lastupdated": "none"
    },
    "swversion": "4000",
    "type": "ZHAConsumption",
    "uniqueid": "00:15:8d:00:05:be:9b:92-01-0702"
  },
  "6": {
    "config": {
      "on": true,
      "reachable": true
    },
    "etag": null,
    "lastannounced": null,
    "lastseen": "2021-11-21T10:36Z",
    "manufacturername": "LiXee",
    "modelid": "ZLinky_TIC",
    "name": "Power 6",
    "state": {
      "current": 2,
      "lastupdated": "none",
      "power": 500,
      "voltage": null
    },
    "swversion": "4000",
    "type": "ZHAPower",
    "uniqueid": "00:15:8d:00:05:be:9b:92-01-0b04"
  }

NOT OK :

curl -s -X GET -H "Content-Type: application/json" http://xxxxxxxxxxxxxxxxxxx/api/XXXXXXXXX/sensors/6/ | jq .
{
  "config": {
    "on": true,
    "reachable": true
  },
  "etag": "0b163249539ceb854550127b47b28b65",
  "lastannounced": null,
  "lastseen": "2021-11-20T22:47Z",
  "manufacturername": "LiXee",
  "modelid": "ZLinky_TIC",
  "name": "Power 6",
  "state": {
    "current": null,
    "lastupdated": "none",
    "power": null,
    "voltage": null
  },
  "swversion": "4000",
  "type": "ZHAPower",
  "uniqueid": "00:15:8d:00:05:be:9b:92-ff-0b04"
}

In Phoscon :

sensors

direct_6

Smanar commented 2 years ago

Ha, effectively, this is funny ...

I will ask to other devs, I hope it s not a DDF issue.

Smanar commented 2 years ago

I have no explanation yet but Swoop have see something strange, on the ZHAPower you have 2 differents uniqueID. Try to force the endpoint to 0x01 instead of "auto" (and BTW why "FF" ...)

AdrienBigot commented 2 years ago

Good news, it works !

I can now graph for example the Power attribute in Home Assistant because the API return good data. HA_graphes

As you noticed, the problem was in the subdevice UID. This morning I wanted to restart a DDF from scratch and when I opened the editor, it automatically added in the Left Column ZHApower and ZHAConsumption subdevices. BUT, by default, the template UID are $address.ext-0xff-0x0b04 and $address.ext-0xff-0x0702 . IDK why , maybe a default config.

ff

Smanar commented 2 years ago

I m reading the page https://github.com/fairecasoimeme/Zlinky_TIC

It seem the only usefull thing you miss is

ADPS | 0xFF66 | 0x0005 | RP |   | Uint16 | 3 car | A | Avertissement de Dépassement De Puissance Souscrite | 0 -- | -- | -- | -- | -- | -- | -- | -- | -- | --

But idk if it s possible to simulate it, and the utility. If you exceed the value too long time, it cut the power nope ?

And we will have a problem too, the device is easy to make it working, it s zigbee compliant. But according to the contract or the mode (historical/standard), bind and report will not be the same. IDK if tis will be possible without touching the c++ code.

And BTW if you can share the DDF for others users ?

Smanar commented 2 years ago

BTW for the issue with lastupdated, try to check the case "Awake on receive" for some attributes.

Edit: Ok it seem it s an issue, will be solved in next version,.

AdrienBigot commented 2 years ago

Yes the "Avertissement de Dépassement De Puissance Souscrite" in cluster 0xFF66 is difficult to test and as I imagine, when you reach the subscribed power, the linky cut the power. So, It's not very useful since if if the power is cut, home assistant / internet box etc ... are down :-D But maybe the power is cut after a certain amount of time and it can be useful to send an alert during the period the power is still ok :) . Or in another case the limit can flap because the subscriber use just the limit of its contract ... but IMHO it's very rare. I tried to add it but I don't have LiXee specific cluster in the column available items in DDF editor and edit the DDF file by hand not works anymore.

Of Course I can share my DDF File.

For a contract : BASE (no HC HP) Monophasé 6KVA (same as @chpego ) DDF file is :

{
  "schema": "devcap1.schema.json",
  "manufacturername": "LiXee",
  "modelid": "ZLinky_TIC",
  "product": "ZLinky_TIC",
  "sleeper": false,
  "status": "Bronze",
  "path": "/devices/zlinky_tic.json",
  "subdevices": [
    {
      "type": "$TYPE_POWER_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x01",
        "0x0b04"
      ],
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid"
        },
        {
          "name": "attr/name"
        },
        {
          "name": "attr/swversion"
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/current",
          "refresh.interval": 300,
          "read": {
            "at": "0x0508",
            "cl": "0x0b04",
            "ep": 1,
            "fn": "zcl"
          },
          "parse": {
            "at": "0x0508",
            "cl": "0x0b04",
            "ep": 1,
            "eval": "if (Attr.val != 65535) { Item.val = Attr.val; }"
          }
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "state/power",
          "refresh.interval": 300,
          "read": {
            "at": "0x050f",
            "cl": "0x0b04",
            "ep": 1,
            "fn": "zcl"
          },
          "parse": {
            "at": "0x050f",
            "cl": "0x0b04",
            "ep": 1,
            "eval": "if (Attr.val != -32768) { Item.val = Attr.val; }"
          }
        },
        {
          "name": "state/voltage",
          "description": "The measured voltage (in V).",
          "refresh.interval": 300
        }
      ]
    },
    {
      "type": "$TYPE_CONSUMPTION_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x01",
        "0x0702"
      ],
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid"
        },
        {
          "name": "attr/name"
        },
        {
          "name": "attr/swversion"
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/consumption",
          "description": "The measured consumption (in Wh).",
          "refresh.interval": 300
        },
        {
          "name": "state/lastupdated"
        }
      ]
    }
  ],
  "bindings": [
    {
      "bind": "unicast",
      "src.ep": 1,
      "cl": "0x0B04",
      "report": [
        {
          "at": "0x050F",
          "dt": "0x21",
          "min": 1,
          "max": 300,
          "change": "0x00000001"
        },
        {
          "at": "0x0508",
          "dt": "0x21",
          "min": 1,
          "max": 300,
          "change": "0x00000001"
        }
      ]
    },
    {
      "bind": "unicast",
      "src.ep": 1,
      "cl": "0x0702",
      "report": [
        {
          "at": "0x0000",
          "dt": "0x23",
          "min": 1,
          "max": 300,
          "change": "0x00000001"
        }
      ]
    }
  ]
}
Smanar commented 2 years ago

Ok will be more sportive. So waiting for new deconz version.

Can try to add the missing state/alam, taked from here https://github.com/dresden-elektronik/deconz-rest-plugin/pull/5503/files (devices/generic/items/state_alarm_item.json)

And make something like that (you will have a popup, say "yes") zemi

With 0x01 as endpoint, If I m right the attribut returned is a value in amperes, so it's perhaps 0 if all is good and 3 if you exceed, from 3 A .... You will see in the cluster if you have something, on the previous test, all was 0. And you need too, set a bind and configure a reporting on the second tab "bindings"

I don't have LiXee specific cluster in the column available items in DDF editor

To have the lixee cluster, you need to edit the xml file https://github.com/dresden-elektronik/deconz-rest-plugin/issues/5459#issuecomment-962577707 Or there is something I haven't see in the DDF editor ?

AdrienBigot commented 2 years ago

Sorry but today, DDF doesn't want to work ... IDK why, but sometimes DDF are not taken into account when I "hot reload" or partially working. At the begining, I thought it was an API cache problem because after 3 or more try, I was able to read a good value. But today, no value are visible by home assistant because when I call sensors directly (/sensors/6 for example) no values are present (same problem I had 2 days ago). After manny tries / restart DDF doesn't work anymore for me. All attributes are set to "null" (it's not the case when I request the endpoint /sensors )

Result :

curl -s -X GET -H "Cache-Control: no-cache" -H "Content-Type: application/json" http://xxxxxxxxxxxxxxxxxxxx/api/XXXXXXXX/sensors/6/ | jq .
{
  "config": {
    "on": true,
    "reachable": true
  },
  "etag": "011af670a593a71a3a738d4fa9a6ea5f",
  "lastannounced": null,
  "lastseen": "2021-11-22T20:24Z",
  "manufacturername": "LiXee",
  "modelid": "ZLinky_TIC",
  "name": "Power 6",
  "state": {
    "current": null,
    "lastupdated": "none",
    "power": null,
    "voltage": null
  },
  "swversion": "4000",
  "type": "ZHAPower",
  "uniqueid": "00:15:8d:00:05:be:9b:92-ff-0b04"
}

I did a last test to try something with the DDF file and it was a bit confusing.

What I did :

  1. I first remove my DDF file placed in my folder ~/.local/share/dresden-elektronik/deCONZ/devices/zlinky_tic.json. I suspect deCONZ try to read it when it starts but because DDF are disabled by default it turns into bad things (it's just a guess).
  2. I curl API (with DDF disabled in the controle pane) and I saw old values in the current and power attributes (I think the last value found in the API cache). Results :
    
    curl -s -X GET -H "Cache-Control: no-cache" -H "Content-Type: application/json" http://xxxxxxxxxxxxxxxxxxxx/api/XXXXXXXX/sensors/6/ | jq .
    {
    "config": {
    "on": true,
    "reachable": true
    },
    "etag": "36cfbe30f682b932a2a14a1549900e4f",
    "lastannounced": null,
    "lastseen": "2021-11-22T20:38Z",
    "manufacturername": "LiXee",
    "modelid": "ZLinky_TIC",
    "name": "Power 6",
    "state": {
    "current": 2,
    "lastupdated": "none",
    "power": 560,
    "voltage": null
    },
    "swversion": "4000",
    "type": "ZHAPower",
    "uniqueid": "00:15:8d:00:05:be:9b:92-ff-0b04"
    }
3. Then, I enabled DDF in the controle pane , load my saved DDF file and Hot Reload and Curl 
Results : 
```json
curl -s -X GET -H "Cache-Control: no-cache" -H "Content-Type: application/json" http://xxxxxxxxxxxxxxxxxxxx/api/XXXXXXXX/sensors/6/ | jq .
{
  "config": {
    "on": true,
    "reachable": true
  },
  "etag": "930ab037a556d467dbe256216230c244",
  "lastannounced": null,
  "lastseen": "2021-11-22T20:38Z",
  "manufacturername": "LiXee",
  "modelid": "ZLinky_TIC",
  "name": "Power 6",
  "state": {
    "current": 2,
    "lastupdated": "none",
    "power": 560,
    "voltage": 520
  },
  "swversion": "4000",
  "type": "ZHAPower",
  "uniqueid": "4000"
}

WTF ? The updated power value (520) appears in the Voltage attribute ! It verify why this feature is still in beta state :-D

But it's not the goal of this issue so I won't go in details but I'm available to fill a bug report if you are interested.

ivico94 commented 2 years ago

Hello @AdrienBigot and thank you for this ongoing project! I would like to complete you're answer. The "Avertissement de Dépassement De Puissance Souscrite" does not lead to an instantaneous cut of power. Without knowing the exact duration before the power is cut, I was able to see via my Linky data on the site of Enedis (electricity provider) that I have several times exceeded my power over a year, without having the Linky cut.

On the contrary, having this information would allow to do load shedding (i.e. to cut off energy consuming devices) and thus optimize the power selected with the electricity subscription.

I would find it very relevant to have this information sent to Home Assistant in order to trigger an automation. It would allow us to optimize the max power selected with the electricity subscription and thus, lower our bill :-)

AdrienBigot commented 2 years ago

Thanks @ivico94 for these details. Indeed, it's quite interesting and following your comment, I've dowloaded my monthly max power and I observed that me too, I've several time exceeded my 6kVA subscription.

You're right :

it's very relevant to have this information sent to Home Assistant in order to trigger an automation

Smanar commented 2 years ago

Same issue than before

"uniqueid": "00:15:8d:00:05:be:9b:92-ff-0b04"

There is something wrong with the endpoint, but your ddf is fine, you are using 0x01. Yes there is a conflict somewhere but I don't see why the api have take FF without using the ddf core .... You have deleted and re-included the device ? (because a uniqueid can't be modified and the one in the API don't look like one that can be created by the ddf.)

And from my memory the device don't use the "voltage" at all ? it s not visible in the GUI. Have you updated the xml file to have the lixee cluster available in deconz ? Even I think the value is 0 for 0xFF66 / 0x0005

And BTW, look at the last uniqueid, it s the swversion.

"uniqueid": "4000"

I think you have found a new issue.

AdrienBigot commented 2 years ago

Yes I think this is a new issue because sometimes, I also have a value like 1.02806E+7 for the Current attribute. And this kind of value is from the consumption attribute. It's like the API mix up all values together ...

You have deleted and re-included the device ? (because a uniqueid can't be modified and the one in the API don't look like one that can be created by the ddf.)

No, I didn't reinclude the device at all. When I start deCONZ with DDF disabled, I can see in the /sensors endpoint that all sensors from 1 to 4 have in their uniqueid the endpoint 0x01 but for the sensors 5 and 6 (ZHAConsumption and ZHAPower) the endpoint id 0xff.

curl -s -X GET -H "Content-Type: application/json" http://xxxxxxxxxxxxxxxxxxxxxxxxxx/api/XXXXXXXXX/sensors/ | jq .
{
  "1": {
    "config": {
      "configured": true,
      "on": true,
      "sunriseoffset": 30,
      "sunsetoffset": -30
    },
    "etag": "40155e45efb4d1755e8d046d1cf714d3",
    "manufacturername": "Philips",
    "modelid": "PHDL00",
    "name": "Daylight",
    "state": {
      "dark": true,
      "daylight": false,
      "lastupdated": "2021-11-23T17:33:28.712",
      "status": 220,
      "sunrise": "2021-11-23T06:50:14",
      "sunset": "2021-11-23T16:15:21"
    },
    "swversion": "1.0",
    "type": "Daylight",
    "uniqueid": "00:21:2e:ff:ff:06:9b:04-01"
  },
  "2": {
    "config": {
      "battery": 100,
      "offset": 0,
      "on": true,
      "reachable": true
    },
    "ep": 1,
    "etag": "bf598c8a6c7e4e35559189e1732a2799",
    "lastannounced": "2021-11-03T17:53:52Z",
    "lastseen": "2021-11-22T22:08Z",
    "manufacturername": "LUMI",
    "modelid": "lumi.weather",
    "name": "Multi Sensor",
    "state": {
      "lastupdated": "2021-11-22T22:08:53.570",
      "temperature": 1771
    },
    "swversion": "20191205",
    "type": "ZHATemperature",
    "uniqueid": "00:15:8d:00:01:9d:18:b7-01-0402"
  },
  "3": {
    "config": {
      "battery": 100,
      "offset": 0,
      "on": true,
      "reachable": true
    },
    "ep": 1,
    "etag": "74665e41140d7028765338e4b7a9026d",
    "lastannounced": "2021-11-03T17:53:52Z",
    "lastseen": "2021-11-22T22:08Z",
    "manufacturername": "LUMI",
    "modelid": "lumi.weather",
    "name": "Humidity 3",
    "state": {
      "humidity": 5320,
      "lastupdated": "2021-11-22T22:08:53.632"
    },
    "swversion": "20191205",
    "type": "ZHAHumidity",
    "uniqueid": "00:15:8d:00:01:9d:18:b7-01-0405"
  },
  "4": {
    "config": {
      "battery": 100,
      "offset": 0,
      "on": true,
      "reachable": true
    },
    "ep": 1,
    "etag": "98725cff8062d17b5da5315628e3f659",
    "lastannounced": "2021-11-03T17:53:52Z",
    "lastseen": "2021-11-22T22:08Z",
    "manufacturername": "LUMI",
    "modelid": "lumi.weather",
    "name": "Pressure 4",
    "state": {
      "lastupdated": "2021-11-22T22:08:53.678",
      "pressure": 1007
    },
    "swversion": "20191205",
    "type": "ZHAPressure",
    "uniqueid": "00:15:8d:00:01:9d:18:b7-01-0403"
  },
  "5": {
    "config": {
      "on": true,
      "reachable": true
    },
    "etag": "247acd22a3b2c01db1996fbd2f9692a7",
    "lastannounced": null,
    "lastseen": "2021-11-22T21:02Z",
    "manufacturername": "LiXee",
    "modelid": "ZLinky_TIC",
    "name": "Consumption 5",
    "state": {
      "consumption": 1.02806E+7,
      "lastupdated": "none"
    },
    "swversion": "4000",
    "type": "ZHAConsumption",
    "uniqueid": "00:15:8d:00:05:be:9b:92-ff-0702"
  },
  "6": {
    "config": {
      "on": true,
      "reachable": true
    },
    "etag": "215e195a488c2e125e9749c9fd9919b8",
    "lastannounced": null,
    "lastseen": "2021-11-22T21:02Z",
    "manufacturername": "LiXee",
    "modelid": "ZLinky_TIC",
    "name": "Power 6",
    "state": {
      "current": 2,
      "lastupdated": "none",
      "power": 560,
      "voltage": 440
    },
    "swversion": "4000",
    "type": "ZHAPower",
    "uniqueid": "00:15:8d:00:05:be:9b:92-ff-0b04"
  }
}

If I enable DDF file , load my file, Hot reload, the Endpoint ID are fine for sensors 5 and 6 :

"uniqueid": "00:15:8d:00:05:be:9b:92-01-0702"
"uniqueid": "00:15:8d:00:05:be:9b:92-01-0b04"

But Only for the /sensors endpoint. If I curl /sensors/6or /sensors/5 it returns the old bad Endpoint ID : 0xff or worse, after few minutes 4000 as the uniqueid attribute and the voltage contain the updated value of the power attribute ...

curl -s -X GET -H "Content-Type: application/json" http://xxxxxxxxxxxxxxxxxxx/api/XXXXXXXXXX/sensors/6 | jq .
{
  "config": {
    "on": true,
    "reachable": true
  },
  "etag": "c9398d8aa581e8df380a4b5d6df21d29",
  "lastannounced": null,
  "lastseen": "2021-11-23T17:53Z",
  "manufacturername": "LiXee",
  "modelid": "ZLinky_TIC",
  "name": "Power 6",
  "state": {
    "current": 2,
    "lastupdated": "none",
    "power": 560,
    "voltage": 900
  },
  "swversion": "4000",
  "type": "ZHAPower",
  "uniqueid": "00:15:8d:00:05:be:9b:92-ff-0b04"
}

curl -s -X GET -H "Content-Type: application/json" http://xxxxxxxxxxxxxxxxxxx/api/XXXXXXXXXX/sensors/6 | jq .{
  "config": {
    "on": true,
    "reachable": true
  },
  "etag": "34c4ecd5f9c3b1ef5a759a4c09a60e85",
  "lastannounced": null,
  "lastseen": "2021-11-23T17:53Z",
  "manufacturername": "LiXee",
  "modelid": "ZLinky_TIC",
  "name": "Power 6",
  "state": {
    "current": 2,
    "lastupdated": "none",
    "power": 560,
    "voltage": 1000
  },
  "swversion": "4000",
  "type": "ZHAPower",
  "uniqueid": "4000"
}

One advice. If I open DDF Editor just after deCONZ starts (in theory witn an "empty config" in the editor), in the left column, the editor add automatically ZHAConsumption and ZHAPower with $address.ext-0xff-0x0702 and $address.ext-0xff-0x0b04 in the Unique ID template. field. I don't know if this info is interesting for you.

Have you updated the xml file to have the lixee cluster available in deconz ? Even I think the value is 0 for 0xFF66 / 0x0005 Yes and the sluter appears in the Device cluster list but when I Drag and Drop it into the DDF editor, this cluster is unrecognized and named "Unknown" . So when I add the attribute 0x0005 in the "reporting" column, the attribute name is not filled as it can't link it with a known cluster. And of course, nothing appears in the API results.

lixee

Smanar commented 2 years ago

Ha yes I understand now, will check for lixee cluster tommorow. And for the issue, Mimiix have fowarded it to Manup, I m waiting for his reaction, because for me too, I think this issue can expose something more critic.

manup commented 2 years ago

Pretty interesting find. I think what might have happened is that in the database a the invalid sensor resources with the 0xff endpoint still exist. Not sure if they are also deleted when the device is deleted via REST-API or GUI. Need to make a few tests here...

After this likely I'll add a small check that such resources won't be added in first place and a warning to the editor that the unique id needs to be edited if endpoint is still 0xff (which is meant as a invalid placeholder).

AdrienBigot commented 2 years ago

Hi,

I made some tests this morning.

  1. Here what I have in database when I start deCONZ with DDF disabled. Old sensors 5 and 6 are still in the database with bad UID :

    sqlite> SELECT "_rowid_",* FROM "main"."sensors" WHERE "sid" >= 5;
    rowid|sid|name|type|modelid|manufacturername|uniqueid|swversion|state|config|fingerprint|deletedState|mode|lastseen|lastannounced
    8385|5|Consumption 5|ZHAConsumption|ZLinky_TIC|LiXee|00:15:8d:00:05:be:9b:92-ff-0702|4000|{"consumption":null,"lastupdated":null}|{"on":true,"reachable":false}||normal|1|2021-11-23T18:26Z|
    8384|6|Power 6|ZHAPower|ZLinky_TIC|LiXee|00:15:8d:00:05:be:9b:92-ff-0b04|4000|{"current":null,"lastupdated":null,"power":null,"voltage":null}|{"on":true,"reachable":false}||normal|1|2021-11-23T18:26Z|
  2. If I enable DDF + hot reload + query each sensor their endpoint is good :

    sqlite> SELECT "_rowid_",* FROM "main"."sensors" WHERE "sid" >= 5;
    rowid|sid|name|type|modelid|manufacturername|uniqueid|swversion|state|config|fingerprint|deletedState|mode|lastseen|lastannounced
    8483|6|Power 6|ZHAPower|ZLinky_TIC|LiXee|00:15:8d:00:05:be:9b:92-01-0b04|4000|{"current":2,"lastupdated":null,"power":500,"voltage":null}|{"on":true,"reachable":true}||normal|2|2021-11-24T08:45Z|
    8484|5|Consumption 5|ZHAConsumption|ZLinky_TIC|LiXee|00:15:8d:00:05:be:9b:92-01-0702|4000|{"consumption":1.03214e+07,"lastupdated":null}|{"on":true,"reachable":true}||normal|2|2021-11-24T08:45Z|
  3. If I stop deCONZ , values UID are still OK in the database.

  4. And Finally if I start deCONZ with DDF disabled, UID are back to bad value :

    sqlite> SELECT "_rowid_",* FROM "main"."sensors" WHERE "sid" >= 5;
    rowid|sid|name|type|modelid|manufacturername|uniqueid|swversion|state|config|fingerprint|deletedState|mode|lastseen|lastannounced
    8486|6|Power 6|ZHAPower|ZLinky_TIC|LiXee|00:15:8d:00:05:be:9b:92-ff-0b04|4000|{"current":null,"lastupdated":null,"power":null,"voltage":null}|{"on":true,"reachable":false}||normal|1|2021-11-24T08:45Z|
    8487|5|Consumption 5|ZHAConsumption|ZLinky_TIC|LiXee|00:15:8d:00:05:be:9b:92-ff-0702|4000|{"consumption":null,"lastupdated":null}|{"on":true,"reachable":false}||normal|1|2021-11-24T08:45Z|

I also notice that bad values returned when I curl API don't reflect values present in the database.

Example :

What I have in the database :

8494|6|Power 6|ZHAPower|ZLinky_TIC|LiXee|00:15:8d:00:05:be:9b:92-ff-0b04|4000|{"current":null,"lastupdated":null,"power":null,"voltage":null}|{"on":true,"reachable":false}||normal|1|2021-11-24T09:12Z|

And what is return by curl :

curl -s -X GET -H "Content-Type: application/json" http://xxxxxxxxxxxxxxxxxxxxxxxxx/api/XXXXXXXXX/sensors/6 | jq .
{
  "config": {
    "on": true,
    "reachable": true
  },
  "etag": "c5d9b8c234afd8a752355da9bcba2036",
  "lastannounced": null,
  "lastseen": "2021-11-24T09:12Z",
  "manufacturername": "LiXee",
  "modelid": "ZLinky_TIC",
  "name": "Power 6",
  "state": {
    "current": 2,
    "lastupdated": "none",
    "power": 560,
    "voltage": 610
  },
  "swversion": "4000",
  "type": "ZHAPower",
  "uniqueid": "00:15:8d:00:05:be:9b:92-ff-0b04"
}