Zigbee2mqtt revisited: No more ugly transformations

What I do with a new Zigbee device, after pairing with zigbee2mqtt, is use MQTT Explorer to ‘sniff’ what the new device parameters are.

Sometimes you’ll also have to command the device to see what the ‘extra’ parameters are, such as double or triple button presses, though I don’t know if that’s necessary for a bulb.

1 Like

Yeah that’s what I do with my sensors… But with the Hue Bulbs I don’t have a hue hub or remote so now way to control the bulbs except for using Zigbee2MQTT…

Look for your device in this table - it includes the modes (and therefore the commands) which are supported.

Either way, surely when you turn your bulb on (as in, supply it with power), it will initially communicate with zigbee2mqtt, and therefore you’ll be able to pick up most parameters?

Yeah that was what I thought, but all I see in the Zigbee2MQTT logs is the bulb “announcing” itself… It doesn’t send anything else about itself…

Ah, but I was on about using something like MQTT Explorer or mqtt.fx to do the sniffing, not looking in the zigbee2mqtt logs…

I’ve never used Hue bulbs, so they may be different, but I’ve used this method successfully for two different types of IKEA Tradfri bulbs.

I also have an Osram RGBW Bulb but unfortunately, your solution doesn’t work for me :frowning:

I have set the same “formatBeforePublish” pattern but only the first value of the color state is being published. For example the color state is 230,100,100 then only 230 is inserted as the %s inside the format.

I just found the solution:
When we have a comma separated string, the first %s in the format represents the first value, the second %s the second and so on.
Example (you can set the outgoing value format via PaperUI and it will do the necessary escapes for you):
color state: 230,100,100
outgoing value format: {"color": {"hsb": "%s"}}
result: {"color": {"hsb": "230"}}
… doesn’t work!

outgoing value format: {"color": {"hsb": "%s,%s,%s"}}
result: {"color": {"hsb": "230,100,100"}}
… exactly what we need :slight_smile:

I also made a pull request to update the readme of the mqtt-binding.

3 Likes

Hello.

I have a problem can you help ? about

  • Osram SmartPlug thing:

    Thing topic SZLV “SZLV” @ “SZ”

can you tell me why when i remove this from the line it works " @ “SZ”` "

i dont know were to find any thing about it ,becourse i dont know what it do ?

I hope you can help Simon . :slight_smile: I know it`s a mqtt thing problem but ?

PS : can you show some of your zigbee sitemap ? i have it working i paperui and shows up in log fine ,but i can`t get anything to show up on sitemap ??

HELLO.

Does anybody know why in sitemap i have values but no values in the app on android ??

Normal sitemap :

Android phone :

What happens if you tap on one of the names in the app? What is your Sitemap configuration?

Nothing happens when i push the lines ,its like its just a txt line and whit no values ?
maybe its a rookie mistake but i cant find any thing about it ,and it dose work on computer only not in app , not even the switch is there ???

    Frame label="sensor_1" icon="button" {	
	
Switch item=mqtt_topic_sensor_1_sensor_1_Occupancy    icon=switch              label="sensor_1 : [%s]"  valuecolor=[==ON="#a9f7b8", ==OFF="#f8a9ad"]
Text   item=mqtt_topic_sensor_1_sensor_1_battery      icon="battery"           label="Battery [%.0f %%]"
Text   item=mqtt_topic_sensor_1_sensor_1_voltage      icon="battery"           label="Voltage [%.0f mV]" 
Text   item=mqtt_topic_sensor_1_sensor_1_linkQuality  icon="qualityofservice"  label="Link quality [%.0f]" 
}

	Frame label="sensor_2" icon="button" {	
	
Switch item=mqtt_topic_sensor_2_sensor_2_Occupancy    icon=switch              label="sensor_2 : [%s]"  valuecolor=[==ON="#a9f7b8", ==OFF="#f8a9ad"]
Text   item=mqtt_topic_sensor_2_sensor_2_battery      icon="battery"           label="Battery [%.0f %%]"
Text   item=mqtt_topic_sensor_2_sensor_2_voltage      icon="battery"           label="Voltage [%.0f mV]" 
Text   item=mqtt_topic_sensor_2_sensor_2_linkQuality  icon="qualityofservice"  label="Link quality [%.0f]" 
}



	Frame label="Bar skab" icon="button" {	
Switch item=mqtt_topic_door_contact_1_door_contact_1_contact       icon=switch               label="Bar skab : [%s]"  mappings=[ON="Lukket", OFF="AAben"] valuecolor=[==ON="#a9f7b8", ==OFF="#f8a9ad"]
Text   item=mqtt_topic_door_contact_1_door_contact_1_battery       icon="battery"            label="Battery [%.0f %%]"
Text   item=mqtt_topic_door_contact_1_door_contact_1_voltage       icon="battery"            label="Voltage [%.0f mV]"
Text   item=mqtt_topic_door_contact_1_door_contact_1_linkQuality   icon="qualityofservice"   label="Link quality [%.0f]" 
}

	Frame label="Slik skab" icon="button" {	
Switch item=mqtt_topic_door_contact_2_door_contact_2_contact       icon=switch               label="Slik skab : [%s]"  mappings=[ON="Lukket", OFF="AAben"] valuecolor=[==ON="#a9f7b8", ==OFF="#f8a9ad"]
Text   item=mqtt_topic_door_contact_2_door_contact_2_battery       icon="battery"            label="Battery [%.0f %%]"
Text   item=mqtt_topic_door_contact_2_door_contact_2_voltage       icon="battery"            label="Voltage [%.0f mV]"
Text   item=mqtt_topic_door_contact_2_door_contact_2_linkQuality   icon="qualityofservice"   label="Link quality [%.0f]" 
}

	
Frame label="termostat_1"                                   icon="temperature" {
Text item=mqtt_topic_termostat_1_termostat_1_temperature   
Text item=mqtt_topic_termostat_1_termostat_1_humidity
Text item=mqtt_topic_termostat_1_termostat_1_Voltage        icon="battery"           label="Voltage [%.0f mV]"
Text item=mqtt_topic_termostat_1_termostat_1_linkQuality    icon="qualityofservice"	 label="Link quality [%.0f]" 
Text item=mqtt_topic_termostat_1_termostat_1_Battery        icon="battery"           label="Battery [%.0f %%]" 
}
		Frame label="termostat_2" icon="temperature" {
Text item=mqtt_topic_termostat_2_termostat_2_temperature 
Text item=mqtt_topic_termostat_2_termostat_2_humidity
Text item=mqtt_topic_termostat_2_termostat_2_Voltage label="Voltage [%.0f mV]" icon="battery"
Text item=mqtt_topic_termostat_2_termostat_2_linkQuality label="Link quality [%.0f]" icon="qualityofservice"	
Text item=mqtt_topic_termostat_2_termostat_2_Battery label="Battery [%.0f %%]" icon="battery"
	}
		
	Frame label="click_1" icon="button" {	
Switch item=mqtt_topic_click_1_click_1 icon=switch label="click 1 : [%s]"  valuecolor=[==ON="#a9f7b8", ==OFF="#f8a9ad"]
Text item=mqtt_topic_click_1_click_1_Reachable label="Button switch [MAP(switch2online.map):%s]" icon="wallswitch" valuecolor=["ON"="green", "OFF"="red", "NULL"="red", "-"="red"]
Text item=mqtt_topic_click_1_click_1_Battery label="Battery [%.0f %%]" icon="battery"
Text item=mqtt_topic_click_1_click_1_Voltage label="Voltage [%.0f mV]" icon="battery"
Text item=mqtt_topic_click_1_click_1_LinkQuality label="Link quality [%.0f]" icon="qualityofservice"
Text item=mqtt_topic_click_1_click_1_Click label="Last click action [%s]"
Text item=mqtt_topic_click_1_click_1_ClickDuration label="Last long click duration [%.0f]" icon="time"
}
            }

