philip1986 / pimatic-led-light

A template for creating plugins
http://pimatic.org/
GNU General Public License v2.0
7 stars 13 forks source link

Invalid config of device mrf12: Property "port" is not a valid property #71

Open TehEbil opened 7 years ago

TehEbil commented 7 years ago

Hello, just copied your text to device section and I keep getting the stated error.

Port is "/dev/ttyUSB1", but changing it to ttyUSB1, USB1 and 1 doesn't change anything, what am I doing wrong?

Edit: I can edit the following under devices in the config file as the following:

    {
      "id": "mrf24",
      "name": "mrf24",
      "class": "MilightRF24",
      "zones": [
        {
          "addr": "test",
          "port": "/dev/ttyUSB1",
          "zone": 0
        }
      ]
    },

but I neither can edit it with the pimatic GUI nor it seems to work (getting undefined port).

mwittig commented 7 years ago

@Xento can you please have a look at this?

mwittig commented 7 years ago

@TehEbil As far as I can see you have misplaced the port property which should be one the same level as zones. See the example I have copied from README EDIT: Actually, the example given in README does not match the current device schema.

TehEbil commented 7 years ago

Thank you for your effort & testing.

If you do that this way, pimatic automatically changes it to port being in zone and you get the following error when restarting pimatic: Error loading device "mrf24": Invalid port specified: undefined

Btw. what is the plugin doing? Does it only send x, r for enabling henryks listening mode (for debugging example), or can you set channels, too? Because for me, henryk isn't working somehow, do not receive anything. But with nRF24 Scanner, I can detect my remote.

Xento commented 7 years ago

In my opinion it's the best to define the port outside the zones because my version of henryks sketch accepts as many zones / remotes as you like. So its a kind of gateway and one port definition for all zones is enough because you only need one arduino for everything.

My version can receive the commands from the remotes and sets the state of the devices in pimatic. And of course you can control your lights over pimatic.

TehEbil commented 7 years ago

Hello, I think I tried yours before, too.

It gave me an compiler error because packet[] is declared locally in the if but is then used outside (see l.43 -> l.59ff), so I tried to move it before the second if but then I got spammed with ID:1001 Group 6 (or second time: ID:0002 Group 6) without pushing any button.

And doesn't one have to change static const uint8_t CHANNELS[] = {9, 40, 71}; ? Because idk, mine worked on channel 5, and I've seen henryk increased those numbers by two somewhere, so it'd be 11, 42, 73.

Xento commented 7 years ago

Mine version just build fine with this RF24 lib: https://github.com/TMRh20/RF24 9, 40, 71 are the correct channels. Which bulbs do you have? This version only works for RGBW bulbs. Group 6 can't be correct. You can only have 4 groups!

TehEbil commented 7 years ago

I dont get it, how is that even possible that it works for you? Look at the following:

      if (receiving) {
            if (mlr.available()) {
                  printf("\n");
                  uint8_t packet[7];
                  size_t packet_length = sizeof(packet);
                  mlr.read(packet, packet_length);

                  for (int i = 0; i < packet_length; i++) {
                        printf("%02X ", packet[i]);
                  }
            }

            int dupesReceived = mlr.dupesReceived();
            for (; dupesPrinted < dupesReceived; dupesPrinted++) {
            printf(".");
      }

      printf("\n");
      // Here, packet is clearly not defined, lol, it's defined in an if
      printf("ID %02X%02X;", packet[1], packet[2]);

I am just wondering why this would work for you, am I doing something wrong?

Yeah, I know, it's strange. I think it's because different packets are received and because of byte shifting, the outcome are some wrong groups, because I don't use RGBW bulbs but got a RGBW Lamp instead. So it's not possible to control it right now? I thought that this protocol is for any milight devices >.<

Xento commented 7 years ago

Ahh, I had multiple versions of my repo. I think I fixed the bug.

TehEbil commented 7 years ago

Oh I see, now it makes sense, lol. Unfortunately, I don't have any output. it fails at mlr.available() -> _pl1167.receive(CHANNELS[0])

btw.: do you also get these warnings?

sketch\MiLightRadio.cpp: In member function 'bool MiLightRadio::available()':

sketch\MiLightRadio.cpp:10:50: warning: left shift count >= width of type

 #define PACKET_ID(packet) ( ((packet[1] & 0xF0)<<24) | (packet[2]<<16) | (packet[3]<<8) | (packet[7]) )

                                                  ^

sketch\MiLightRadio.cpp:75:28: note: in expansion of macro 'PACKET_ID'

       uint32_t packet_id = PACKET_ID(_packet);

I played a bit with that code, replaced channels with looping from i=0 to i = 9 and finally I at least get some output:

Packet received: 6D6D6D6D6D6D6D6D6D6D6D6D (unreversed) Packet received: B6B6B6B6B6B6B6B6B6B6B6B6 (reversed) Sync 3h fail (0: B6)

But I don't know what that B6 means, I only know that my remote / lamp communicate over a channel between 0 and 9 (I think 5, 6, 7 and 8 are all possible). Do you guys know what else I can try?

And btw. sorry for spamming that thread

Xento commented 7 years ago

No I don't get this warnings. Is this lamp from milight? If not I think you have to completely reverse engineer the protocol. Milight has some new lights with a different protocol.

TehEbil commented 7 years ago

I actually think it is, at least it looks like one:

click me for photo

Well, so there's still hope that the warnings are the reason for wrong input. Do you know why I get those, if I cloned (downloaded zip) your project, lol?

Which Arduino IDE are you using, or do you compile via linux, maybe another gcc version or something x.x

I also wonder why it is int packet[7] and on the other hand, on the makro define, there is packet[7] (although packet only goes from 0 - 6):

#define PACKET_ID(packet) ( ((packet[1] & 0xF0)<<24) | (packet[2]<<16) | (packet[3]<<8) | (packet[7]) )

As far as I know, ID consists of packet[0] first nib, packet[1] and packet[2], it's kinda confusing for me why 1) he uses 1, 2 & 3 within an usual array and 2) why he xor's it with the last byte (sequence one).

Xento commented 7 years ago

Hmm this lamp should work. The remote looks like mine. I'm using Arduino IDE 1.6.11 I don't know what henryk is doing there ;)

