ggeorgovassilis / linuxscripts

Script collection for linux
Other
391 stars 113 forks source link

Check JSON response for relay_state in cmd_print_plug_relay_state #3

Closed marukuru closed 8 years ago

marukuru commented 8 years ago

I just purchased a HS100 with the most recent firmware installed. I noticed, that the simple AAACJ/AAACK match in cmd_print_plug_relay_state didn't work for my plug, because in both states my plug returned a message starting with AAACGNDygfiL*. I modified cmd_print_plug_relay_state to decode the plug's response and check for the value of relay_state with a simple egrep. This should be more robust and universal.

ggeorgovassilis commented 8 years ago

Thanks! I'd like to merge the new signatures in, but stick with the simple pattern matching instead of decoding. The reason is that decoding is slow and uses programmes that are not available on all platforms; I'd like to maintain the most basic functionality (on/off) with as little dependencies as possible.

ggeorgovassilis commented 8 years ago

My plug seems to also have changed the output format just like yours, so this is probably some timestamp. In this light I think your approach is better and more stable, I'm merging it in.

marukuru commented 8 years ago

Thanks :)

ggeorgovassilis commented 8 years ago

I thank you! :)