MySensors - Gateway to Domoticz

Re: MySensors - Gateway to Domoticz

Already checked, this is the detail (setup) of sensor 11 on domoticz gui :

sensor setup

capture-mysensors.png (125.22 KiB) Viewed 3982 times

1) Sensors 2 and 3 receive message type 36. This is the received message on my node : 11;2;1;1;36;1\n

2) Looking at the picture, I just realize that sensor 5 and 6 are last seen today a few minutes ago when I used my garage door (so the notification is received) but the state is not reported on domoticz display.

3) I don't know what sensor 111 and 255 are. Any idea ?

Re: MySensors - Gateway to Domoticz

Posted: Monday 16 November 2015 16:50

by alexsh1

If USB connection is broken in case of the serial gateway, I can see it in the logs: Error opening /dev/USB20, trying in 30 secs.
What about the ethernet gateway? I cannot see Domoticz checking its presence and if it is disconnected then one has to restart Domoticz to make it work.
Am I correct?

Re: MySensors - Gateway to Domoticz

Posted: Monday 16 November 2015 19:02

by gizmocuz

alexsh1 wrote:If USB connection is broken in case of the serial gateway, I can see it in the logs: Error opening /dev/USB20, trying in 30 secs.
What about the ethernet gateway? I cannot see Domoticz checking its presence and if it is disconnected then one has to restart Domoticz to make it work.
Am I correct?

If the TCP connection gets disconnected it is displaying this in

MySensorsTCP::OnDisconnect()

if it is connected, a message is logged here:

void MySensorsTCP::OnConnect()

the only thing that is missing is a log message

Connecting to .....

Will implement this in the next beta version

Re: MySensors - Gateway to Domoticz

Posted: Monday 16 November 2015 19:13

by alexsh1

gizmocuz wrote:
the only thing that is missing is a log message

Connecting to .....

Will implement this in the next beta version

You are the star! I have been running MYSController in the absence of any TCP logging in Domoticz, but now ...

Re: MySensors - Gateway to Domoticz

Posted: Monday 16 November 2015 20:06

by gizmocuz

alexsh1 wrote:

gizmocuz wrote:
the only thing that is missing is a log message

Connecting to .....

Will implement this in the next beta version

You are the star! I have been running MYSController in the absence of any TCP logging in Domoticz, but now ...

New beta available #3603

