Command line generating never-ending processes connected to HASS

Hello everyone.

Having a strange behavior in my HA with a new automation I have set up, and cannot figure out why. Was wondering if someone had a clue. Let me explain.

I have a Set Top Box connected to my TV and found out it can receive commands on a specific port.

So I wondered: it would be nice if I could turn off the set top box when the TV (Samsung Smart TV setup in HA), is also powered off.

So what I defined a shell command (the ping before is to try to check if the set top box is actually available):
vdf_box_off: 'if ping -c1 -W1 192.168.1.65 >/dev/null 2>&1; then /bin/echo "key=151"|/bin/nc 192.168.1.65 8082; fi'

and then created an automation:

- alias: 'TV Off - Box Off'
  trigger:
    platform: state
    entity_id: 'media_player.tv_sala'
    from: 'on'
    to: 'off'
  action:
    service: shell_command.vdf_box_off

This usually works, but I noticed that when looking at my RPi HASS service status, I sometimes have multiple processes opened for this shell command:

[email protected] - Home Assistant for homeassistant
   Loaded: loaded (/etc/systemd/system/[email protected]; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2018-01-06 23:36:58 UTC; 49min ago
 Main PID: 24751 (hass)
   CGroup: /system.slice/system-home\x2dassistant.slice/[email protected]
           ├─24751 /srv/homeassistant/bin/python3 /srv/homeassistant/bin/hass
           ├─25433 /bin/sh -c if ping -c1 -W1 192.168.1.65 >/dev/null 2>&1; then /bin/echo "key=151"|/bin/nc 192.168.1.65 8082; fi
           └─25436 /bin/nc 192.168.1.65 8082

Jan 06 23:37:13 hassbian hass[24751]: 2018-01-06 23:37:13 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: service=di
Jan 06 23:37:13 hassbian hass[24751]: 2018-01-06 23:37:13 INFO (MainThread) [homeassistant.bootstrap] Home Assistant core initialized
Jan 06 23:37:13 hassbian hass[24751]: 2018-01-06 23:37:13 INFO (MainThread) [homeassistant.loader] Loaded history from homeassistant.components.histor
Jan 06 23:37:13 hassbian hass[24751]: 2018-01-06 23:37:13 INFO (MainThread) [homeassistant.loader] Loaded recorder from homeassistant.components.recor
Jan 06 23:37:13 hassbian hass[24751]: 2018-01-06 23:37:13 INFO (MainThread) [homeassistant.loader] Loaded http from homeassistant.components.http
Jan 06 23:37:13 hassbian hass[24751]: 2018-01-06 23:37:13 INFO (MainThread) [homeassistant.loader] Loaded mqtt from homeassistant.components.mqtt
Jan 06 23:37:13 hassbian hass[24751]: 2018-01-06 23:37:13 INFO (MainThread) [homeassistant.loader] Loaded logger from homeassistant.components.logger
Jan 06 23:37:13 hassbian hass[24751]: 2018-01-06 23:37:13 INFO (MainThread) [homeassistant.setup] Setting up logger
Jan 06 23:37:41 hassbian hass[24751]: 2018-01-06 23:37:41 ERROR (Thread-5) [miio.device] Got error when receiving: timed out
Jan 06 23:37:42 hassbian hass[24751]: 2018-01-06 23:37:42 ERROR (Thread-21) [miio.device] Got error when receiving: timed out

Unlike other processes, these seem to stay there forever and they pile up, which is even worst.

Shouldn’t this process just go away even if it cannot be executed?

Can anyone help me figure this out?

Thanks in advance.