Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

binary characters found in status payload #8

Open
spideyb opened this issue Apr 24, 2017 · 4 comments
Open

binary characters found in status payload #8

spideyb opened this issue Apr 24, 2017 · 4 comments

Comments

@spideyb
Copy link

spideyb commented Apr 24, 2017

I found that running the status payload was returning binary characters, adjusting cmd_print_plug_relay_state() to the following strips it out (added tr -cd '\11\12\15\40-\176'):

output=send_to_plug $ip $port "$payload_query" | decode | tr -cd '\11\12\15\40-\176' | egrep -o 'relay_state":[0,1]' | egrep -o '[0,1]'

@ggeorgovassilis
Copy link
Owner

Thanks @spideyb . Which device/firmware version?

@spideyb
Copy link
Author

spideyb commented Apr 27, 2017

HS110 v1.0 - Firmware: 1.0.8
HS200 v1.0 - Firmware: 1.1.0

BTW - thanks for the scripts, real useful

@Beanux
Copy link

Beanux commented Sep 17, 2020

Hello, i got the same "issue".
But i decided to deal with it by adding "a" as option of the first egrep. This allow grep to check content as text even with binary char.
Because the binary character is outside of the json, it doesn't pose any trouble to match the string relay_state.

the egrep become: send_to_plug $ip $port "$payload_query" | decode | egrep -oa 'relay_state":[0,1]' | egrep -o '[0,1]'

and this should also fix the #13

Result recieved by cmd_print_plug_relay_state():

{"system":{"get_sysinfo":{"sw_ver":"1.1.1 Build 191209 Rel.103408","hw_ver":"4.0","model":"HS100(FR)","deviceId":"XXX","oemId":"XXXX","hwId":"XXXX","rssi":-XXXX,"longitude_i":XXXX,"latitude_i":XXXX,"alias":"prise 1 test","status":"new","mic_type":"IOT.SMARTPLUGSWITCH","feature":"TIM","mac":"XXXX","updating":0,"led_off":0,"relay_state":0,"on_time":0,"active_mode":"none","icon_hash":"","dev_name":"Smart Wi-Fi Plug","next_action":{"type":-1},"err_code":0}}}▒,^A^@^K^F^W^]^F^ANT^[O^Q^F^E^\^\^C^_^W
^]^\^B^P^Y^@^@^@^YP^_^]^FT{/^W^S_K^M^Z^G^]^G^M^W)}S^F^V^@^F^@^A^A^AE+

@ggeorgovassilis
Copy link
Owner

Thank you @Beanux for the analysis and fix.
Unfortunately I don't have the hs100 any more and cannot test this. Nevertheless I will modify the script according to your suggestion - if anybody complains, we'll know it didn't work :)

ggeorgovassilis added a commit that referenced this issue Sep 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants