Hello, today I’m going to show you how I made MQTT dimmer which sends values to ESP-EASY PWM and that’s it. It’s pretty straight forward.
my .rules file
import java.lang.Math.*
import org.openhab.core.library.types.DecimalType
rule "LEDLIGHT_IN"
when
Item MQTTLED received update
then
var Number outNum = MQTTLED.state as DecimalType
MQTTLEDS.sendCommand(outNum*10)
end
my .items file
Dimmer MQTTLED
Number MQTTLEDS {mqtt=">[broker:/led/PWM/5:command:*:default]"}
and my .sitemap file
Slider item=MQTTLED label="LED Brightness"
that’s all there is for it. Feel free to ask any questions about this code.
P.S I believe that there was something similar poster, but I couldn’t find it, so here it’s.