Hello,
I am brandnew to OH. With my first solution, I want to control an MQTT actor based on ESP8266. Switches and input work well, but the dimmer not jet. With it the LED15 should be dimmed in 5% increase/decrease. But with the choosen setup, I only got ON/OFF and INCREASE/DECREASE states (and no MQTT messages).
My actor.items:
// Gruppen
Group gAct1 // Gruppe Actor 1
Group gAct2 // Gruppe Actor 2
/MQTT/
Switch LED11 “LED11” (gAct1) { mqtt=">[mosquitto:actor1/ch0:command:ON:ch0_255],>[mosquitto:actor1/ch0:command:OFF:ch0_0]" }
Switch LED12 “LED12” (gAct1) { mqtt=">[mosquitto:actor1/ch1:command:ON:ch1_255],>[mosquitto:actor1/ch1:command:OFF:ch1_0]" }
Switch LED13 “LED13” (gAct1) { mqtt=">[mosquitto:actor1/ch2:command:ON:ch2_255],>[mosquitto:actor1/ch2:command:OFF:ch2_0]" }
Switch LED14 “LED14” (gAct1) { mqtt=">[mosquitto:actor1/ch3:command:ON:ch3_255],>[mosquitto:actor1/ch3:command:OFF:ch3_0]" }
Dimmer LED15 “LED15 [%d %%]” (gAct1) { mqtt=">[mosquitto:actor1/ch3:state:*:default]" }
Switch LED21 “LED11” (gAct2) { mqtt=">[mosquitto:test:command:ON:211],>[mosquitto:test:command:OFF:210]" }
Switch LED22 “LED22” (gAct2) { mqtt=">[mosquitto:test:command:ON:221],>[mosquitto:test:command:OFF:220]" }
Switch LED23 “LED23” (gAct2) { mqtt=">[mosquitto:test:command:ON:231],>[mosquitto:test:command:OFF:230]" }
Switch LED24 “LED24” (gAct2) { mqtt=">[mosquitto:test:command:ON:241],>[mosquitto:test:command:OFF:240]" }
/MQTT input/
Number Temperatur “Temperatur [%d Grad C]” (gAct1) { mqtt="<[mosquitto:test:state:default]" }
My actor.sitemap:
sitemap actor label=“Hauptmenue”
{
Frame {
Group item=gAct1 label=“Actor 1” icon="Actor 1"
Group item=gAct2 label=“Actor 2” icon=“Actor 2”
}
Frame {
Slider item=LED15
}
}
My actor.rules:
import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
/**
-
This is a demo rule which simulates a real dimmer by reacting to increase/decrease commands
-
and posting an updated state on the bus
*/
rule "Dimmed"
when
Item LED15 received command
then
var Number percent = 0
if(LED15.state instanceof DecimalType) percent = LED15.state as DecimalTypeif(receivedCommand==INCREASE) percent = percent + 5 if(receivedCommand==DECREASE) percent = percent - 5 if(percent<0) percent = 0 if(percent>100) percent = 100 postUpdate(LED15, percent);
end
I run Openhab1 (1.8.3) on a Windows 7 PC browsing with Chrome.
Any hint is very welcome!
Best regards
Walter