Try send commands.

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
owe
Normal user
Posts: 13
Joined: 23 Jan 2021, 02:49

Try send commands.

#1 Post by owe » 23 Jan 2021, 02:53

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!

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Try send commands.

#2 Post by Ath » 23 Jan 2021, 10:14

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
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Try send commands.

#3 Post by TD-er » 23 Jan 2021, 11:02

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

owe
Normal user
Posts: 13
Joined: 23 Jan 2021, 02:49

Re: Try send commands.

#4 Post by owe » 23 Jan 2021, 12:48

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 10428 times
Снимок экрана 2021-01-23 в 14.45.54.png
Снимок экрана 2021-01-23 в 14.45.54.png (193.96 KiB) Viewed 10428 times
Изображение.jpeg
Изображение.jpeg (773.85 KiB) Viewed 10428 times
Снимок экрана 2021-01-23 в 14.49.57.png
Снимок экрана 2021-01-23 в 14.49.57.png (74.78 KiB) Viewed 10427 times

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Try send commands.

#5 Post by Ath » 23 Jan 2021, 14:11

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.
/Ton (PayPal.me)

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Try send commands.

#6 Post by Ath » 23 Jan 2021, 14:26

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?
/Ton (PayPal.me)

owe
Normal user
Posts: 13
Joined: 23 Jan 2021, 02:49

Re: Try send commands.

#7 Post by owe » 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.

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Try send commands.

#8 Post by Ath » 23 Jan 2021, 16:58

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.
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Try send commands.

#9 Post by TD-er » 23 Jan 2021, 17:47

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.)

owe
Normal user
Posts: 13
Joined: 23 Jan 2021, 02:49

Re: Try send commands.

#10 Post by owe » 23 Jan 2021, 19:47

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.

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Try send commands.

#11 Post by Ath » 23 Jan 2021, 20:02

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
/Ton (PayPal.me)

owe
Normal user
Posts: 13
Joined: 23 Jan 2021, 02:49

Re: Try send commands.

#12 Post by owe » 26 Jan 2021, 22:39

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 10315 times

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Try send commands.

#13 Post by Ath » 27 Jan 2021, 08:44

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)
Last edited by Ath on 27 Jan 2021, 10:57, edited 2 times in total.
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Try send commands.

#14 Post by TD-er » 27 Jan 2021, 10:52

Please note the PWM has a 10 bit range, so you may want to multiply the values by 4.

owe
Normal user
Posts: 13
Joined: 23 Jan 2021, 02:49

Re: Try send commands.

#15 Post by owe » 28 Jan 2021, 00:11

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 10237 times
Снимок экрана 2021-01-28 в 2.04.18.png
Снимок экрана 2021-01-28 в 2.04.18.png (65.83 KiB) Viewed 10237 times
Снимок экрана 2021-01-28 в 1.26.17.png
Снимок экрана 2021-01-28 в 1.26.17.png (12.04 KiB) Viewed 10237 times

owe
Normal user
Posts: 13
Joined: 23 Jan 2021, 02:49

Re: Try send commands.

#16 Post by owe » 28 Jan 2021, 00:13

Firmwares
Attachments
firmwares.zip
(928.92 KiB) Downloaded 167 times

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Try send commands.

#17 Post by TD-er » 28 Jan 2021, 00:14

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?

owe
Normal user
Posts: 13
Joined: 23 Jan 2021, 02:49

Re: Try send commands.

#18 Post by owe » 28 Jan 2021, 02:02

In the new firmware, I cannot use the plugins from homebridge and Esp_Easy to control the LED strips

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Try send commands.

#19 Post by TD-er » 28 Jan 2021, 10:27

Why not?
Does the plugin no longer compile on newer versions of ESPEasy?

owe
Normal user
Posts: 13
Joined: 23 Jan 2021, 02:49

Re: Try send commands.

#20 Post by owe » 28 Jan 2021, 13:31

Yeap, this plugin not compile in newer versions.

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Try send commands.

#21 Post by Ath » 28 Jan 2021, 13:58

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
/Ton (PayPal.me)

owe
Normal user
Posts: 13
Joined: 23 Jan 2021, 02:49

Re: Try send commands.

#22 Post by owe » 28 Jan 2021, 23:05

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 10153 times

owe
Normal user
Posts: 13
Joined: 23 Jan 2021, 02:49

Re: Try send commands.

#23 Post by owe » 28 Jan 2021, 23:18

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 10151 times

owe
Normal user
Posts: 13
Joined: 23 Jan 2021, 02:49

Re: Try send commands.

#24 Post by owe » 28 Jan 2021, 23:23

Can you fix code this plugins for good compilation?
_P142_RGB-Strip.ino
_P141_LedStrip.ino

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Try send commands.

#25 Post by Ath » 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)
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Try send commands.

#26 Post by TD-er » 29 Jan 2021, 10:46

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.

owe
Normal user
Posts: 13
Joined: 23 Jan 2021, 02:49

Re: Try send commands.

#27 Post by owe » 30 Jan 2021, 00:22

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]);

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Try send commands.

#28 Post by TD-er » 30 Jan 2021, 00:58

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.

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Try send commands.

#29 Post by Ath » 02 Feb 2021, 08:18

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.
/Ton (PayPal.me)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 22 guests