have not tested it, i will have to build a ethernet gateway soon (no arduino's left)

Hope it works

Re: MySensors - Gateway to Domoticz

Posted: Monday 16 November 2015 21:34

by alexsh1

gizmocuz wrote:

alexsh1 wrote:

gizmocuz wrote:
the only thing that is missing is a log message

Connecting to .....

Will implement this in the next beta version

You are the star! I have been running MYSController in the absence of any TCP logging in Domoticz, but now ...

New beta available #3603

have not tested it, i will have to build a ethernet gateway soon (no arduino's left)

Hope it works

Upgrading and testing now.
Another unrelated question - do you know which value I should change in the DB (domoticz.db) in order to change the total consumption value (MySensors - node 10 - child 1)
I have changed the value below, but it did not work.

Re: MySensors - Gateway to Domoticz

Posted: Monday 16 November 2015 21:45

by alexsh1

gizmocuz wrote:

alexsh1 wrote:

gizmocuz wrote:
New beta available #3603

have not tested it, i will have to build a ethernet gateway soon (no arduino's left)

EDIT: I have to restart domoticz every time I power down/power up the gateway. Otherwise it is not seen by domoticz unlike the serial gateway.

Re: MySensors - Gateway to Domoticz

Posted: Tuesday 17 November 2015 8:25

by gizmocuz

Okey, i have to build myself an Ethernet controller to test this

Re: MySensors - Gateway to Domoticz

Posted: Tuesday 17 November 2015 11:24

by alexsh1

gizmocuz wrote:Okey, i have to build myself an Ethernet controller to test this

As I have one, can I be of any assistance to you at all?

Re: MySensors - Gateway to Domoticz

Posted: Tuesday 17 November 2015 11:36

by darknico31

I can confirm I have the same behavior.
I have to restart domoticz when I restart my Ethernet gateway.
Also available to assist

Edit: A workaround would be to set a data timeout on the ethernet gateway.
But, it's not the good way to do that.

Re: MySensors - Gateway to Domoticz

Posted: Tuesday 17 November 2015 20:00

by gizmocuz

Okey, build a ethernet gateway

there is no way of knowing that you unplugged your ethernet gateway, it is not a gracefully shutdown of the tcp socket

there is only one option, and that is set the data timeout in the hardware setup.

For instance you know you should receive data at least every 5 minutes (or minute), then you set the data timeout to 5 minutes.
If nothing is received for 5 minutes, then it mysensors ethernet hardware is restarted

i checked if i received 0 bytes, or an error, but nothing is received... it is just waiting for new data

of course you won't unplug the ethernet gateway often, but i would set the above data timeout to be sure.

another issue, it seems the ethernet gateway does not send the gateway version info on connect... (serial does)
Fixed, and will be available in the next beta version

Re: MySensors - Gateway to Domoticz

Posted: Tuesday 17 November 2015 20:22

by darknico31

It's nice that you fixed the version "problem".
Data timeout will work, but it's not very "clean".
If we don't have sensors and only actuator, it will not work.

Maybe we can work on some keepalive ?
A quick google search confirm that W5100 support sending keepalive.

I'll try to mod the gateway sketch to send keepalive and see what's happen.
I'll let you know.

Re: MySensors - Gateway to Domoticz

Posted: Tuesday 17 November 2015 20:32

by gizmocuz

darknico31 wrote:It's nice that you fixed the version "problem".
Data timeout will work, but it's not very "clean".
If we don't have sensors and only actuator, it will not work.

Maybe we can work on some keepalive ?
A quick google search confirm that W5100 support sending keepalive.

I'll try to mod the gateway sketch to send keepalive and see what's happen.
I'll let you know.

Great, in the mean time i asked Henrik if a PING/PONG solution might work

If we don't have sensors and only actuator, it will not work.

true

Re: MySensors - Gateway to Domoticz

Posted: Wednesday 18 November 2015 0:20

by darknico31

If by ping/pong you mean icmp ping.
I don't think it could work.
Because if you ping lets say, every minute, the gateway boot time is so fast that you will never miss a ping.
And after restart, the telnet connection will be dead but the ping ok.

I dug a little more about W5100 keepalive. it seems to exist but I couldn't find anyone who make it work.

So here is another idea, why not use mysensors protocol to make or own "keep-alive".
If we try to send anything over the broken connection we should be able to catch the error and restart the worker.
We can for example request the gateway version every x min.

Re: MySensors - Gateway to Domoticz

Posted: Wednesday 18 November 2015 20:01

by gizmocuz

I meant via the mysensors method

I made a new beta version that now handles this case (#3608)

It may take up to 30 seconds.... but we now use the I_HEARTBEAT message,
it needs to be checked as i do not receive anything back, but sending this, will cause the TCP class to know there are problems

Re: MySensors - Gateway to Domoticz

Posted: Wednesday 18 November 2015 23:19

by darknico31

Nice, I didn't know about the I_HEARTBEAT message.
Is this a mysensors 1.6 thing ?
Because it's not referenced here : http://www.mysensors.org/download/serial_api_15
In your code you use internal code 18, and the documentation stop at 17.

Re: MySensors - Gateway to Domoticz

Posted: Thursday 19 November 2015 8:42

by gizmocuz

Yes, its part of 1.6, and not documented
also 1.5 gateways will ignore it, so it works for this as well

but is it working?

Re: MySensors - Gateway to Domoticz

Posted: Thursday 19 November 2015 10:28

by darknico31

I've just compiled a fresh 3608.
I'm not a home, so I have no way to shutdown the ethernet gateway to test.
I'll will test as soon as a get home.
I'll keep you informed.

Speeking of 1.6, the other day, in have found a page that explained how to modify 1.5 sketch to be 1.6.
I don't find it anymore. Do you have a link to something like that ?

Re: MySensors - Gateway to Domoticz

Posted: Friday 20 November 2015 11:27

by darknico31

I've done some tests yesterday.
It acted weird at first but it seems ok now.

First restart after compiling, I've not looked on the logs, but it was connected.
When I came home, I reset the gateway and waited for the keepalive to do is job, but nothing happened (I've waited at least 5min).
So I decided to restart domoticz, but the only log entry about mysensors was "trying to connect to ..." but It never seems to try.
I've restarted domoticz again, and this time it was connected, gateway version appeared , sensor OK.
After that every gateway reset triggered the keepalive functionality.
Even with more domoticz restart (I really tried to stress it).
The only downside I see is that the keepalive functionality only work in case of gateway reset.
If the gateway is really down, nothing happen.
Probably because when the gateway is reset, it's send back a connection refused/reset when domoticz try to use the old connection.
When the gateway is down nothing is send back, so domoticz do nothing.
The problem is if you do something when there is no response to the heartbeat request, it will not work with the version 1.5 that ignore the heartbeat.
Maybe we could us the gateway version request to determine how to act with the heartbeat non response.
BTW, All my tests were done with an 1.5 gateway.
I'll try to make an 1.6 version this weekend.

Re: MySensors - Gateway to Domoticz

Posted: Saturday 21 November 2015 15:54

by gizmocuz

there has been an update to the 1.6 development branch
try using the new code to make your ethernet gateway
working good here

you get log messages from two different classes, the MySensorsTCP and the AsyncTCP class
the asynctcp will try to reconnect every 30 seconds