TehEbil commented 7 years ago

hmm, should try it too with 1.6 then, using 1.8.1 right now.

I used another syncword and different channel now from here: http://arduino-projects4u.com/milight-rf-control/ the CW / WW one (although mine is RGBW)

and now I get the following output:

ID 5122;Group 7;All on;Short press;
68 51 21 18 0F 82 01 ....
ID 5121;Group 7;All off;Short press;
68 51 22 18 0F 8E 01 ..................................................................................
ID 5122;Group 7;Brightnes 15;Short press;
68 51 21 18 0F 94 01 ..........................................
ID 5121;Group 7;Group 1 off;Long press;

But unfortunately, it's not what I really pressed on the remote, but for now the one which gives me the least errors (or at least seem to work, lol). And unfortunately, only the M button and the slider work, the other 1-0 buttons work if I e.g. first press in 1 of group one and then 0 of group 2 and so one, rgb slider doesnt work at all x.x

Could you please give me your (hex)code for turning white on? Maybe I can take my id and replace yours, if I am lucky at least that'll work.

Xento commented 7 years ago

I'm sorry I don't have it setup at the moment.

TehEbil commented 7 years ago

Okay, one last question:

Do you know how to fix that pimatic setup? if I do the following:

    {
      "id": "mrf24",
      "name": "mrf24",
      "class": "MilightRF24",
      "port": "/dev/ttyUSB1",
      "zones": [
      ]
    },

I get this error message after restarting: Error loading device "mrf24": Invalid port specified: undefined

It automatically changes to:

      "id": "mrf24",
      "name": "mrf24",
      "class": "MilightRF24",
      "zones": [
        {
          "addr": "test",
          "port": "/dev/ttyUSB1",
          "zone": 0
        }
      ]
Xento commented 7 years ago

I think the device-config-schema.coffee has to be changed.

TehEbil commented 7 years ago

ehm okay, sorry then I got another question;

How can I install a pimatic plugin from github? just clone it and then add it to pimatic-app/node_modules? >.< And don't I have to include it somewhere, too?

mwittig commented 7 years ago

How can I install a pimatic plugin from github?

Please be aware that the current branch is v0.9.x!

  1. cd to pimatic-app/node_modules and rm -rf pimatic-led-light
  2. git clone -b v0.9.x pimatic-led-light
  3. cd pimatic-led-light
  4. npm install
  5. Make sure you have pimatic-led-light configured as part of "plugins" of config.json
TehEbil commented 7 years ago

@mwittig Thank you for your answer, unfortunately, it's not working for me.

I failed at step two, it sais it'd be no repos. Instead, I tried to -b v0.9.x (didnt work either) and at last, I tried to clone the master, add branch v0.9.5, checkout and git pull it, but that doesn't work either (but the last is rather my fault, I don't actually know how to switch to a branch with git).

Gratizzz commented 6 years ago

Any news on the issue "Error loading device "mrf24": Invalid port specified: undefined"? I have the same problem :(.

mwittig commented 6 years ago

@Gratizzz ~did you try the v0.9.x branch. As @TehEbil had difficulties setting it up you may want to try method 1 described at https://forum.pimatic.org/topic/1114/updated-how-to-install-a-plugin-from-github-using-npm-or-git~

v0.9.x is broken. The problem is that @Xento changed the API of the underlying library while he did not updated the MilightRF24 implementation. See my request from February 11 on this thread. Apparently, he no longer maintains this part of the project. I'll try to fix this asap and get back to you as I'll need you for testing. Thanks

Gratizzz commented 6 years ago

@mwittig That would be awesome! I'm ready to test some fixes, just let me know!

Gratizzz commented 6 years ago

@mwittig did you already find some time to look at the issue? Looking forward to have it working :)

Gratizzz commented 6 years ago

@mwittig did you already had a change to look at the issue :) I have my nrf24l01 ready to test!

Gratizzz commented 6 years ago

@mwittig do you already know I you have some time in the near future?