Zigbee2mqtt revisited: No more ugly transformations

Type dimmer : dimmer "Dimmer" [ stateTopic = "zigbee2mqtt/OsramLightifyTest/brightness", commandTopic = "zigbee2mqtt/OsramLightifyTest/set/brightness", min = 1, max = 255, step = 1 ]

use this one:

Type dimmer : dimmer "Dimmer" [ stateTopic = "zigbee2mqtt/OsramLightifyTest/brightness", commandTopic = "zigbee2mqtt/OsramLightifyTest/set/brightness_percent", min = 0, max = 100, step = 1 ]

for the information commit:
Apr 22 14:26:34 openhab npm[18328]: zigbee2mqtt:info 2020-04-22 14:26:34: MQTT publish: topic ‘zigbee2mqtt/OsramLightifyTest/update_available’, payload ‘false’’

that’s correct, if it’s ‘true’ you’ve a old firmware on your Zigebee-Device. It is ‘false’ you running the newest firmware.

Thank you
I just changed it as you advised. Still it does not work right now.

That I am aware of but what I meant is that there is not a single other entry of the OsramLightifyTest device in the logs.

No linkquality or any other state reported.
Any idea why ?

EDIT: I now get the linkquality, state and brightness reported. Everything works now

Hi guys,

I just paired a 9290012573A - Philips Hue white and color ambiance E26/E27/E14 bulb with zigbee2mqtt
but this error shows:

Apr 24 01:28:02 openhab npm[3839]: zigbee2mqtt:error 2020-04-24 01:28:02: Failed to setup reporting for '0x001788010278badc' - Error: ConfigureReporting 0x001788010278badc/11 genOnOff([{"attribute":"onOff","minimumReportInterval":0,"maximumReportInterval":300,"reportableChange":0}], {"timeout":6000,"manufacturerCode":null,"disableDefaultResponse":true}) failed (Error: Timeout - 47266 - 11 - 2 - 6 - 7 after 6000ms)
Apr 24 01:28:02 openhab npm[3839]:     at Endpoint.<anonymous> (/opt/zigbee2mqtt/node_modules/zigbee-herdsman/dist/controller/model/endpoint.js:326:23)
Apr 24 01:28:02 openhab npm[3839]:     at Generator.throw (<anonymous>)
Apr 24 01:28:02 openhab npm[3839]:     at rejected (/opt/zigbee2mqtt/node_modules/zigbee-herdsman/dist/controller/model/endpoint.js:6:65)

Did you guys ever encounter an error like this, what do I need to do in such a case ?

I can control the light via mqtt but I do not get any reports of link quality etc.

what the zigbee device reports only gets shown when the device sends the data. This data is then handled by the converter to interpret. Some devices may always send the linkquality on a regular basis, some not. One helpful tool to check the linkquality is to use the network map. There you see the routes and linkqualities.

As the the log suggests, there was a timeout. Either there was no repsonse by the device and thus the message could not be delivered or the sent command was not recognised. As this is more a zigbee2mqtt than OH issue, I would search on the project’s github page.

I have opened a Issue on their repo. Seems like I am not the only one who gets this error. But should be quite easy to fix from what I understood.

What does your thing look like? So far, I’m only using attributes (works fine) but have added json. But I’m not familar with json and information on color-transformation are a bit tricky to find.

BR Frank

1 Like

i need some help with the https://www.zigbee2mqtt.io/devices/E1603_E1702.html

