Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

API misbehavior #276

Closed
dermalikmann opened this issue Dec 3, 2018 · 6 comments
Closed

API misbehavior #276

dermalikmann opened this issue Dec 3, 2018 · 6 comments

Comments

@dermalikmann
Copy link
Collaborator

dermalikmann commented Dec 3, 2018

So, I'm not quite sure if this is a bug, or I'm just not getting it.
I am currently building my smart home system and wanted to integrate an esp (nodemcu) with McLighting.
Currently I'm going with MQTT (mabe I'm going to switch to HTTP because of more detailed features)
In the WS API doc (wich should be the same as the MQTT) it is explained that the #<hexrgb> is setting a color and the *<hexrgb> is setting the color AND turning all lamps on

Payload: #<hexrgb>
Where is the color as HEX, e.g. 04d2ff
Set default color of the lamp.

Payload: *<hexrgb>
Where is the color as HEX, e.g. 04d2ff
Set default color of the lamp and light all LEDs in that color.

But this does not match with the behavior I'm experiencing. Although I call #<hexrgb> my LED strip is turned on.

So again: Am I interpreting this wrongly, or is this a misbehavior?

MfG / Greets
Malik

@debsahu
Copy link
Collaborator

debsahu commented Dec 3, 2018

The diff is: # sets only main color, so the animation can be anything, but the main color is changed without affecting the current mode. * sets the main color AND sets mode to static mode (old mode is replaced, mode=FX_MODE_STATIC).

@dermalikmann
Copy link
Collaborator Author

dermalikmann commented Dec 3, 2018

Oh yeah, I see that I was definitly unclear what I meant. Sorry for that.
I forgot to mention that my strip is turned off. Then I set the color via #<hexrgb>. The problem now is that the strip turns on again. I've done some very basic debugging via the API and found out that when I set the color the switch status gets turned to 1.

Here is some JSON

{
  "mode": 2,
  "ws2812fx_mode": 0,
  "ws2812fx_mode_name": "Static",
  "speed": 196,
  "brightness": 196,
  "color": [
    0,
    250,
    212
  ]
}

Result of http://myesp/status after sending =off via MQTT
http://myesp/get_switch returns 0

{
  "mode": 1,
  "ws2812fx_mode": 0,
  "ws2812fx_mode_name": "Static",
  "speed": 196,
  "brightness": 196,
  "color": [
    255,
    0,
    0
  ]
}

Result of http://myesp/status after sending #ff0000 via MQTT
http://myesp/get_switch returns 1

This is a missbehavior as far as I can tell from the pov of a generic API (I send one command and two things change) and from the docs, since this should only be the case when *<hexrgb> is used.

Again I apologise for being unclear as heck what my problem is.

@debsahu debsahu reopened this Dec 3, 2018
@debsahu
Copy link
Collaborator

debsahu commented Dec 3, 2018

Ahh I see,

if (prevmode == SET_MODE) prevmode = HOLD;
is to blame. The prevmode is never set back to HOLD, or any value other than SET_MODE unless brightness is called. Its a bug, thanks for reporting!

@debsahu debsahu added the bug label Dec 3, 2018
@dermalikmann
Copy link
Collaborator Author

To make some Additions: This does not happen when setting the speed (neither via HTTP nor MQTT)
But it also happens if you set the brightness (both HTTP and MQTT).
The latter may seem counterintuitive but as I said befor: An API should be designed to send one command that changes one thing (except otherwise specified, of course)

No problem for reporting. Maybe I will contribute to this project too, if I can get my lasy butt to learn some proper C 😄

Greets

@debsahu
Copy link
Collaborator

debsahu commented Dec 3, 2018

Upon second thought, # is the only way one can turn on McLighting. There is=off but not on. We turn on by setting main values for RGB. @toblum am I right?

@toblum
Copy link
Owner

toblum commented Dec 3, 2018

Exactly. Turning off is esentially setting RGB values to black. So there is no real turning on/off, just setting the colors.

debsahu added a commit that referenced this issue Dec 3, 2018
* Contributions by @	MrTheBarbarian from #270 Putting Static IP config added in Jun 17th 2018 to definitions.h
* rethink ESP.getChipId implementaion
* check ArduinoJSON version
* Try restting prevmode as suggested in #276
@debsahu debsahu closed this as completed Dec 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants