Hi
Can anyone tell what to put into “Incomming Value Transformation” in Paper UI, if i want to get the “click”, when the payload in MQTT.fx looks like this: {“battery”:100,“voltage”:3052,“linkquality”:60,“click”:“single”}
Thanks for your help - i am new into this.
/Torben
JSONPATH:$.click
Ensure you have the JSONPath transformation installed: PaperUI -> Add-ons -> Transformations -> JSONPath Transformation -> Install
Thanks for quick reply.
I did not get the “click” working BUT the “battery” and “linkquality” works fine - NICE - thanks again!
I defined the “click”-item as STRING - should it not be like that?
/Torben
I’m not too familiar with setting this up via PaperUI, but you need to make sure that your openHAB thing channel is also a string, in addition to your openHAB item.
Out of interest, what device is this?
You are quite right - there was a mismatch - so now it is woking - FANTASTIC!
The device is a Xiaomi MiJia wireless switch (WXKG01LM) - got several other diveces working now, thanks to you.
If i rahter would like to setup the items in config-files will it be hard for you to show me what the line should look like?
Tanks again
/Torben
Sure - that’s also my preferred method! I presume you’re using zigbee2mqtt? What is the friendly name of your device? And the IP address of your MQTT broker?
Thanks a lot!
Yes i am using zigbee2mqtt.
Friendly name: 001
IP: 192.168.86.10 (Port 1883)
Could you also make the line for at command for a IKEA driver for a ledpanel.
Freindly name: 006
Payload: “brightness”
/Torben
The following assumes that nothing has previously been setup via PaperUI - having duplicate things and items causes all sorts of confusion. I would recommend getting rid of all things and items created using PaperUI!
Enable attribute output from zigbee2mqtt
Configure zigbee2mqtt so that it outputs strings, rather than JSON: Zigbee2mqtt revisited: No more ugly transformations
In short, add the following to the end of your zigbee2mqtt configuration.yaml:
experimental:
output: attribute
Create a bridge to your MQTT broker
Create a file in your things folder called bridge.things. Add the following (I’m assuming you’re using Mosquitto):
Bridge mqtt:broker:MosquittoMqttBroker "Mosquitto MQTT Broker" [
host="192.168.86.10",
secure=false,
port=1883,
clientID="OpenHAB2"
]
Create things and channels to the devices
Create a file in your things folder called zigbee.things. Add the following into it (there’s a bit of guessing involved on my part, but this should be close!):
Thing mqtt:topic:sw001 "WXKG01LM switch" (mqtt:broker:MosquittoMqttBroker) {
Channels:
Type string : click "Click" [
stateTopic = "zigbee2mqtt/001/click"
]
Type number : battery "Battery level" [
stateTopic = "zigbee2mqtt/001/battery"
]
Type number : linkquality "Link quality" [
stateTopic = "zigbee2mqtt/001/linkquality"
]
}
Thing mqtt:topic:swLEDPanel "LEDPanel" (mqtt:broker:MosquittoMqttBroker) {
Channels:
Type switch:switch "Power Switch" [
stateTopic="zigbee2mqtt/006/state",
commandTopic="zigbee2mqtt/006/set",
on="ON",
off="OFF"
]
Type dimmer:dimmer "Dimmer" [
stateTopic="zigbee2mqtt/006/brightness",
commandTopic="zigbee2mqtt/006/set/brightness",
min=0,
max=255,
step=1
]
}
Create items
Create a file in your items folder called zigbee.items. Add the following into it:
String str001Click "Click" {channel="mqtt:topic:sw001:click"}
Number n001Battery "Battery" {channel="mqtt:topic:sw001:battery"}
Number n001LinkQuality "Link Quality" {channel="mqtt:topic:sw001:linkquality"}
Switch sLEDPanel "LEDPanel Light" { channel="mqtt:topic:swLEDPanel:switch" }
Dimmer dLEDPanel "LEDPanel dimmer" {channel="mqtt:topic:swLEDPanel:dimmer"}
Thanks a lot - i will try!
/Torben
I am using the “MQTT Broker Moquette” (misc-mqttbroker - 2.5.5) is that correct?
That’s the in-built MQTT broker than comes with OpenHAB. I don’t know anything about it, other than it will be deprecated in the next major version of OpenHAB. If you are just starting out I would recommend removing Moquette and installing and using Mosquitto.
OK - now i am using a user/password - is it better/easier without?
/Torben
Makes no difference really. If you use it, change bridge.things to:
Bridge mqtt:broker:MosquittoMqttBroker "Mosquitto MQTT Broker" [
host="192.168.86.10",
secure=false,
username="yourusername",
password="yourpassword",
port=1883,
clientID="OpenHAB2"
]
Can the Msquitto bee setup in Paper UI
Mosquitto is completely independent of OpenHAB. Once you have installed it outside of OpenHAB, all you need to do is create the bridge.things from my previous post and you will have a connection between OpenHAB and Mosquitto - no need for PaperUI.
I have now installed the Mosquitto on the PI.
When i run npm start - i get:
zigbee2mqtt:error 2020-07-26 20:59:26: Not connected to MQTT server!
My mosquitto config file:
Place your local configuration in /etc/mosquitto/conf.d/
A full description of the configuration file is at
/usr/share/doc/mosquitto/examples/mosquitto.conf.example
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/log_dest file /var/log/mosquitto/mosquitto.log
allow_anonymous false
password_file /etc/mosquitto/pwfile
listener 1883
Can you see what is wrong - is there a command to check the status of the mosquitto?
/Torben
Is that actually what your configuration file looks like?! Doesn’t seem right at all!
What instructions did you use to install Mosquitto? It should be installed as a service, which means it will start automatically. To check if it’s running:
sudo systemctl status mosquitto
If I run the above, I get:
pi@raspberrypi:~ $ sudo systemctl status mosquitto
● mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
Loaded: loaded (/etc/init.d/mosquitto; generated; vendor preset: enabled)
Active: active (running) since Wed 2020-07-15 22:28:39 BST; 1 weeks 3 days ago
Docs: man:systemd-sysv-generator(8)
Process: 370 ExecStart=/etc/init.d/mosquitto start (code=exited, status=0/SUCCESS)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/mosquitto.service
└─457 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
Jul 15 22:28:38 raspberrypi systemd[1]: Starting LSB: mosquitto MQTT v3.1 message broker...
Jul 15 22:28:39 raspberrypi mosquitto[370]: Starting network daemon:: mosquitto.
Jul 15 22:28:39 raspberrypi systemd[1]: Started LSB: mosquitto MQTT v3.1 message broker.
if i run it i get:
● mosquitto.service
Loaded: masked (Reason: Unit mosquitto.service is masked.)
Active: inactive (dead)
I use this for installation:
/Torben
I done so - now i get:
● mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
Loaded: loaded (/etc/init.d/mosquitto; generated)
Active: active (exited) since Sun 2020-07-26 21:25:16 BST; 3min 18s ago
Docs: man:systemd-sysv-generator(8)
Process: 3018 ExecStart=/etc/init.d/mosquitto start (code=exited, status=0/SUCCESS)Jul 26 21:25:16 openhab systemd[1]: Starting LSB: mosquitto MQTT v3.1 message broker…
Jul 26 21:25:16 openhab systemd[1]: Started LSB: mosquitto MQTT v3.1 message broker.
Does this mean that the Misquitto i running?
But i still can not connect:
zigbee2mqtt:error 2020-07-26 21:31:45: Not connected to MQTT server!