more G-Labs products

Author Topic: MySensors Serial Gateway (v2.0)  (Read 4181 times)

October 12, 2016, 08:10:29 PM
Read 4181 times

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
The MySensor Serial Gateway has been replaced with a combined Serial/Ethernat gateway.

I've created a new thread for this:
http://www.homegenie.it/forum/index.php?topic=1725.0
« Last Edit: October 20, 2016, 07:17:19 AM by mvdarend »

October 12, 2016, 10:29:48 PM
Reply #1

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
Oops... I just realised that the Controller is not handing out NodeIds... :-[ I was using old MySensor Nodes that already had Id's assigned by the previous version I created.

I'll have to fix that, as a workaround you can set the NodeId manually with the following code:

Code: [Select]
#define MY_NODE_ID 1

October 14, 2016, 12:59:06 PM
Reply #2

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
ID_REQUEST is now implemented.

For 'grouped' modules, I've added meta data to the ChildrenNodes to better differentiate between data types.

October 14, 2016, 06:17:59 PM
Reply #3

raptorjr

  • ***
  • Information
  • Full Member
  • Posts: 78
Either this is very easy and I'm complicating things, or I'm really stupid =) I can't figure out how to use it.
I think I have added it as a Interconnection(although I thought first that I should add it as a Interface in some way), but I get a blue light, and that don't feel right. I have tested to add the Serial Gateway in Domoticz, and it works, so I guess it's all about configuring HG the right way.

Any chance of a small walkthrough on how to set up this?

October 14, 2016, 06:43:38 PM
Reply #4

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
Blue light is good, it means that the APP is running correctly (in the background)

If the COM port and baud rate are correct you can try modifying the code slightly to see if messages are being received correctly, you can do this as follows:

- Go to: Configure -> Programs -> Interconnections -> MySensors APP and click on it
- Click on Edit
- Go to tab 'Program code'

