WLED control without the binding

Looks cool!

Would you also be able to share all your map files to complete the example?

Hi Please find CFG file at following location

You made me to do my 1st mqtt 1.0X to 2.5 which was long pending at my end :slight_smile: Thanks

State topic requires work for state subscription . This will help to maintain the correct status on Openhab end if the state change done using WLED WEB UI / Push Button .
I tried but not working .

Also I will like to learn on jython rule .

For me, every time something is changed with WLED (either via openHAB, or the web UI or the app), WLED always responds with all three MQTT response topics: g, c and v.

openHAB will always pick this up, whether or not the original command came from openHAB, and my items will update almost instantaneously.

I haven’t changed anything from default on WLED except for enabling MQTT in the first place. It’s strange that it doesn’t work for you.

` effects, palettes & preset the additional Item I added .System gives the Log message like this

2020-06-23 17:02:22.383 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Incoming payload 'Bouncing Balls' not supported by type 'NumberValue'
2020-06-23 17:02:22.396 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Incoming payload 'Rainbow' not supported by type 'NumberValue'

I am trying to update the number item with a text value. What I want is to update the number Item and respective text value to be picked up from the map file.

In general, I would keep the channel as a number, the item as a number and the sitemap widget as a selection - all of these deal with numbers. Then (using effect (FX) as an example):

  • On the sitemap widget you have mappings (as you already do) to show the user more friendly effect names. (It would be great if these could be defined in a map file, but it doesn’t look like it from the docs). Make sure that each effect number and name match those defined by WLED.
  • On the channel use formatBeforePublish="FX=%s" instead of transformationPatternOut. This will send out “FX=22” if you selected “Sparkle+” from the sitemap selection box.
  • On the channel, keep the XPATH transform on transformationPattern. This number will then be passed back to the sitemap selection box, and the currently active effect will be displayed with your friendlier name.

EDIT: Now implemented in post #1

Done Bingo works perfectly. I shall upload Dropbox and update the configuration soon.

Hi guys,
If understood correctly second post is optimized code from post no 1. Looks much smoother but got lost somewhere I guess.
We do have three blocks of code to copy/paste into THINGS, ITEMS and SITEMAP and done that. However not using Mosquitto but MQTT Embedded Broker, anyone adapted that code for different broker?

This depends on how you’ve set your embedded broker up. If your broker does not yet have a bridge Thing associated with it, then you can use the one from the example and adjust the parameters.

If you do already have a bridge Thing, and you set this up using PaperUI then I’m afraid I don’t quite know what the next step would be.

I will say this: if you intend to upgrade to OH3, the embedded broker is being removed completely. I would recommend moving to a dedicated MQTT broker such as Mosquitto to future proof yourself…

EDIT: Just realised this example doesn’t include the code for a bridge Thing. Use the one from this post for now (scroll to bridge.things).

It`s working now :slight_smile:
First changed (mqtt:broker:MosquittoMqttBroker) into (mqtt:systemBroker:embedded-mqtt-broker) , then installed Xpath and javascript transformations (before used only jsonpath) and finally rebooted OH (not sure if neccessary).

Thanks hafniumzinc !!

@sujitrp Why in MAP files you use “:” instead of “=”?

No specific reason .

Any chance of getting “Sleep” running or did I missed something.

BUUUUT ALL IN ALL - Guys great - really love it.
Took me a few minutes and it works like a charm!

Thx for sharing!

Clyde

Do you mean the dimming timer? I’ve got a proof of concept working - will write it up over the weekend.

Yeah, correct. The dimming timer.
Which switches “off” the lights after /default 60 mins.

Would be awesome. Will try to help/test :wink:

Getting full control over Sleep is awkward, involving rules and metadata, and there’s also this problem.

A simple method, which just involves a switch, is as follows. This will use the Default Duration and Default Target brightness in the WLED settings:

Channel

Type switch : sleep "Sleep" [
	stateTopic="wled/RGB2/v",
	transformationPattern="XPATH:/vs/nl/text()",
	commandTopic="wled/RGB2/api",
	formatBeforePublish="ND",
	on="1",
	off="0"
]

Item

Switch sRGB2Sleep "Sleep" {channel="mqtt:topic:swRGB2:sleep"}

WLED settings

Change to suit
image

The challenge with configuring Sleep over MQTT is that you can send an NL= command, which takes a number in minutes as an argument. This will set the Sleep Default Duration to that time, BUT ALSO will turn Sleep ON! So without a rule I haven’t found a way to change ONLY the Default Duration. You may want to check out the WLED binding options for Sleep.

1 Like

Faniumzinc: Wh00p Whoop - tested works. NICE!
Thx for help. This suits my needs totally. I just want to set a timer for nightlight and done.
60 mins are fine and if I want to change it I can do it via the GUI.

:slight_smile: pure awesomeness!

Any chance to control Presets through MQTT as well? I see these are reported on strings named ps
1

It looks like you should be able to with the HTTP API.

You could add the following Channel to the Thing (untested):

			Type number : preset "Preset" [
				commandTopic="wled/RGB2/api",
				formatBeforePublish="PL=%s",
				stateTopic="wled/RGB2/v",
				transformationPattern="XPATH:/vs/ps/text()"
			]

Link that to a Number Item, and if using a Sitemap set the mappings appropriately.

I don’t use presets, so can’t test this.

1 Like

Thanks, works like a charm !

You will also get PLAYLISTS mixed in with the PRESETS, the binding will sort them into different channels. The API treats both of those very similar.