micware
(Michiel)
1
Happy new year…
I love OH 3, good time to start over from scrats
I’m struggling whit the integration of MQTT “Things” in Openhab 3.0.
My Broker (mosquito) is running on the same Raspberry PI as openhab 3.
With the tool MQTT.fx I can Publish and Subscribe to topics.
In OH3 I made a “Thing” that connected to my broker and has the status online
I made a “Generic MQTT Thing” for a hue bulb with a channel named “Switch”
Incoming Value Transformations : JSONPATH:$.state
Outgoing Value Transformation : [“state” : “%S”]
MQTT Thing:
UID: mqtt:topic:b8be661fe1:Studeerkamer_Hue_white
label: Studeerkamer Hue white
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:b8be661fe1
channels:
- id: switch
channelTypeUID: mqtt:switch
label: Switch on/off
description: ""
configuration:
commandTopic: zigbee2mqtt/Studeerkamer_Hue_white/set
transformationPatternOut: '["state" : "%S"]'
stateTopic: zigbee2mqtt/Studeerkamer_Hue_white
transformationPattern: JSONPATH:$.state
event.log
2021-01-03 14:26:24.385 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'StudeerkamerHuewhite_Switchonoff' changed from OFF to ON
Openhab.log
2021-01-03 14:11:59.112 [WARN ] [t.generic.ChannelStateTransformation] - Transformation service ["STATE" for pattern "%S"] not found!
When I publish {“state” : “ON”} or {“state” : “OFF”} to the topic “zigbee2mqtt/Studeerkamer_Hue_white/set” with MQTT.fx tool it is working
I think something is going wrong with the Outgoing Transformation.
I’m new to OH3, MQTT and transformations
Any advice / examples
Thanks…
Instead of transformationPatternOut
you want formatBeforePublish
.
Not quite sure how it’s implemented via YAML, but in a Things file:
formatBeforePublish = "[\"state\":\"%s\"]"
1 Like
micware
(Michiel)
3
Hi thanx for your response
I now use the property Outgoing value format.
When i flip the swicht i see this in the even.log , but i don’t see anything in openhab.log
And my bulb is nog going on or off
I will experiment some more
rossko57
(Rossko57)
4
Use your tool to see what openHAB is sending
micware
(Michiel)
5
that is a good one Ross, I had not yet thought about that.
When i use {“sate” : “%S”} I get back:
{
"state" : "ON"
}
And my light goos on. so far so goed.
But hitting the switch again dus not generate a OFF command {“state” : OFF"}
But i learned a lot in a view houwers and will go on
micware
(Michiel)
7
@hafniumzinc hafniumzinc : that is exactly what I experience.
On Chrome version 87.0.4280.101 on Android 7.0 is working correct and is sending ON and OFF command
I added my experience to the Github issue #731
1 Like
micware
(Michiel)
9
thx,
I find that out the hard way , but it’s working now . minus the bug in OH 3:
Switch OFF Command stuck · Issue #731 · openhab/openhab-webui · GitHub
Ah, cheers. Presumably by virtue of encasing the string in single quotes, the double quotes don’t need escaping. Good to know!
1 Like
Can you post the technical information for you openHAB that didn’t work. It will help the devs to pinpoint issues.
Goto Help & About / Technical Information / View Details / Copy
micware
(Michiel)
12
runtimeInfo:
version: 3.0.0
buildString: Release Build
locale: en
systemInfo:
configFolder: /etc/openhab
userdataFolder: /var/lib/openhab
logFolder: /var/log/openhab
javaVersion: 11.0.9.1
javaVendor: Raspbian
osName: Linux
osVersion: 5.4.79-v7l+
osArchitecture: arm
availableProcessors: 4
freeMemory: 26119936
totalMemory: 131072000
bindings:
- astro
- miio
- mqtt
- remoteopenhab
- zwave
clientInfo:
device:
ios: false
android: false
androidChrome: false
desktop: true
iphone: false
ipod: false
ipad: false
edge: false
ie: false
firefox: false
macos: false
windows: true
cordova: false
phonegap: false
electron: false
nwjs: false
webView: false
webview: false
standalone: false
os: windows
pixelRatio: 1.5
prefersColorScheme: dark
isSecureContext: false
locationbarVisible: true
menubarVisible: true
navigator:
cookieEnabled: true
deviceMemory: N/A
hardwareConcurrency: 8
language: nl-NL
languages:
- nl-NL
- nl
- en-US
- en
onLine: true
platform: Win32
screen:
width: 2560
height: 1440
colorDepth: 24
support:
touch: false
pointerEvents: true
observer: true
passiveListener: true
gestures: false
intersectionObserver: true
themeOptions:
dark: dark
filled: true
pageTransitionAnimation: default
bars: light
homeNavbar: default
homeBackground: default
expandableCardAnimation: default
userAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,
like Gecko) Chrome/87.0.4280.88 Safari/537.36
timestamp: 2021-01-04T19:06:57.275Z