Skip to content

Commit

Permalink
Added user-agent to all HTTP requests
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-r committed Jan 2, 2024
1 parent 616a93e commit ef9d785
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions custom_components/ohme/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from time import time
from datetime import datetime, timedelta
from homeassistant.helpers.entity import DeviceInfo
from .const import DOMAIN
from .const import DOMAIN, USER_AGENT, INTEGRATION_VERSION
from .utils import time_next_occurs

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -111,7 +111,8 @@ def _get_headers(self):
"""Get auth and content-type headers"""
return {
"Authorization": "Firebase %s" % self._token,
"Content-Type": "application/json"
"Content-Type": "application/json",
"User-Agent": f"{USER_AGENT}/{INTEGRATION_VERSION}"
}

async def _post_request(self, url, skip_json=False, data=None):
Expand Down
4 changes: 3 additions & 1 deletion custom_components/ohme/const.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Component constants"""

DOMAIN = "ohme"
USER_AGENT = "dan-r-homeassistant-ohme"
INTEGRATION_VERSION = "0.2.7"

DATA_CLIENT = "client"
DATA_COORDINATORS = "coordinators"
COORDINATOR_CHARGESESSIONS = 0
Expand Down

0 comments on commit ef9d785

Please sign in to comment.