MQTT publish command?

Hi there,

Im just exploring OH3 and wow - this is just awesome! Great work!

Since there is no mysensors binding I have started to switch everything to mqtt, this is workin great for reading items but I could use some help for publishing

My things:

   Thing topic Wohnzimmersensor "Wohnzimmersensor" @ "Portable" {
    Channels: 
        Type number : temp "Temperature" [ stateTopic="MYS_pub/49/3/1/0/0", unit="°C" ]
        Type number : pressure "Pressure" [ stateTopic="MYS_pub/49/1/1/0/4"]
        Type number : humidity "Humidity" [ stateTopic="MYS_pub/49/2/1/0/1"]
        Type number : aqi "Air Quality" [ stateTopic="MYS_pub/49/4/1/0/37"]
        Type number : light "Light" [ stateTopic="MYS_pub/49/0/1/0/23"]
        Type number : switch_on "schalter an" [ commandTopic="MYS_sub/49/1/1/0/1"]
        Type number : switch_off "schalter aus" [ commandTopic="MYS_sub/49/1/1/0/2"]
}

Items:

Number    Wohnzimmer_BME680_humidity                 "Humidity Wohnzimmer BMW680[%.1f %%]"                       (g_Wohnzimmer_BME680_Sensor)    [ "Measurement" , "Humidity" ]       {channel="mqtt:topic:Mosquitto:Wohnzimmersensor:humidity"}
Number    Wohnzimmer_BME680_temperatur               "Temperatur Wohnzimmer BMW680[%.1f °C]"                     (g_Wohnzimmer_BME680_Sensor)    [ "Measurement" , "Temperature" ]    {channel="mqtt:topic:Mosquitto:Wohnzimmersensor:temp"}
Number    Wohnzimmer_AirQuality                      "AirQuality Wohnzimmer [%d]"                                (g_Wohnzimmer_BME680_Sensor)    [ "Measurement" , "CO2" ]            {channel="mqtt:topic:Mosquitto:Wohnzimmersensor:aqi"}
Number    Wohnzimmer_Licht_index                     "Wohnzimmer Helligkeit"                                     (g_Wohnzimmer_BME680_Sensor)    [ "Measurement" , "Light" ]          {channel="mqtt:topic:Mosquitto:Wohnzimmersensor:light"}
Switch    Wohnzimmer_Bild_an                           "Wohnzimmer Bild an"                                                                                                               {channel="mqtt:topic:Mosquitto:Wohnzimmersensor:switch_on"}
Switch    Wohnzimmer_Bild_aus                           "Wohnzimmer Bild aus"                                                                                                               {channel="mqtt:topic:Mosquitto:Wohnzimmersensor:switch_off"}

The channels to read are working fine but the publish item does not do any effect.

I can trigger the item with MQTT.fx with a MYS_SUB/49/1/1/0/2 -> 1 command
Any hints what I’m doing wrong?

thanks for you help

MM

is not the same as

MYS_sub/49/1/1/0/2

Note the SUB and sub capitalisations. Is that the issue?

sorry that was a typo - it is MYS_sub/49/1/1/0/2

Typo in your post?

I’m interested in this: you have defined your Channel as a Number type (Type number : switch_off), but your Item as a Switch type (Switch Wohnzimmer_Bild_aus). Does the Item just send 1 and 0 instead of the usual on and off? I’ve never mixed those two types before in this way, so am curious if you’ve previously managed to get this to work…

Does this mean that when you flick your Switch Item, nothing appears in mqtt.fx?

yes type in my post…

infact it doesn’t matter what I send to the channel since the device just reacts in the channel (maybe not nice but a dirty hack - but works outside of openhab).

within mqtt.fy I can switch but not in openhab,

maybe it is a more general question of how to link an item to a publish channel?

I’m afraid I don’t understand this.

So, you send 1 to MYS_sub/49/1/1/0/2 and that turns your switch on?

The syntax you have used is correct, but I come back to the fact that you have linked a Switch Item to a Number Channel - I don’t know if this works. Why not try with a Switch Channel, linked to the existing Switch Item?

Type switch : switch_off "schalter aus" [ 
    commandTopic="MYS_sub/49/1/1/0/2",
    on="1",
    off="0"
]

Using the above configuration, I can see that I can publish 1 and 0 to the topic using the Switch Item (screenshot from MQTT Explorer). Note that I am using openHAB2, still:
image

looks like I need to rework the receiving side… I will check, thanks…

it was really just the number / switch confusion :frowning:

thank

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.