// ledMessageHandler set Led to ON or OFF and get STATUS
ledMessageHandler set Led to ON or OFF and get STATUS
// ledMessageHandler set Led to ON or OFF and get STATUS
func (l *led) ledMessageHandler(client mqtt.Client, msg mqtt.Message) {
	if l.debug {
		log.Println("[SUB]", msg.Qos(), msg.Topic(), string(msg.Payload()))
	}
	switch string(msg.Payload()) {
	case "0":
		setBrightness(l.ledID, string(msg.Payload()))
		l.status, _ = getBrightness(l.ledID)
		l.PublishStatus(0)
	case "1":
		setBrightness(l.ledID, string(msg.Payload()))
		l.status, _ = getBrightness(l.ledID)
		l.PublishStatus(0)
	case "STATUS":
		l.status, _ = getBrightness(l.ledID)
		l.PublishStatus(0)
	}
}
func ( l * led ) ledMessageHandler ( client mqtt . Client , msg mqtt . Message ) { if l . debug { log . Println ( " " , msg . Qos ( ) , msg . Topic ( ) , string ( msg . Payload ( ) ) ) } switch string ( msg . Payload ( ) ) { case " " : setBrightness ( l . ledID , string ( msg . Payload ( ) ) ) l . status , _ = getBrightness ( l . ledID ) l . PublishStatus ( 0 ) case " " : setBrightness ( l . ledID , string ( msg . Payload ( ) ) ) l . status , _ = getBrightness ( l . ledID ) l . PublishStatus ( 0 ) case " " : l . status , _ = getBrightness ( l . ledID ) l . PublishStatus ( 0 ) } }
ledMessageHandler set Led to ON or OFF and get STATUS
ledMessageHandler set Led to ON or OFF and get STATUS
// debug // receive message and DO // logic when OFF // logic when ON // publish status