Adding mqtt output channel to non mqtt things / items

Hi,

I want to add a MQTT output channel to items which do not get their state from MQTT.

As an example i have the following thing defined

Bridge airquality:api:aqiFaridabd "Bridge" [apiKey="xxxxxxxx"] {
    station AQI547 "AQI" [location="28.3998266,77.3242992", refresh=60]
}

With following items

Number AirQualityAQI 							"Air Quality Index" 					(LocalAirQuality, gHome) ["Point", "Measurement"] 				{ channel="airquality:station:aqiFaridabd:AQI547:aqi#index" }
Number AirQualityPM25 							"Main Pollutant" 						(LocalAirQuality, gHome) ["Point"] 					{ channel="airquality:station:aqiFaridabd:AQI547:pm25#value" }
Number AirQualityTemperature 					"Temperature" 			<temperature> 	(LocalAirQuality, gHome) ["Point"] 					{ channel="airquality:station:aqiFaridabd:AQI547:weather#temperature" }
Number AirQualityHumidity						"Humidity" 								(LocalAirQuality, gHome) ["Point"] 					{ channel="airquality:station:aqiFaridabd:AQI547:weather#humidity" }
Number AirQualityPressure						"Pressure" 								(LocalAirQuality, gHome) ["Point"] 					{ channel="airquality:station:aqiFaridabd:AQI547:weather#pressure" }
Number AirQualityWindSpeed						"Wind Speed" 							(LocalAirQuality, gHome) ["Point"] 					{ channel="airquality:station:aqiFaridabd:AQI547:weather#wind-speed" }
String LocalAirQualityAQIDescription 			"AQI Description" 						(gLocalAirQuality, gHome) ["Point", "Measurement"] 	{ channel="airquality:station:aqiFaridabd:AQI547:aqi#dominent" }
Image LocalAirQuality_pictogram					"pictogram"																					{channel="airquality:station:aqiFaridabd:AQI547:aqi#icon"}

Can i define an MQTT output channel / topic for each of the above items ? I understand you can do that via rules i.e. use

mqttActions.publishMQTT("mytopic","myvalue", true)

Can you define this from within the ITEM definition itself ?

Maybe just create a regular mqtt thing and connect items to the channel, that you can read / write the mqtt topics you want to publish.

Then you can either work with rules to copy items state from one item (linked to air quality item) to the other item (linked to mqtt) or try to use the follow profile

Thanks - will try.
Q: How do you get a MQTT thing / item to regularly publish state to broker ?

I think you will need to run a rule triggered by either a timer or cron as there is no pull/push frequency config in the MQTT thing or channel.

1 Like

You don’t, unless you use a rule and the publish Action you described earlier, or rule to update the Item with an MQTT link.

Do actually you need regularly?
See follow profile used here

1 Like

As mentioned by the others, the normal behavior is that the state will only be published once the item state will change.
If that’s enough you don’t need any extra rule.

1 Like

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