more G-Labs products

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

October 15, 2016, 08:34:37 PM
Reply #30

Orkspalter

  • *
  • Information
  • Newbie
  • Posts: 6
Hi Marcel,

thank you for offering me your help with my problem setting up MySensors MQTT which i am still making no progress, i will pm you about that, thanks !!
The gateway i have built is the ESP8266 Mqtt gateway so i will not be able to use your new 2.0 sensors app but will you adapt it to the MQTT aswell ?

I am thinking of setting up a arduino nano and building a serial gateway just to try out your 2.0 app on my raspberry pi but mqtt is the way to go for me because all the options you have. Do you think it will work if having running a PI with both homegenie and node red on it, that both apps can use one serial gateway at the same time, using the same usb which it is connected ? As in node red, i can turn a serial gateway into mqtt and vice versa, so i could have a serial gateway in homegenie with your app and still having at the same time a mqtt gateway for using with node red?

October 15, 2016, 09:08:48 PM
Reply #31

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
Hi,

I'm not sure if you can create two connections to a single COM port, raptorjr managed to read the port with Cat while Domoticz was still connected to the port, so I imagine it shouldn't be a problem.

raptorjr also adapted my code to work with the MySensor Ethernet gateway, is that an option for you? MQTT messages are a lot different to the standard MySensor messages, I'm not sure if I can find the time to create/maintain another version.

October 16, 2016, 12:33:58 AM
Reply #32

raptorjr

  • ***
  • Information
  • Full Member
  • Posts: 78
I'm trying to experiment a little and make some changes to try and learn how HG and programs work. But doing this it seems that even though a program is not enabled, it still produces Popups?

If I restart my Arduino so it starts with presentation. Both the original gateway, by mvdarend, and my modified shows popups of added sensors, even though none of those two programs is enabled and running.

That can't be right?

October 16, 2016, 07:29:02 AM
Reply #33

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
No, that doesn't sound right. When I stop the Serial version, I get a 'Serial disconnected' popup (are you seeing that?), but I haven't noticed a 'Disconnected' with the Ethernet version, not sure why.

Is it possible that when you imported the program that you might have imported it more than once? Could you try checking all of the program groups to make sure that you don;t have a second instance hidden away and running?

October 16, 2016, 08:39:38 AM
Reply #34

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
OK, I think I've found the problem, I'm not sure, but I think that in your code the Instance of TcpHelper is not shutting down properly and an instance of the program keeps running in the background.

For me the following worked:

Remove line 31:
Code: [Select]
TcpClientHelper tcpConnection = new TcpClientHelper();
And then change all instances of tcpConnection, rename to TcpClient.

After that restart the HomeGenie service and the problem should be resolved.

October 16, 2016, 09:58:21 AM
Reply #35

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
I've combined the Serial en Ethernet connections into one app. You can now swtich between the two.

I've also created a few custom Sensor types for HomeGenie, to get these to display properly you'll have to edit the homegenie.generic.sensor widget (until I've found a proper solution) you can do this as follows:

- Configure -> Widgets
- open the homegenie.generic.sensor widget
- Click on the Javascript tab
- Scroll down to line 154 and change it to the following:
From this:
Code: [Select]
if (!ctx.isUnknown) {to this:
Code: [Select]
if (!ctx.isUnknown || parameter.Name.indexOf("Sensor.") >= 0 ) {- Actions -> Save

You can test it by clicking the Run/Preview button and binding to an existing module.
« Last Edit: October 20, 2016, 07:17:39 AM by mvdarend »

October 16, 2016, 11:26:14 AM
Reply #36

raptorjr

  • ***
  • Information
  • Full Member
  • Posts: 78
The gateway seems to work fine. (Although I think it looks better with default ip to be 127.0.0.1)

I changed the javascript code, but don't really know what change to look for?

But when talking about widgets. The water flow widget needs some changing, and I don't know if I need to create a completely new widget? As it is now it is always Off, and when I blow in my flow sensor to emulate a flow, the widget turns On when the total volume is > 0. Goes back to Off when I reset the total volume.

Eventually I need to find out how to make widgets and make a real water flow widget with both total volume and current water flow, but until then. Is there another widget that can be used to at least show the value from total volume?
« Last Edit: October 16, 2016, 11:28:14 AM by raptorjr »

October 16, 2016, 11:44:57 AM
Reply #37

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
I've changed the above example for changing the javascript code in the widget, it should be clearer now. Once you've modified it it should show the actual Flow value (if your using the latest version of the script)

Good catch on the default IP address, I'll change it.

One more thing, Widgets will often 'hold on' to old values, even if theyre no longer being used. By going to the parameters of the widget you can delete the old values. (Configure -> Groups -> Select group -> Select hamburger menu for widget) Delete any old values. (in your case Sensor.Generic, or Status.value i'm not sure which)

« Last Edit: October 16, 2016, 11:48:31 AM by mvdarend »

October 16, 2016, 12:20:49 PM
Reply #38

raptorjr

  • ***
  • Information
  • Full Member
  • Posts: 78
I'm using the version from your previous post. I removed all the modules (don't know if that is needed or if I can change a module manually, or if they get updated if I restart my MySensors node?)

When I added all again this is how my Water flow widget look now:


October 16, 2016, 03:16:58 PM
Reply #39

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
Have you also modified the widget in the widget editor?

October 16, 2016, 03:19:26 PM
Reply #40

raptorjr

  • ***
  • Information
  • Full Member
  • Posts: 78
Yes I have. Line 153-155 looks like this. Changed Line 154.

Code: [Select]
        var ctx = $$.ui.GetParameterContext($$.module, parameter.Name, parameter.Value);
        if (!ctx.isUnknown || parameter.Name.indexOf("Sensor.") >= 0) {
          var paramBox = $(paramTemplate);

October 16, 2016, 03:31:13 PM
Reply #41

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
Not sure what it could be, when editing and chaning a prgram (with widgets) in HG sometimes the widgets will start acting in strange ways, here's a few things you can check:

- In the parameters menu (Hamburger menu) of the widget do you see 'Sensor.Flow' in the list?
- Is the value of 'VirtualModule.ParentId' the same as the MySensors prgram Id?

If all else fails I usually remove all traces of the widget/module by doing the following:

- Stop the MySensor APP
- Remove all the MySensor widgets
- Remove all MySensor modules via 'Modules Cleanup'. (Only the actual widget modules, not the prpgram itself.)

Restart HOmeGenie and check to see no traces of the MySensor widgets are lef. Then try starting everything back up and add the widgets again.

October 17, 2016, 04:37:48 PM
Reply #42

raptorjr

  • ***
  • Information
  • Full Member
  • Posts: 78
Is it the gateway or HG that should take care of ACK from the node/sensor? Noticed yesterday that my relay didn't engage, and HG didn't care. Thought that it was on.
Feels like a important thing for on/off modules. But maybe no support for this in HG?

October 17, 2016, 04:42:44 PM
Reply #43

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
I haven't looked into ACK properly yet, after a quick read of the docs yesterday I think it works as follows:

ACK request from node: Handled by Gateway, if I have understood it correctly.

ACK request from HG: ACK response handled by HG, not yet implemented.

October 17, 2016, 10:39:34 PM
Reply #44

imedia

  • *
  • Information
  • Newbie
  • Posts: 1
Hi.

I managed to install your mysensors code and I can see the notifications showing up with the serial data but I cannot add the module to the group it is not listed in the module list. There is no HomeAutomation.MySensors in the list.