Page 1 of 1

Try send commands.

Posted: 23 Jan 2021, 02:53
by owe
Hi guys! Please help me, I try send mqtt to espeasy mega all night. How did that? I want build rgb led strip (not adress), but esp not accept commands. thks!

Re: Try send commands.

Posted: 23 Jan 2021, 10:14
by Ath
Welcome to this forum.

You will need to provide more information than this before anyone can help you, (and my crystal ball is quarantined because of Covid-19. ;))
- What hardware are you using
- How is it all connected up
- What version of ESPEasy do you have installed on the ESP (name of the .bin file is the most informative)
- How are your devices configured
- What commands have you tried

Re: Try send commands.

Posted: 23 Jan 2021, 11:02
by TD-er
And what controller are you using?
The OpenHAB/HomeAssistant controller is the most generic one.

@Ath: We should add a documentation section on how to send commands over MQTT (OpenHAB/HomeAssistant) as it keeps raising questions

Re: Try send commands.

Posted: 23 Jan 2021, 12:48
by owe
Im use openHAB, in my raspberry mosquitto.
Снимок экрана 2021-01-23 в 14.46.13.png
Снимок экрана 2021-01-23 в 14.46.13.png (158.33 KiB) Viewed 10542 times
Снимок экрана 2021-01-23 в 14.45.54.png
Снимок экрана 2021-01-23 в 14.45.54.png (193.96 KiB) Viewed 10542 times
Изображение.jpeg
Изображение.jpeg (773.85 KiB) Viewed 10542 times
Снимок экрана 2021-01-23 в 14.49.57.png
Снимок экрана 2021-01-23 в 14.49.57.png (74.78 KiB) Viewed 10541 times

Re: Try send commands.

Posted: 23 Jan 2021, 14:11
by Ath
Hm that Domoticz Helper won't work with your HA server, so that can be removed from your devices list.
Are you sure you don't need to enter credentials for the HA server? Usually that's required, AFAIK, but I don't have HA installed so I'm not sure.

Re: Try send commands.

