Skip to content

Commit

Permalink
updated url and added headers to get data fra calls again
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesper committed Nov 21, 2022
1 parent fcd86aa commit 16310fd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion custom_components/apsystems/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"dependencies": [],
"codeowners": ["@skelgaard"],
"requirements": ["mechanize==0.4.5"],
"version": "1.0.4"
"version": "1.0.6"
}
11 changes: 6 additions & 5 deletions custom_components/apsystems/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ def find_stop_time(self, now):


class APsystemsFetcher:
url_login = "https://apsystemsema.com/ema/intoDemoUser.action?id="
url_data = "https://apsystemsema.com/ema/ajax/getReportApiAjax/getPowerOnCurrentDayAjax"
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0'}
url_login = "https://www.apsystemsema.com/ema/intoDemoUser.action?id="
url_data = "https://www.apsystemsema.com/ema/ajax/getReportApiAjax/getPowerOnCurrentDayAjax"
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Chrome/50.0.2661.102 Firefox/62.0'}
cache = None
cache_timestamp = None
running = False
Expand All @@ -196,7 +196,7 @@ async def login(self):
s = requests.Session()

r = await self._hass.async_add_executor_job(
s.get, self.url_login + self._auth_id
s.request, "GET", self.url_login + self._auth_id, None, None, self.headers
)
return s

Expand All @@ -213,10 +213,11 @@ async def run(self):
_LOGGER.debug('post_data:')
_LOGGER.debug(post_data)

s = requests.session()
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
_LOGGER.debug('starting: ' + now)
result_data = await self._hass.async_add_executor_job(
browser.post, self.url_data, post_data
s.request, "POST", self.url_data, None, post_data, self.headers, browser.cookies.get_dict()
)

_LOGGER.debug("status code data: " + str(result_data.status_code))
Expand Down

0 comments on commit 16310fd

Please sign in to comment.