Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Controllers
  3. OpenHAB
  4. Help sending nodes commands from openhab

Help sending nodes commands from openhab

Scheduled Pinned Locked Moved OpenHAB
5 Posts 2 Posters 1.4k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • fifoF Offline
    fifoF Offline
    fifo
    wrote on last edited by fifo
    #1

    Communication Path
    openhab 2.2 snapshot --> mosquitto (Broker) --> mysensors mqtt gateway --> mysensors node

    I can send the following command to my mosquitto broker and it works with no issue to turn a node on and off.

    mosquitto_pub -t 'mysgateway-in/5/0/1/0/2' -m 'OFF'
    mosquitto_pub -t 'mysgateway-in/5/0/1/0/2' -m 'ON'
    

    I am using HabPanel and set up a switch to basically toggle from OFF to ON

    The OpenHab item is "mqttsw1"

    my items file looks like this

    Switch mqttsw1 "Switch 1" (all) {mqtt=">[mysgateway-in/5/0/1/0/2:command:*:default],>[mysgateway-in/5/0/1/0/2:command:off:default,<[mysgateway-in/5/0/1/0/2:command:*:default]]"}
    
    

    My mqtt-eventbus.cfg looks like this. I believe the issue is in the commandPublishTopic and if I comment out the existing line and replace it with the one right below I can get at least that switch to work.

    broker=mosquitto
    
    # When available, all status updates which occur on the openHAB event bus are published to the provided topic. The message content will
    # be the status. The variable ${item} will be replaced during publishing with the item name for which the state was received.
    #statePublishTopic=
    
    # When available, all commands which occur on the openHAB event bus are published to the provided topic. The message content will be the
    # command. The variable ${item} will be replaced during publishing with the item name for which the command was received.
    commandPublishTopic=mysgateway-in/${item}
    #commandPublishTopic=mysgateway-in/5/0/1/0/2
    
    # When available, all status updates received on this topic will be posted to the openHAB event bus. The message content is assumed to be
    # a string representation of the status. The topic should include the variable ${item} to indicate which part of the topic contains the
    # item name which can be used for posting the received value to the event bus.
    stateSubscribeTopic=mosquitto/stateUpdates/${item}/state
    
    # When available, all commands received on this topic will be posted to the openHAB event bus. The message content is assumed to be a
    # string representation of the command. The topic should include the variable ${item} to indicate which part of the topic contains the
    # item name which can be used for posting the received value to the event bus.
    commandSubscribeTopic=mosquitto/commandUpdates/${item}/command
    

    Here is what I get when I subscribe to the topic with the eventbus file above.

    Client mosqsub/12310-raspberry received PUBLISH (d0, q0, r0, m0, 'mysgateway-in/mqttsw1', ... (3 bytes))
    OFF
    Client mosqsub/12310-raspberry received PUBLISH (d0, q0, r0, m0, 'mysgateway-in/mqttsw1', ... (2 bytes))
    ON
    
    

    Of course it doesnt work because it is using the name of the device instead of "mysgateway-in/5/0/1/0/2" for this instance.

    Any clue what I can be doing wrong? I just cant seem to find anything on the web to help me out with this and I am sure its something simple.

    1 Reply Last reply
    0
    • rozpruwaczR Offline
      rozpruwaczR Offline
      rozpruwacz
      wrote on last edited by rozpruwacz
      #2

      what is this mqtt-eventbus.cfg file for ? and what is mqtt eventbus ? I have all commented out in this file and everything is working fine form me.

      1 Reply Last reply
      0
      • fifoF Offline
        fifoF Offline
        fifo
        wrote on last edited by fifo
        #3

        @rozpruwacz said in Issue with item names when sending my nodes a command from openhab to my arduino -> mysensors mqtt gateway / openhab 2.2 snapshot / mosquitto:

        what is this mqtt-eventbus.cfg file for

        Ok I am by no means an expert, but what I understand it to be is to get all OpenHab events to look like an MQTT message and to thus allow you to update status of items in OpenHab using MQTT messages

        So I have my GUI (HabPanel) sending messages to my broker (Raspberry Pi3) who sends info to my gateway (Arduino Nano) who in turn sends the data to my sensor whatever it may be.

        It also works in reverse (this reverse part is working as I can get status update from some temp and PIR sensors I have running already)..

        1 Reply Last reply
        0
        • rozpruwaczR Offline
          rozpruwaczR Offline
          rozpruwacz
          wrote on last edited by
          #4

          You have two brokers ? I thought that there must be one broker, why do You need two brokers ? I can't help You with your setup because actually I don't understand what You are doing :P But why You do it this way ? I have it like that: HabPanel is just an UI for OpenHAB, so I don't send anything from HabPanel just controll OH items. Some of them are mqtt items and they send/receive data to/from mosquitto broker on raspberry pi, which in turn sends to mysensors gateway. And this is working perfectly.

          1 Reply Last reply
          0
          • fifoF Offline
            fifoF Offline
            fifo
            wrote on last edited by fifo
            #5

            @rozpruwacz said in Issue with item names when sending my nodes a command from openhab to my arduino -> mysensors mqtt gateway / openhab 2.2 snapshot / mosquitto:

            t help You with your setup because actually I don't understand what You are doing But why You do it this way ? I have it like that: HabPanel is just an UI for OpenHAB, so I don't send anything from HabPanel just controll OH items. Some of them are mqtt items and they send/receive data to/from

            Oh sorry I meant Arduino Nano is my gateway not a broker ( I edited above post to fix). I only have one broker which is the Raspberry Pi. So its basically the same thing but I want to send controls to my sensors via the HabPanel. I can receive from the sensors with no problems. It's the sending that doesnt work when I use the variable "${item}".

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            38

            Online

            11.7k

            Users

            11.2k

            Topics

            113.1k

            Posts


            Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • MySensors
            • OpenHardware.io
            • Categories
            • Recent
            • Tags
            • Popular