parsing RGB from Dashboard
Moderators: grovkillen, Stuntteam, TD-er
parsing RGB from Dashboard
Hi guys.
Can you help me to do it!
When picked color in dashboard i receive: "room/light/color -> #rrggbb" // color in hex format start with '#' char
1. <Generic - MQTT Import'> can only float, no string
2. How to parse integers r,g,b from here ?
Thank's.
Can you help me to do it!
When picked color in dashboard i receive: "room/light/color -> #rrggbb" // color in hex format start with '#' char
1. <Generic - MQTT Import'> can only float, no string
2. How to parse integers r,g,b from here ?
Thank's.
Re: parsing RGB from Dashboard
from android apk. MQTT Dashboard for example.
Another aplication was send the same '#rrggbb' format or 'RGBA(r,g,b,a)' (if use alpha) ' ' - text in payload from broker
Another aplication was send the same '#rrggbb' format or 'RGBA(r,g,b,a)' (if use alpha) ' ' - text in payload from broker
Re: parsing RGB from Dashboard
I have been working on MQTT Import plugin for a while, see this PR #3424 I can add support for that type of data, as it currently doesn't support that yet.
Another approach could be to script some kind of replace on the sending side, replacing the "#" prefix by "0x", so the value is properly parsed, but then it still isn't split in R, G and B values.
You could mock up a rule that handles the value using string processing, I'll toy with that idea a bit.
Another approach could be to script some kind of replace on the sending side, replacing the "#" prefix by "0x", so the value is properly parsed, but then it still isn't split in R, G and B values.
You could mock up a rule that handles the value using string processing, I'll toy with that idea a bit.
/Ton (PayPal.me)
Re: parsing RGB from Dashboard
Great work!!! Thanks. It's a light in end of tube
try compile but:
error: src\src\PluginStructs_tmp\__tmpfile.cpp:4752:54: error: 'compareValues' was not declared in this scope
later...
after adding to ESPEasyRules.cpp
result:
custom_ESP8266_4M1M SUCCESS 00:02:06.020
try compile but:
error: src\src\PluginStructs_tmp\__tmpfile.cpp:4752:54: error: 'compareValues' was not declared in this scope
later...
after adding to ESPEasyRules.cpp
Code: Select all
bool compareValues(char compare, float Value1, float Value2)
{
bool match = false;
switch (compare) {
case '>' + '=':
if (Value1 >= Value2) {
match = true;
}
break;
case '<' + '=':
if (Value1 <= Value2) {
match = true;
}
break;
case '!' + '=':
if (Value1 != Value2) {
match = true;
}
break;
case '>':
if (Value1 > Value2) {
match = true;
}
break;
case '<':
if (Value1 < Value2) {
match = true;
}
break;
case '=':
if (Value1 == Value2) {
match = true;
}
break;
}
return match;
}
custom_ESP8266_4M1M SUCCESS 00:02:06.020
Re: parsing RGB from Dashboard
You should be able to download a precompiled build from the last Github actions run (Scroll to the bottom at the right side of that screen, there's a Binaries.zip file)
If your build-type isn't included, because it failed/got cancelled, then I can create a local build for you to see if that already helps, just mention the name of the .bin file you use for flashing.
If your build-type isn't included, because it failed/got cancelled, then I can create a local build for you to see if that already helps, just mention the name of the .bin file you use for flashing.
/Ton (PayPal.me)
Re: parsing RGB from Dashboard
Thank'sAth wrote: ↑19 Jan 2022, 13:29 You should be able to download a precompiled build from the last Github actions run (Scroll to the bottom at the right side of that screen, there's a Binaries.zip file)
If your build-type isn't included, because it failed/got cancelled, then I can create a local build for you to see if that already helps, just mention the name of the .bin file you use for flashing.
I was compiled success.
After i was added some code:
Code: Select all
if (matchedTopic && Payload.substring(0, 1) == F("#")) {
addLog(LOG_LEVEL_INFO, F("IMPT : ... transforming HTML color to JSON"));
int r,g,b = 0;
sscanf(Payload.c_str(), "#%02x%02x%02x", &r, &g, &b);
Payload = "{\"r\":" ;
Payload += r;
Payload += ",\"g\":";
Payload += g;
Payload += ",\"b\":";
Payload += b;
Payload += "}\n";
}
Code: Select all
66305 : Info : IMPT : ... transforming HTML color to JSON
66308 : Info : IMPT : [controll#Rgb] : 0.00
66369 : Info : EVENT: controll#room/test/rgb/Rgb=#ffffff
66468 : Info : EVENT: controll#Rgb={"r":255,"g":255,"b":255}
Code: Select all
977929 : Info : IMPT : ... transforming HTML color to JSON
977931 : Info : IMPT : MQTT 037 JSON data detected.
Re: parsing RGB from Dashboard
Not sure why you have to add that to the source code, I've never had to do anything like that. Did you clone the regular ESPEasy project, or forked it first?
I think converting a message that starts with a # could be converted into separate R, G, B values a bit easier if I add that as a mapping. I'll think of a way to implement that, and generate a single event with 3 values from it, so you could handle it in rules.hash20 wrote: ↑19 Jan 2022, 18:16 After i was added some code:Code: Select all
if (matchedTopic && Payload.substring(0, 1) == F("#")) { addLog(LOG_LEVEL_INFO, F("IMPT : ... transforming HTML color to JSON")); ...
Also want to take 1 step back and ask the 'big' question: What is the purpose of having your MQTT rrggbb color value split into separate colors?
/Ton (PayPal.me)
Re: parsing RGB from Dashboard
Sorry, it my first expirience with Platformio and EasyESP (3-4 days) i just create a new project from git. I don't understand how i can do it, but it work )))Not sure why you have to add that to the source code, I've never had to do anything like that. Did you clone the regular ESPEasy project, or forked it first?
Ok, thanks. But i want make it selfI think converting a message that starts with a # could be converted into separate R, G, B values a bit easier if I add that as a mapping. I'll think of a way to implement that, and generate a single event with 3 values from it, so you could handle it in rules.
... if you will "toy" with it then better parse 4 parameters R,G,B,W (full support for all strips will be or can use this chanell as alpha)
I'm using application https://play.google.com/store/apps/deta ... mqtt&gl=UAAlso want to take 1 step back and ask the 'big' question: What is the purpose of having your MQTT rrggbb color value split into separate colors?
it have color picker component. After picked it publish ' #rrggbb' message to assigned topic.
i want to recieve it and send the command in rules:
Code: Select all
NeoPixelAll,[dummy#VarGreen],[dummy#VarRed],[dummy#VarBlue],[dummy#VarWhite]]
I try get this fucked parameters while.... help please
Re: parsing RGB from Dashboard
I wrote a starters guide for development on ESPEasy: https://espeasy.readthedocs.io/en/lates ... on-espeasy
That last line could be in a rule like:hash20 wrote: ↑19 Jan 2022, 20:48 I'm using application https://play.google.com/store/apps/deta ... mqtt&gl=UA
it have color picker component. After picked it publish ' #rrggbb' message to assigned topic.
i want to recieve it and send the command in rules:Code: Select all
NeoPixelAll,[dummy#VarGreen],[dummy#VarRed],[dummy#VarBlue],[dummy#VarWhite]]
Code: Select all
on controll#Rgb do
NeoPixelAll,%eventvalue1%,%eventvalue2%,%eventvalue4%,%eventvalue4%
endon
/Ton (PayPal.me)
Who is online
Users browsing this forum: No registered users and 19 guests