Posted: 23 Jan 2021, 14:26
by Ath
If you connect the ESP via USB you can start the Serial monitor from the ESPEasy.Flasher tool, to view the logs on the ESP (that's usually much easier then via the web log).
Do you see successful connection attempts for the HA MQTT controller, and also from the MQTT Import plugin, in the log output?

Re: Try send commands.

Posted: 23 Jan 2021, 16:47
by owe
Yeah! Thanks sooo!!! That's help me^^
One more question: how I can send value form topic to GPIO. I try "Generic - MQTT Import" and "Regulator - Level Control" but this can only I/O not 0-255 value.

Re: Try send commands.

Posted: 23 Jan 2021, 16:58
by Ath
owe wrote: 23 Jan 2021, 16:47 Yeah! Thanks sooo!!! That's help me^^
One more question: how I can send value form topic to GPIO. I try "Generic - MQTT Import" and "Regulator - Level Control" but this can only I/O not 0-255 value.
When using the Generic MQTT Import you can add a rule (Rules and Old Engine must both be enabled on Tools/Advanced page) that gets triggered by the value change:

Code: Select all

on sniff#State do
  GPIO,8,%eventvalue% // on/off
endon
%eventvalue% is the first argument passed to the event handler, and the value sent from MQTT to the first topic configured. You can add similar handlers for the other values, though I'm not sure the /ESPEasy/State will actually work. All event handlers use their own %eventvalue%, %eventvalue2% and up are not passed to the event handler, so will be 0 in all cases. Instead of %eventvalue% you can also write %eventvalue1%, that is the same.

Re: Try send commands.

Posted: 23 Jan 2021, 17:47
by TD-er
Ath wrote: 23 Jan 2021, 16:58 [...] All event handlers use their own %eventvalue%, %eventvalue2% and up are not passed to the event handler, so will be 0 in all cases. [...]
Nope, if there is no %eventvalue4%, then it will not be replaced. (same for 3, 2, etc.)

Re: Try send commands.

Posted: 23 Jan 2021, 19:47
by owe

Code: Select all

14581238 : Info   : ACT  : GPIO,14,192.00
14581245 : Info   : GPIO : port#14: set to 1
Guys GPIO work with 1/0, but I need set value 0-255 or 0-100 for dimming led.

Re: Try send commands.

Posted: 23 Jan 2021, 20:02
by Ath
You probably need the PWM command, that works like GPIO, but instead of a 0/1 it accepts a duty cycle value from 0 to 1023, you can recalculate from 0-100 or 0-255 by using a LET command (LET,varnr,calculation_goes_here), and then use the result to pass to the PWM command (PWM,14,[VAR#varnr] (the square brackets are part of the variable expansion, f.e. [var#1] if you used let,1,%eventvalue%*10.23 to re-calculate the 0-100 range))

Code: Select all

on sniff#state do
  let,1,%eventvalue%*10.23 // Range 0-100 -> 0-1023
  pwm,14,[var#1] // Set GPIO14 to pwm with calculated dutycycle
endon

Re: Try send commands.

Posted: 26 Jan 2021, 22:39
by owe
Hi Ath. Please help me. My last question) I send to esp "255,170,84" that means red, green, blue channels for GPIO. How I can do that. Write rules or what I need. Thks! Best regards.
Снимок экрана 2021-01-27 в 0.36.22.png
Снимок экрана 2021-01-27 в 0.36.22.png (38.58 KiB) Viewed 10429 times

Re: Try send commands.

Posted: 27 Jan 2021, 08:44
by Ath
I hope you have read the documentation on Rules, over here

Currently, you would have to send an active command to your ESP, containing these values, in a command like this:

Code: Select all

http://ip.of.esp.unit/control?cmd=event,externalrgb=255,170,84
And then create a rule on your ESP to receive that:

Code: Select all

on ExternalRGB do
  PWM,12,%eventvalue1%*4 // R (multiplied by 4 to adjust to 0..1023 range)
  PWM,13,%eventvalue2%*4 // G
  PWM,14,%eventvalue3%*4 // B
endon
Edit: Range adjustment added (see comment below)

Re: Try send commands.

Posted: 27 Jan 2021, 10:52
by TD-er
Please note the PWM has a 10 bit range, so you may want to multiply the values by 4.

Re: Try send commands.

Posted: 28 Jan 2021, 00:11
by owe
Hi guys! I spend my time 3 days) How I can Send mqtt to RGB-Strip? I need use 2 plugins with 2 led strips. Thks you frends!
Plugin is
Topic to try send is /ESP_Easy/HSV value 30,67,99
Снимок экрана 2021-01-28 в 2.04.29.png
Снимок экрана 2021-01-28 в 2.04.29.png (83.83 KiB) Viewed 10351 times
Снимок экрана 2021-01-28 в 2.04.18.png
Снимок экрана 2021-01-28 в 2.04.18.png (65.83 KiB) Viewed 10351 times
Снимок экрана 2021-01-28 в 1.26.17.png
Снимок экрана 2021-01-28 в 1.26.17.png (12.04 KiB) Viewed 10351 times

Re: Try send commands.

Posted: 28 Jan 2021, 00:13
by owe
Firmwares

Re: Try send commands.

Posted: 28 Jan 2021, 00:14
by TD-er
That screenshot does look like a really old version of ESPEasy.
See here for newer versions: https://github.com/letscontrolit/ESPEasy/releases

Apart from that the playground plugin is not part of the build, but what makes that specific plugin better than the plugins we now have in the mega branch?

Re: Try send commands.

Posted: 28 Jan 2021, 02:02
by owe
In the new firmware, I cannot use the plugins from homebridge and Esp_Easy to control the LED strips

Re: Try send commands.

Posted: 28 Jan 2021, 10:27
by TD-er
Why not?
Does the plugin no longer compile on newer versions of ESPEasy?

Re: Try send commands.

Posted: 28 Jan 2021, 13:31
by owe
Yeap, this plugin not compile in newer versions.

Re: Try send commands.

Posted: 28 Jan 2021, 13:58
by Ath
Are we talking about this, really really old, plugin that's not even in the PluginPlayground? It actually needs a big renovation.

Edit:
Ah, I've just found it, P142 in the PluginPlayground

Re: Try send commands.

Posted: 28 Jan 2021, 23:05
by owe
Yes, if add it to the compilation and the library it uses FastLED version 3.1.8. then it throws a compilation error.
Снимок экрана 2021-01-29 в 1.01.53.png
Снимок экрана 2021-01-29 в 1.01.53.png (280.18 KiB) Viewed 10267 times

Re: Try send commands.

Posted: 28 Jan 2021, 23:18
by owe
Other plugin "_P142_RGB-Strip" have error compile too ...
Снимок экрана 2021-01-29 в 1.17.47.png
Снимок экрана 2021-01-29 в 1.17.47.png (60.06 KiB) Viewed 10265 times

Re: Try send commands.

Posted: 28 Jan 2021, 23:23
by owe
Can you fix code this plugins for good compilation?
_P142_RGB-Strip.ino
_P141_LedStrip.ino

Re: Try send commands.

Posted: 29 Jan 2021, 07:52
by Ath
About compilation errors in general:
Start with looking at the first error that occurs, the compiler gets really upset once it sees an error, and often, a single error causes dozens, or even hundreds of 'collateral damage' errors. Fixing that first and retrying will often reduce the amount of errors drastically.


Not sure about that FastLed library, it seems to trigger a lot of compile errors, most likely because it is not updated for modern C++ compilers.


This one is quite easy to fix, it exists in most of the PluginPlayground sources:

Code: Select all

Device[deviceCount].VType = SENSOR_TYPE_TRIPLE;
should be adjusted by adding "Sensor_VType::" resulting in:

Code: Select all

Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_TRIPLE;
I'll have a look at those plugins sometime during the weekend, I've got a few other ESPEasy projects at hand, switching halfway is a bit disturbing.

NB: Adding screenshots of code-like stuff, like error logs, is quite hard to reply to, better wrap parts of the logs into [ code ] [ /code ] (without the spaces) tags in your post (the </> button in the toolbar)

Re: Try send commands.

Posted: 29 Jan 2021, 10:46
by TD-er
The typedef boolean is something that should not have been in any Arduino library as it is already defined in Arduino.h
So that typedef in the library should be removed.

Re: Try send commands.

Posted: 30 Jan 2021, 00:22
by owe
Ath wrote: 29 Jan 2021, 07:52 About compilation errors in general:
Start with looking at the first error that occurs, the compiler gets really upset once it sees an error, and often, a single error causes dozens, or even hundreds of 'collateral damage' errors. Fixing that first and retrying will often reduce the amount of errors drastically.


Not sure about that FastLed library, it seems to trigger a lot of compile errors, most likely because it is not updated for modern C++ compilers.


This one is quite easy to fix, it exists in most of the PluginPlayground sources:

Code: Select all

Device[deviceCount].VType = SENSOR_TYPE_TRIPLE;
should be adjusted by adding "Sensor_VType::" resulting in:

Code: Select all

Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_TRIPLE;
I'll have a look at those plugins sometime during the weekend, I've got a few other ESPEasy projects at hand, switching halfway is a bit disturbing.

NB: Adding screenshots of code-like stuff, like error logs, is quite hard to reply to, better wrap parts of the logs into [ code ] [ /code ] (without the spaces) tags in your post (the </> button in the toolbar)
Now its :

Code: Select all

/Users/power/Downloads/ESPEasy-mega/src/_P142_RGB-Strip.ino: In function 'boolean Plugin_142(byte, EventStruct*, String&)':
/Users/power/Downloads/ESPEasy-mega/src/_P142_RGB-Strip.ino:83:14: warning: unused variable 'tmpString' [-Wunused-variable]
         char tmpString[128];
              ^
/Users/power/Downloads/ESPEasy-mega/src/_P142_RGB-Strip.ino: In function 'void Plugin_142_Output(float*)':
/Users/power/Downloads/ESPEasy-mega/src/_P142_RGB-Strip.ino:355:65: error: 'setPinState' was not declared in this scope
         setPinState(PLUGIN_ID_142, pin, PIN_MODE_PWM, actRGBW[i]);
I look other plugins and this line is off

Code: Select all

// setPinState(PLUGIN_ID_001, CONFIG_PIN1, PIN_MODE_INPUT, switchstate[event->TaskIndex]);

Re: Try send commands.

Posted: 30 Jan 2021, 00:58
by TD-er
That part of the setPinState...
Check the code in Servo.cpp (just one example) to see how it is now called:

Code: Select all

   // setPinState(PLUGIN_ID_001, event->Par2, PIN_MODE_SERVO, event->Par3);
    tempStatus.mode = PIN_MODE_SERVO;
    savePortStatus(key, tempStatus);
    log += F(" Servo set to ");
    log += event->Par3;
    addLog(LOG_LEVEL_INFO, log);
    SendStatusOnlyIfNeeded(event, SEARCH_PIN_STATE, key, log, 0);
Other examples just by searching for "setPinState" in the code.

Re: Try send commands.

Posted: 02 Feb 2021, 08:18
by Ath
Ath wrote: 29 Jan 2021, 07:52 I'll have a look at those plugins sometime during the weekend, I've got a few other ESPEasy projects at hand, switching halfway is a bit disturbing.
I did have a look at the code last night, but there are too many snags there for me to fix quickly/easily, so I'm letting this one go for someone else to tackle. And I don't have the hardware available, what would be a primary requirement to get this code properly tested.
Sorry.