From 892a38575f3157226ecec2fac605e5c5926b4a67 Mon Sep 17 00:00:00 2001 From: Hans Karlinius Date: Sun, 21 May 2017 11:58:13 +0200 Subject: [PATCH] Fix request --- HASS.pm | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/HASS.pm b/HASS.pm index bf504e5..c4960b5 100644 --- a/HASS.pm +++ b/HASS.pm @@ -27,7 +27,7 @@ sub testHassConnection { $log->info("Connected to Home Assistant at (".$prefs->get('connect').")"); }, sub { - $log->warn("Warning (".$prefs->get('connect')."): $_[1]"); + $log->error("Error (".$prefs->get('connect')."): $_[1]"); }, { timeout => 5, @@ -36,20 +36,13 @@ sub testHassConnection { $http->get( $prefs->get('connect'), + 'x-ha-access' => $prefs->get('pass'), 'Content-Type' => 'application/json', 'charset' => 'UTF-8', - access(), ); } } -sub access() { - if ($prefs->get('pass')) { - $log->debug('PASS'); - return 'x-ha-access' => $prefs->get('pass'); - } - return !defined; -} sub getEntities { my ( $client, $cb, $params, $args ) = @_; @@ -118,7 +111,7 @@ sub getEntity { $cb->($result); }, sub { - $log->warn("Warning (".$localurl."): $_[1]"); + $log->error("Error (".$localurl."): $_[1]"); $cb->(); }, { @@ -129,9 +122,9 @@ sub getEntity { $http->get( $localurl, + 'x-ha-access' => $prefs->get('pass'), 'Content-Type' => 'application/json', 'charset' => 'UTF-8', - access(), ); } @@ -153,7 +146,7 @@ sub toggleLightEntity { $cb->($result); }, sub { - $log->error("error: $_[1]"); + $log->error("Error (".$localurl."): $_[1]"); $cb->(); }, { @@ -163,10 +156,10 @@ sub toggleLightEntity { $http->post( $localurl, + 'x-ha-access' => $prefs->get('pass'), 'Content-Type' => 'application/json', 'charset' => 'UTF-8', encode_json($req), - access(), ); }