At line 27 uncomment the the line Program.Notify (also comment the Pause line if you want:
Code: [Select]
  // this will be called every time a message is received from serial port
  //Program.Notify("SerialPort String", incoming);
  //Pause(5);

You should now see if messages are arriving in Homegenie, Power cycle (or reset) the gateway or one of the sensors to force it to Present itself again and see if you are getting popups in HomeGenie (see image example)

Edit: Forgot to add, once all is OK, you'll need to add the actual module (or widgets) to the interface, you can do this as follows:

- Go to Configure -> Groups
- Create a new group and open it (or open an existing one)
- Go to Actions -> Add Module
- You should see a group 'HomeAutomation.MySensors' with the modules
« Last Edit: October 14, 2016, 06:52:12 PM by mvdarend »

October 14, 2016, 07:00:06 PM
Reply #5

raptorjr

  • ***
  • Information
  • Full Member
  • Posts: 78
Thank you for your help. But it doesn't seem to be anything coming in to HG.

If I do  cat /dev/ttyUSB20 and restart my MySensor node. I get this:

1;255;0;0;17;2.0.1-beta
1;255;3;0;6;0
1;255;3;0;11;FishTank
1;255;3;0;12;1.0
1;1;0;0;6;Water temperature
1;2;0;0;3;Water valve
1;3;0;0;21;Water flow
1;3;1;0;34;0.0
1;3;1;0;35;0.00
1;1;1;0;0;24.7
1;3;1;0;34;0.0
1;3;1;0;35;0.00
1;1;1;0;0;24.7

First presenting name and sensors attached, and then starting to report temperature and water flow/volume.
But I don't get any message in HG.

This is my configuration of MySensor Serial gateway in HG:
    BaudRate = "115200"
    Fri Oct 14 2016 17:54:10 GMT+0200 (W. Europe Standard Time)
    COMPort = "/dev/ttyUSB20"
    Fri Oct 14 2016 17:54:45 GMT+0200 (W. Europe Standard Time)
    GroupSubDevices = "True"
    Fri Oct 14 2016 17:54:10 GMT+0200 (W. Europe Standard Time)
    InclusionMode = "True"
    Fri Oct 14 2016 17:54:10 GMT+0200 (W. Europe Standard Time)
    Module Parameters
    Program.Status = "Background"
    Fri Oct 14 2016 18:55:29 GMT+0200 (W. Europe Standard Time)

October 14, 2016, 07:09:49 PM
Reply #6

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
When you restart the MySensor APP do you see a 'MySensors COM Port Status CONNECTED!' popup?

October 14, 2016, 07:14:24 PM
Reply #7

raptorjr

  • ***
  • Information
  • Full Member
  • Posts: 78

October 14, 2016, 07:20:34 PM
Reply #8

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
Have you ever clicked on the Stop/Hand icon when you got one of those popus? That could be the reason you're no longer getting them.

If you have you can remove it from the Blocked popup list as follows:

- Configure -> Maintenance
- Open User Interface
- Click on Blocked Popups -> Edit button
- Remove the blocked popup from the list

There's a good chance that modules have already been created, but that there was no notification because of the blocked popups, have you tried adding a new module to a group yet, can you see the mysensors modules in the list?

October 14, 2016, 07:28:28 PM
Reply #9

raptorjr

  • ***
  • Information
  • Full Member
  • Posts: 78
No blocked popups. Haven't done much with HG other than trying the demo things. I only have MySensors nodes, so before you made this I hadn't anything to test with.

I have no module that has anything to do with MySensors. I guess the sensors should appear below a bold/italic text that says something about MySensors.FishTank or something like that? (Since that is the name of my node)

Can I add some more log printing in the Program to see how far we get in the code? Or is there some HG log that can tell us anything?

October 14, 2016, 07:38:05 PM
Reply #10

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
I have no idea what could be wrong, not getting a 'Serial connected' (or even a connection error) popup seems strange, especially seeing as the App has a blue icon which means it is running.

Could you try going to COnfigure -> Maintenance -> Configuration and Data -> Modules cleanup -> Select Modules?

Do you see any MySensor nodes in the list?

October 14, 2016, 07:47:03 PM
Reply #11

raptorjr

  • ***
  • Information
  • Full Member
  • Posts: 78
Yes, it says 1000 MySensors Serial Gateway.

Could it be som kind of permission issue on my Raspberry Pi3?
« Last Edit: October 14, 2016, 07:50:25 PM by raptorjr »

October 14, 2016, 07:54:22 PM
Reply #12

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
Not sure if it could be a permissions issue, I'm running HomeGenie on a Windows machine and I don;t know very much about Linux.

Is Domoticz still running on your RPi? Could it be blocking the COM port? (or some other program?)

I forgot to answer your last question, the code you uncommented earlier is the first line of code after a message has been received on the COM port, if that isn;t showing anything then there is no message being received.

October 14, 2016, 07:55:57 PM
Reply #13

raptorjr

  • ***
  • Information
  • Full Member
  • Posts: 78
Domoticz is running. But I can stop it. Thought it shouldn't be a problem since I got output from /dev/ttyUSB20. But I'll try.


No, didn't make a change. Stopped Domoticz and restarted the APP. No message.

You say that the first thing received. But what if the port can't be opened? Is it possible to add some debug output on the call to open the port? To see if that fails? Or that should always generate Connected or Disconnected?
« Last Edit: October 14, 2016, 08:00:24 PM by raptorjr »

October 14, 2016, 08:16:45 PM
Reply #14

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
I'm not sure how to get more feedback from the Serial connection, I only get a true or false back.

In Maintenance -> System options you can enable to log file. If it's already been enabled open it and search for the COM port address.

If it has not been enabled you can do it now and then restart the APP, hopefully you'll find some info in there.

I tested it with a non-existant port number on my machine and got the following in the logs:

Code: [Select]
2016-10-14 20:11:01.4140 Error System.IO.IOException: The port 'COM55' does not exist.
   at System.IO.Ports.InternalResources.WinIOError(Int32 errorCode String str)
   at System.IO.Ports.SerialStream..ctor(String portName Int32 baudRate Parity parity Int32 dataBits
   at System.IO.Ports.SerialPort.Open()
   at SerialPortLib.SerialPortInput.Open()

Edit: By using a non existant COM port I could reproduce the problem you seem to be getting. Maybe I'm parsing the COM port string incorrectly (I've only tested it on a Windows machine)
« Last Edit: October 14, 2016, 08:18:47 PM by mvdarend »