Help sending nodes commands from openhab



  • 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.



  • 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.



  • @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)..



  • 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 😛 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.



  • @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}".


Log in to reply
 

Suggested Topics

  • 22
  • 2
  • 10
  • 135
  • 3
  • 5

1
Online

11.4k
Users

11.1k
Topics

112.7k
Posts