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. OpenHab mqtt binding only one topic

OpenHab mqtt binding only one topic

Scheduled Pinned Locked Moved OpenHAB
mqtt topicopenhab
5 Posts 2 Posters 5.7k 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.
  • M Offline
    M Offline
    mothpaul
    wrote on last edited by
    #1

    I have OpenHab up and running. I have mosquito up and running. I have a switch item with a mqtt binding that works. When I try to add another switch item with a different mqtt topic, the mqtt binding process never picks it up. But if i comment out the first switch item, then the second switch will get picked up with mqtt binding. Each one will work indiviudally, but I can't get both to work simulanieously. Any advice would be appreciated.

    1 Reply Last reply
    0
    • gaduG Offline
      gaduG Offline
      gadu
      wrote on last edited by
      #2

      What does your items and your sitemap config look like?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mothpaul
        wrote on last edited by
        #3

        Thank you for looking at this. Right now the items file shows as

        /* Office Items*/
        Switch itm_reset_office_count "Reset Library Count" (gr_office)
        Number itm_office_hit "Office PIR Hits [%d PIR Hits]" (gr_office)
        DateTime itm_office_hit_tstamp "Last Updated [%1$tA, %1$tI:%1$tM %1$Tp]" (gr_office)
        Number itm_office_mqtt_string {mqtt="<[officepi:office_string:state:default]"} (gr_office)
        Switch itm_office_mqtt_motion_switch {mqtt="<[officepi:office_motion:command:default]"} (gr_office)

        The sitemap file has:

        Group label="Office" item=gr_office
        {
        Text item=itm_office_hit
        Text item=itm_office_hit_tstamp
        Switch item=itm_reset_office_count
        Switch item=itm_office_mqtt_string label="What my Raspberry Pi said:" mappings=[1=Yes, 2=No, 3=Maybe]
        Switch item=itm_office_mqtt_motion_switch label="motion switch"
        } //END OFFICE FRAME

        With this setup, I can publish mqtt messages with mosquito on my Raspberry Pi to
        highlight the itm_office_mqtt_string Switch in OpenHab Display: Yes, No or Maybe. But the I
        cannot publish mqtt messages to the itm_office_mqtt_motion_switch, OpenHab does
        not get them. Moreover, when I toggle the switch on the OpenHab Display, I get:

        [WARN ] [.w.internal.servlet.CmdServlet:100 ] - Received command 'TOGGLE' for item 'itm_office_mqtt_motion_switch', but the item does not exist in the registry

        [ERROR] [o.u.i.items.ItemUIRegistryImpl:411 ] - Cannot retrieve item 'itm_office_mqtt_motion_switch' for widget org.openhab.model.sitemap.Switch

        If I comment out the itm_office_mqtt_string Switch Item, then I can publish mqtt
        messages with mosquito to toggle the itm_office_mqtt_motion_switch Item on
        OpenHab Display to ON or OFF. I can also toggle the switch on the OpenHab Display without
        error.

        Also when I comment out the itm_office_mqtt_string, and close the item file this occurs:

        Refreshing model 'mini.items'
        [DEBUG] [i.internal.GenericItemProvider:154 ] - Processing binding configs for items from model 'mini.items'
        [DEBUG] [m.i.MqttGenericBindingProvider:73 ] - Removing message consumers for item itm_office_mqtt_string
        [DEBUG] [o.i.t.m.i.MqttBrokerConnection:505 ] - Unsubscribing message consumer for topic 'office_string' from broker 'officepi'
        [DEBUG] [m.i.MqttGenericBindingProvider:106 ] - Removing message publishers for item itm_office_mqtt_string
        [DEBUG] [b.mqtt.internal.MqttItemConfig:71 ] - Loaded MQTT config for item 'itm_office_mqtt_motion_switch' : 1 subscribers, 0 publishers
        [DEBUG] [o.i.t.m.i.MqttBrokerConnection:476 ] - Starting message consumer for broker 'officepi' on topic 'office_motion'
        [DEBUG] [i.internal.GenericItemProvider:133 ] - Read items from model 'mini.items'

        Both work individually, but the OpenHab doesn't bind both topic at the same time. Somehow when the first mqtt item is picked up the second one isn't, but if I comment out the first one, then the second one is picked up.

        I don't understand what I should do to make both work. Any suggestions appriciated.

        1 Reply Last reply
        0
        • gaduG Offline
          gaduG Offline
          gadu
          wrote on last edited by
          #4

          Not sure about this, but could it be the syntax for the mapping that don't work?
          Switch item=itm_office_mqtt_string label="What my Raspberry Pi said:" mappings=[1=Yes, 2=No, 3=Maybe]

          Got this from here... Note the spaces and quotes.
          Mappings can be used to let the user chose an item from a list.
          Syntax:
          mappings = [ "value1"="name1", "value2"="name2" ]

          Quotes can be omitted if the value string and name string do not contain spaces.
          Examples:
          mappings = [ "1"="ON", "0"="OFF" ]
          mappings = [ 1="BBC", 2="CNN", 3="BLOOMBERG" ]

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mothpaul
            wrote on last edited by
            #5

            I really don't think this is a sitemap issue. I don't know the language well enough to speak of this but the error I am getting is

            [ERROR] [o.u.i.items.ItemUIRegistryImpl:411 ] - Cannot retrieve item 'itm_office_mqtt_motion_switch' for widget org.openhab.model.sitemap.Switch

            This makes me think it is an item issue not a sitemap issue. I captured this startup information from the log file:

            [DEBUG] [.b.mqtt.internal.MqttActivator:34 ] - MQTT binding has been started.
            [DEBUG] [i.internal.GenericItemProvider:334 ] - Start processing binding configuration of Item 'itm_office_mqtt_string (Type=NumberItem, State=Uninitialized)' with 'MqttGenericBindingProvider' reader.
            [DEBUG] [b.mqtt.internal.MqttItemConfig:71 ] - Loaded MQTT config for item 'itm_office_mqtt_string' : 1 subscribers, 0 publishers
            [DEBUG] [o.i.t.m.i.MqttBrokerConnection:476 ] - Starting message consumer for broker 'officepi' on topic 'office_string'
            [DEBUG] [m.internal.MqttEventBusBinding:61 ] - MQTT: Activating event bus binding.

            It shows the process for binding the itm_office_mqtt_string Item, but there is no mention of the binding of the itm_office_mqtt_motion_switch Item. Should there be? If so, anyone know why it might not be there?

            As I said above, when I comment out the itm_office_mqtt_string Item in the items file, OpenHab refreshes (see below) and allows the itm_office_mqtt_motion_switch Switch Item to function.

            [INFO ] [c.internal.ModelRepositoryImpl:97 ] - Refreshing model 'mini.items'
            [DEBUG] [i.internal.GenericItemProvider:154 ] - Processing binding configs for items from model 'mini.items'
            [DEBUG] [m.i.MqttGenericBindingProvider:73 ] - Removing message consumers for item itm_office_mqtt_string
            [DEBUG] [o.i.t.m.i.MqttBrokerConnection:505 ] - Unsubscribing message consumer for topic 'office_string' from broker 'officepi'
            [DEBUG] [m.i.MqttGenericBindingProvider:106 ] - Removing message publishers for item itm_office_mqtt_string
            [DEBUG] [b.mqtt.internal.MqttItemConfig:71 ] - Loaded MQTT config for item 'itm_office_mqtt_motion_switch' : 1 subscribers, 0 publishers
            [DEBUG] [o.i.t.m.i.MqttBrokerConnection:476 ] - Starting message consumer for broker 'officepi' on topic 'office_motion'
            [DEBUG] [i.internal.GenericItemProvider:133 ] - Read items from model 'mini.items'

            The sitemap works when the item can be retrieved, but I don't know why only one item is being retrieved, not both.

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


            34

            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