pihome-shc / pihome

PiHome - Smart Heating, Ventilation and Air Conditioning (HVAC)
http://www.pihome.eu
Other
52 stars 25 forks source link

Terminate gateway script if route to network gateway is lost, see #444 #455

Closed twa127 closed 3 years ago

pihome-shc commented 3 years ago

444

pihome-shc commented 3 years ago

i see this implementation ping gateway in between messages. is this expected behavior?

also you have indentation wrong on line 104 i think

    while 1:
        ## Terminate gateway script if no route to network gateway
        if gatewaytype == "wifi":
            gateway_up  = True if os.system("ping -c 1 " + gatewaylocation) is 0 else False
            if not gateway_up:
                break

--- 192.168.99.3 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 2.204/2.204/2.204/0.000 ms
PING 192.168.99.3 (192.168.99.3) 56(84) bytes of data.
64 bytes from 192.168.99.3: icmp_seq=1 ttl=255 time=7.37 ms

--- 192.168.99.3 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 7.373/7.373/7.373/0.000 ms
PING 192.168.99.3 (192.168.99.3) 56(84) bytes of data.
64 bytes from 192.168.99.3: icmp_seq=1 ttl=255 time=5.93 ms

--- 192.168.99.3 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 5.931/5.931/5.931/0.000 ms
PING 192.168.99.3 (192.168.99.3) 56(84) bytes of data.
64 bytes from 192.168.99.3: icmp_seq=1 ttl=255 time=3.83 ms

--- 192.168.99.3 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 3.830/3.830/3.830/0.000 ms
PING 192.168.99.3 (192.168.99.3) 56(84) bytes of data.
64 bytes from 192.168.99.3: icmp_seq=1 ttl=255 time=2.63 ms

--- 192.168.99.3 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 2.625/2.625/2.625/0.000 ms

Size of the String Received:  42
Date & Time:                  Fri Apr 30 23:25:34 2021
Full String Received:         20;1;1;0;38;3.43
Full Statement Received:      ['20', '1', '1', '0', '38', '3.43\n']
Node ID:                      20
Child Sensor ID:              1
Message Type:                 1
Acknowledge:                  0
Sub Type:                     38
Pay Load:                     3.43
6: Battery Voltage for Node ID: 20  Battery Voltage: 3.43
PING 192.168.99.3 (192.168.99.3) 56(84) bytes of data.
64 bytes from 192.168.99.3: icmp_seq=1 ttl=255 time=2.95 ms

--- 192.168.99.3 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 2.948/2.948/2.948/0.000 ms

Size of the String Received:  41
Date & Time:                  Fri Apr 30 23:25:34 2021
Full String Received:         20;255;3;0;0;46
Full Statement Received:      ['20', '255', '3', '0', '0', '46\n']
Node ID:                      20
Child Sensor ID:              255
Message Type:                 3
Acknowledge:                  0
Sub Type:                     0
Pay Load:                     46
7: Adding Battery Level & Voltage for Node ID: 20 Battery Level: 46
PING 192.168.99.3 (192.168.99.3) 56(84) bytes of data.
64 bytes from 192.168.99.3: icmp_seq=1 ttl=255 time=2.37 ms

--- 192.168.99.3 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 2.374/2.374/2.374/0.000 ms

Size of the String Received:  41
Date & Time:                  Fri Apr 30 23:25:38 2021
Full String Received:         20;0;1;0;0;20.4
Full Statement Received:      ['20', '0', '1', '0', '0', '20.4\n']
Node ID:                      20
Child Sensor ID:              0
Message Type:                 1
Acknowledge:                  0
Sub Type:                     0
Pay Load:                     20.4
5: Adding Temperature Reading From Node ID: 20  Child Sensor ID: 0  PayLoad: 20.4
5a: Adding Temperature Reading to Graph Table From Node ID: 20  Child Sensor ID: 0  PayLoad: 20.4
PING 192.168.99.3 (192.168.99.3) 56(84) bytes of data.
64 bytes from 192.168.99.3: icmp_seq=1 ttl=255 time=2.22 ms

--- 192.168.99.3 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 2.222/2.222/2.222/0.000 ms
PING 192.168.99.3 (192.168.99.3) 56(84) bytes of data.
64 bytes from 192.168.99.3: icmp_seq=1 ttl=255 time=6.60 ms
pihome-shc commented 3 years ago

i think this ping is killing gateway connection, i have gateway connect issue once every few minutes, i have commented out and i will keep eye on this for next few days.

        ## Terminate gateway script if no route to network gateway
        ##if gatewaytype == "wifi":
        ##  gateway_up  = True if os.system("ping -c 1 " + gatewaylocation) is 0 else False
        ##  if not gateway_up:
        ##      break 
twa127 commented 3 years ago

Hi,

I'm using an ethernet gateway and never see this issue. All the code does is ping the local router, so unless the wifi connection keeps dropping there should not be a problem

pihome-shc commented 3 years ago

Even when i run script from shell it gets disconnected after short while, I think best to remove ping lins

On 23 May 2021, at 13:13, twa127 @.***> wrote:

Hi,

I'm using an ethernet gateway and never see this issue. All the code does is ping the local router, so unless the wifi connection keeps dropping there should not be a problem

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe.

twa127 commented 3 years ago

we put the check in to cover the case where the gateway hangs if it looses its connection to the network with no indication to the user as per #444