This is my Thing

 Thing topic WalloutletCoffeeDevice "Koffie" {
            Type string : state "state"         [ stateTopic="zigbee2mqtt/WalloutletCoffeeDevice/state"] 
            Type string : update_available "update_available"     [ stateTopic="zigbee2mqtt/WalloutletCoffeeDevice/update_available"]   
            Type number : linkquality      "linkquality"     [ stateTopic="zigbee2mqtt/WalloutletCoffeeDevice/linkquality" ]     
    

This is my item

// WalloutletCoffeeDevice
Switch      GF_WalloutletCoffeeDevice_Button_Press              "KoffieAutomaat"                     <button>            (GF_DiningRoom, gButton)     ["Button"]      {channel="mqtt:topic:c99ba5fd:WalloutletCoffeeDevice:state"} 
Number      GF_WalloutletCoffeeDevice_Button_Link               "Link kwalietijd"                 <link>              (gButton)                       ["link"]        {channel="mqtt:topic:c99ba5fd:WalloutletCoffeeDevice:linkquality" }
String      GF_WalloutletCoffeeDevice_Button_update_available   "Update beschhikbaar [%s]"      <softwareupdate>            (gButton)              ["update_available"]     {channel="mqtt:topic:c99ba5fd:WalloutletCoffeeDevice:update_available"} 

The update status and link status is working. But i cant get the switch working.

And does any know how to make a button to update a device software? https://www.zigbee2mqtt.io/information/ota_updates.html

Your switch channel appears to have no commandTopic

oops different device. :frowning:

confused with E1524.

As @rossko57 said, you need a command topic. And you should use a switch channel, not a string. You need something like this:

Type switch : state "state" [ stateTopic = "zigbee2mqtt/WalloutletCoffeeDevice/state", commandTopic = "zigbee2mqtt/WalloutletCoffeeDevice/set/state", on="ON", off="OFF" ]

If you look in the first post, you will find several examples. Many types of devices are covered. Your device is similar to the Osram Plug.

Thank you! i understand it better now. Thought Its is not updating the state. I have to look further.

Edit it works now. I had to restart my pi.

In the past I formatted within the thing, but now I split it and use transformations. With this I only need the colorpicker on the sitemap as it has the toggle already built in. Here is an example

Thing

Thing topic wohnz_Innr_Licht_Stehlampe_Holz "Licht Innr Stehlampe Holz" {
    Channels:
        Type switch : toggleonoff               [ commandTopic="zigbee2mqtt/XX/set", on="ON", off="OFF" ]
        Type colorHSB : colorHSB                [ commandTopic="zigbee2mqtt/XX/set", transformationPatternOut="JS:HSBtoRGB.js" ]
    }

Transformation HSBtoRGB.js

(function (x) {
    if (x=="ON" || x=="INCREASE") {
        return '{"state":"ON","transition":0.3}'
    } else if (x=="OFF" || x=="DECREASE") {
        return '{"state":"OFF","transition":0.3}'
    } else {
        var tex = x.split(',');
        s = parseInt(tex[1]);
        v = parseInt(tex[2]);
        h = parseInt(tex[0]);
    
        h=(!h ? 0 : h/360.0);
        s=(!s ? 0 : s/100.0);
        v=(!v ? 0 : v/100.0);
        i = Math.floor(h * 6);
        f = h * 6 - i;
        p = v * (1 - s);
        q = v * (1 - f * s);
        t = v * (1 - (1 - f) * s);
        switch (i % 6) {
            case 0: r = v, g = t, b = p; break;
            case 1: r = q, g = v, b = p; break;
            case 2: r = p, g = v, b = t; break;
            case 3: r = p, g = q, b = v; break;
            case 4: r = t, g = p, b = v; break;
            case 5: r = v, g = p, b = q; break;
        }
        return '{"brightness":'+ Math.round(v * 255)+',"color":{"rgb":"'+ Math.round(r * 255)+','+ Math.round(g * 255)+','+Math.round(b * 255)+'"},"transition":0.7}'
    }
})(input)
2 Likes

It would be very nice if every one that has a working configuration. Submit it to the zigbee2mqtt GitHub documentation. It is very easy to do. You need to make a Git Hub account.

Search for the device on https://www.zigbee2mqtt.io/information/supported_devices.html

Open the device page. *To contribute to this page, edit the following file

So, i shared my configuration for an MCCGQ01LM Xiaomi MiJia door & window contact sensor (contact) as you suggested on the zigbee2mqtt device page. Lets see if and when it will be merged.
Update: It is already merged. So if someone can check if it is appropriated described.

3 Likes

Danke!

:slight_smile:

Dr. Frank Looff

Frühlingstrasse 8

22525 Hamburg

01523/6366477

BlueMail for Android herunterladen

I have noticed that it allows to indicate the expiration time

  • Xiaomi Aqara human body movement and illuminance sensor RTCGQ11LM thing:
    Thing topic TEMD "TEMD"  @ "TE"
    {
        Channels:
            Type switch : occupancy "occupancy" [ stateTopic = "zigbee2mqtt/TEMD/occupancy", on="true", off="false"  ]
            Type number : illuminance "illuminance" [ stateTopic = "zigbee2mqtt/TEMD/illuminance" ]            
            Type number : voltage "voltage" [ stateTopic = "zigbee2mqtt/TEMD/voltage" ]     
            Type number : battery "battery" [ stateTopic = "zigbee2mqtt/TEMD/battery" ]     
            Type number : linkquality "linkquality" [ stateTopic = "zigbee2mqtt/TEMD/linkquality" ]     
    }
``` Type switch : occupancy "occupancy" [ stateTopic = "zigbee2mqtt/TEMD/occupancy", on="true", off="false" , expire="1m"  ]

I have noticed that it allows to indicate the expiration time

Nice try, but it didn’t work, at least not for me. I changed my thing file, as you suggested to set the expiration time to 1 Minute (which by the way is the most shorted value you can use) and it still expires after 90 seconds which is the default. I mean it is possible, to change the expiration time as described on the manual page, but obviously not like you have described here. It is still possible, that I did something wrong. But I added your , expire="1m" to my working configuration and than commented out the thing in my thing file, saved it and after that removed comment and saved it again.

By the way, this is the workaround instead of restarting OpenHAB when making changes to an exisiting thing by first deleting (commenting it out) the thing and than save the thing file and removing the comment and saving it again, which obviuously recreates a thing instead of just restarting it.

Do you have the Expire binding installed?

By the way expire binding applies over ITEMS not in thing File, if I correctly remember.

I do not think, this will work as expected. Just if you expire before the “occupancy = false” message is sent. If you set it to more than the usual 90 seconds, the standard message will switch the switch off before it expires.

If you want to change the expiration time, you have to to send this as a commandTopic. It will persisted. I remember this feature from the Xiaomi Binding…

Not exactly sure about the command in detail with Mqtt , but definitely not like the code above.

See at zigbee2mqtt: https://www.zigbee2mqtt.io/devices/RTCGQ01LM.html

  • occupancy_timeout : Timeout (in seconds) after the occupancy: false message is sent. If not set, the timeout is 90 seconds. When set to 0 no occupancy: false is send.

IMPORTANT : occupancy_timeout should not be set to lower than 60 seconds. The reason is this: after detecting a motion the sensor ignores any movements for exactly 60 seconds. In case there are movements after this, a new message ( occupancy: true ) will be sent and the sensor will go for one more minute sleep, and so on. This is expected behaviour (see #270). To work around this, ahardware modification is needed.