Is that your whole sitemap? Can you post the whole thing, in-between code fences?

```

In here like this
And like this

```

Do your Item names really repeat like termostat_2_termostat_2.

This should really be a separate thread: @moderators could we split from post 143?

Has anybody a working config for the Aqara Vibration Sensor - for whatever reason I fail.

Sure, but it won’t help you much as mqtt channel names are individual:

Number Xia_Vibr_01_Battery "Vibration Sensor [%d %%]" <battery> { channel="mqtt:topic:xia-vibration-01:aquara-vib-01-battery" }
Number Xia_Vibr_01_Linkquality "Vibration Link [%d]" <qualityofservice> { channel="mqtt:topic:xia-vibration-01:aquara-vib-01-linkquality" }
DateTime Xia_Vibr_01_lastseen "Vibration Lastseen [%1$td.%1$tm.%1$tY %1$tH:%1$tM]" { channel="mqtt:topic:xia-vibration-01:aquara-vib-01-last_seen" }
Number Xia_Vibr_01_Angle "Vibration Angle [%d]" { channel="mqtt:topic:xia-vibration-01:aquara-vib-01-angle" }
Number Xia_Vibr_01_Angle_X "Vibration Angle X [%d]" { channel="mqtt:topic:xia-vibration-01:aquara-vib-01-angle_x" }
Number Xia_Vibr_01_Angle_Y "Vibration Angle Y [%d]" { channel="mqtt:topic:xia-vibration-01:aquara-vib-01-angle_y" }
Number Xia_Vibr_01_Angle_Z "Vibration Angle Z [%d]" { channel="mqtt:topic:xia-vibration-01:aquara-vib-01-angle_z" }
Number Xia_Vibr_01_Angle_X_abs "Vibration Angle X abs [%d]" { channel="mqtt:topic:xia-vibration-01:aquara-vib-01-angle_x_absolute" }
Number Xia_Vibr_01_Angle_Y_abs "Vibration Angle Y abs [%d]" { channel="mqtt:topic:xia-vibration-01:aquara-vib-01-angle_y_absolute" }
Number Xia_Vibr_01_Strength "Vibration Stärke [%d]" { channel="mqtt:topic:xia-vibration-01:aquara-vib-01-strength" }
String Xia_Vibr_01_Action "Vibration Aktion [%s]" { channel="mqtt:topic:xia-vibration-01:aquara-vib-01-action" }

Edit: Here is an example for the action channel:

grafik

Thanks - works now perfectly.

1 Like

do you know how do i need to write it for textual configuragtion?
the last one that was working was: {“color”:{“hsb”: “%s”}}

i have set {“hsb”: “%s,%s,%s”}}, now i see 3 values:

but no mqtt message will be sent :frowning:

What device have you got?

Did you try adding the following to your channel?

formatBeforePublish="{\"color\":{\"hsb\": \"%s, %s, %s\"}}"

(just copied and updated from the linked post)

yes, this i smy thing konfiguration, but no mqtt message is send after i change the colour :confused:

Type string : color "Color" [ stateTopic="zigbee2mqtt/Osram_Livingroom/color-hsb", commandTopic="zigbee2mqtt/Osram_Livingroom/set/", formatBeforePublish="{\"color\":{\"hsb\": \"%s, %s, %s\"}}" ]