I’m trying to use a switch item in openhab2 to publish to mqtt.
If i manually publish stat/sonoff/POWER openhab displays the correct switch state.
General publishing of changes appears to be working with the eventbus binding.
I cannot get openhab to publish any state changes for my switch.
This one works using the command format…the “mymosquitto/ParticlePi/DimmerOn” is my MQTT address …The command I think is the state of the switch position…and the number is what my device sees as the subject posted …it actually works …you can subscribe to the subject using " mqtt tool " app and toggle the buttons to see if it’s posting if it posts and you see it but nothing happens you need to check on your Arduino or whatever your using to make sure your setup for s right
If you want an external status sent to OpenHAB …make a new line and have Mqtt send the info … using the mqtt in but you’ll need a new line in your sitemap as a number item …
Like
(Sitemap)
Number item switch_status
(Items)
Number switch_status “Kitchen Switch [%.2f]” {mqtt="<[mosquitto:stat/sonoff/Power:state:default]"}
So the mqtt configuration seems to be at least syntactically correct.
Even my old configuration appears to be alright as it reports 1 subscriber and 2 publishers.
I’ve copied @jade7272 example and only changed the broker part to see if there was something wrong with my syntax.
My mqtt.cfg file is working already as the eventbus is able to publish through it.
I was using mosquitto for something else and was having compatibility issues so I just put in mymosquito …it could be anything I’m thinking …as long as your consistent …I am on my iPad and it’s hard to copy the config files through the app I’m using …You are right about the on and off for some reason it worked anyway …strange …I’ll try in a sec
############################################################################################Transport configurations############################################################################################################################# MQTT Transport ######################################## Define your MQTT broker connections here for use in the MQTT Binding or MQTT# Persistence bundles. Replace with a id you choose.## URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883mqtt:mymosquitto.url=tcp://localhost:1883# Optional. Client id (max 23 chars) to use when connecting to the broker.# If not provided a default one is generated.#mqtt:.clientId=
You know when I have my start_debug.sh going it doesn’t seem to go out either but then my leds do what they are supposed to do …do you have a mqtt tool you can subscribe to ? That’s how I found out the mistakes I made when posting to the server …you can also use node red as a test bed subscribing to the mqtt stream and tweeting the information it receives
I’ve found whats causing my issue:
I’ve been testing my sitemap using habmin exclusively. Today I tried to just use a plain button without anything hooked up and it didn’t cause any events on click.