Closed Spartan-II-117 closed 3 years ago
I'm seeing this too. Happy to help debug if required.
This seems to be a ruby issue where ruby for some reasons is trying to inflate something which wasn't compressed in the first place. I see bug reports against older versions of ruby for this.
Updating to the latest ruby with RVM didn't help.
I'm running this on a RaspberryPI 3B with ruby 2.3.0. I had the same or similar issue; crash when receiving the response from homeassistant. BTW, I'm running HA 0.85.1 on a RaspberryPI 3B. I suspected an issue with deflating the response from HA, so I forced the accept-encoding header to 'identity' to disable compressed responses. That fixed the issue and it's now working. I do not believe that home_assistant_ble will every be transferring huge amounts of data, so this is probably an acceptable change - until ruby is fixed. Patch below or would you like a PR for this one-liner?
def update_home_assistant(ha_conf, state)
ha_name = ha_conf['name']
uri = URI.join(home_assistant_url, "api/states/device_tracker.#{ha_name}")
request = Net::HTTP::Post.new(uri)
request.content_type = 'application/json'
+ request['Accept-Encoding'] = 'identity'
request['X-Ha-Access'] = home_assistant_password if home_assistant_password
request.body = state_update(ha_conf, state)
req_options = { use_ssl: uri.scheme == 'https' }
while running in terminal, upon discovery of a listed device from the config, home_assistant-ble crashes. stack trace: Just discovered D8:84:DF:14:DA:83 /usr/lib/ruby/2.1.0/net/http/response.rb:357:in'
finish': incorrect header check (Zlib::DataError) from /usr/lib/ruby/2.1.0/net/http/response.rb:357:in
finish' from /usr/lib/ruby/2.1.0/net/http/response.rb:262:inensure in inflater' from /usr/lib/ruby/2.1.0/net/http/response.rb:262:in
inflater' from /usr/lib/ruby/2.1.0/net/http/response.rb:274:inread_body_0' from /usr/lib/ruby/2.1.0/net/http/response.rb:201:in
read_body' from /usr/lib/ruby/2.1.0/net/http/response.rb:226:inbody' from /usr/lib/ruby/2.1.0/net/http/response.rb:163:in
reading_body' from /usr/lib/ruby/2.1.0/net/http.rb:1414:inblock in transport_request' from /usr/lib/ruby/2.1.0/net/http.rb:1405:in
catch' from /usr/lib/ruby/2.1.0/net/http.rb:1405:intransport_request' from /usr/lib/ruby/2.1.0/net/http.rb:1378:in
request' from /var/lib/gems/2.1.0/gems/home_assistant-ble-1.3.1/lib/home_assistant/ble.rb:129:inblock in update_home_assistant' from /usr/lib/ruby/2.1.0/net/http.rb:853:in
start' from /usr/lib/ruby/2.1.0/net/http.rb:583:instart' from /var/lib/gems/2.1.0/gems/home_assistant-ble-1.3.1/lib/home_assistant/ble.rb:128:in
update_home_assistant' from /var/lib/gems/2.1.0/gems/home_assistant-ble-1.3.1/lib/home_assistant/ble.rb:91:inblock in detect_new_devices' from /var/lib/gems/2.1.0/gems/home_assistant-ble-1.3.1/lib/home_assistant/ble.rb:88:in
each' from /var/lib/gems/2.1.0/gems/home_assistant-ble-1.3.1/lib/home_assistant/ble.rb:88:indetect_new_devices' from /var/lib/gems/2.1.0/gems/home_assistant-ble-1.3.1/lib/home_assistant/ble.rb:66:in
block in run' from /var/lib/gems/2.1.0/gems/home_assistant-ble-1.3.1/lib/home_assistant/ble.rb:64:inloop' from /var/lib/gems/2.1.0/gems/home_assistant-ble-1.3.1/lib/home_assistant/ble.rb:64:in
run' from /var/lib/gems/2.1.0/gems/home_assistant-ble-1.3.1/bin/home_assistant-ble:22:in<top (required)>' from /usr/local/bin/home_assistant-ble:23:in
load' from /usr/local/bin/home_assistant-ble:23:in `