flavio / scsgate

A python module to interact with the SCSGate device
MIT License
5 stars 6 forks source link

SCSGate Cover doesn't work after some time #5

Open Max-Bel opened 5 years ago

Max-Bel commented 5 years ago

Home Assistant 0.82.0 SCSGATE SCSGATE cover

I'm in front of a boring behaviour with scsgate cover... after some time that I don't use Home Assistant the cover doesn't work anymore. I need execute homeassistant.restart in order to resolve (temporarely) the issue.

configuration.yaml:

SCSGate

scsgate: device: /dev/ttyACM0

cover:

Any idea?

How can reset/restart scsgate by homeautomation?

flavio commented 5 years ago

I wonder if this is a problem with the python code or with the firmware on the SCS device; I suspect the second one.

At boot time the SCSGate connection performs a reset of the firmware by sending some specific commands (see there).

Can you try to perform these operations manually using something like minicom?

Max-Bel commented 5 years ago

I tried to perform the command manually via serial and this works fine. I suspecting the issue depend of SCSGate connection timeout...

In order to check if my suspect was correct, I implemented this automation configuration:

- id: keep_alive
  alias: Keep Alive
  trigger:
  - event_data: {}
    event_type: keepalive
    platform: event
  - event: start
    platform: homeassistant
  action:
  - data:
      entity_id: cover.keep_alive
    service: cover.stop_cover
  - delay: '2'
  - data:
      entity_id: cover.keep_alive
    service: cover.open_cover
  - delay: '180'
  - event: keepalive
    event_data: {}

Obviously the cover.keep_alive is configured as a dummy cover (with an id not exixtent).

In this way the HA works fine also after some hours.

It's possible for you implementing some solution like that ("keep alive" like) in python?

Thank you very much.

flavio commented 5 years ago

I suspecting the issue depend of SCSGate connection timeout...

Wait a second... what kind of SCSGate device are you using, is that the one connected via USB or WiFi?

Max-Bel commented 5 years ago

USB

flavio commented 5 years ago

Sorry for the delay, it's a pretty busy time.

Can you provide me the following information:

Also, looking at your previous example (BTW, I fixed the code by quoting the yaml snipped with the `` symbols), I struggle to find the event typekeepalive` inside of homeassistant documentation... Can you share some light about that?

I'm currently puzzled by your issue, right now the code keeps asking the SCSGate device to provide status updates:

https://github.com/flavio/scsgate/blob/aad1d181eef4714ab475f4ff7fcfac4a6425fbb4/scsgate/reactor.py#L38-L52

Also, I never run into that at home despite I have covers :disappointed:

Max-Bel commented 5 years ago

Hi Flavio, The SCSGate firmware version is 18.60 and the Home Assistant is 0.82.1.

The keepalive mechanism I implemented, was for check if the issue was relate to connection timeout, but the mechanism has not resolved the issue.

So I used the alternative platform: "command_line" for my covers ;-), this is the yaml code:

- platform: command_line
    covers:
      tapparella_della_cameretta:
        command_open: 'echo @w822 > /dev/ttyACM0'
        command_close: 'echo @w922 > /dev/ttyACM0'
        command_stop: 'echo @wA22 > /dev/ttyACM0'
        friendly_name: Tapparella della Cameretta
      tutte_le_tapparelle:
        command_open: 'echo @W7A8B1001208ABA3 > /dev/ttyACM0'
        command_close: 'echo @W7A8B1001209AAA3 > /dev/ttyACM0'
        command_stop: 'echo @W7A8B100120AA9A3 > /dev/ttyACM0'
        friendly_name: Tutte le Tapparelle

In this way I didn't have restriction to interface directly the SCSGate via Serial and I could send complex (or long ) message like "@W...."

When I have some time a will test your new code and I will let you a feedback.

Thanks Massimo

flavio commented 5 years ago

When I have some time a will test your new code and I will let you a feedback.

Actually there's no new code :smile:

I'm chasing down another bug, from time to time homeassistant is not able to send commands or receive updates from the SCS device. The only solution is to restart homeassistant. Have you ever faced that?

I think I've found a deadlock into the code and I've a theory about how to reproduce it.