Skip to content

Commit 506fb07

Browse files
committed
fixed json formatting
1 parent bd85e61 commit 506fb07

File tree

5 files changed

+28
-11
lines changed

5 files changed

+28
-11
lines changed

custom_components/hyperhdr_control/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
2626
manufacturer="HyperHDR",
2727
name=f"HyperHDR ({entry.data[CONF_HOST]})",
2828
model="HyperHDR LED Controller",
29-
sw_version="1.3.0",
29+
sw_version="1.3.1",
3030
)
3131

3232
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

custom_components/hyperhdr_control/button.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def device_info(self) -> DeviceInfo:
5353
manufacturer="HyperHDR",
5454
name=f"HyperHDR ({self._host})",
5555
model="HyperHDR LED Controller",
56-
sw_version="1.3.0",
56+
sw_version="1.3.1",
5757
)
5858

5959
async def async_press(self) -> None:
@@ -71,9 +71,14 @@ async def async_press(self) -> None:
7171
try:
7272
async with aiohttp.ClientSession() as session:
7373
url = f"http://{self._host}:{self._port}/json-rpc"
74+
params = {"request": json.dumps(request_data, separators=(',', ':'))}
75+
_LOGGER.debug("Sending request to %s with params: %s", url, params)
76+
7477
async with async_timeout.timeout(10):
75-
async with session.get(url, params={"request": json.dumps(request_data)}) as response:
78+
async with session.get(url, params=params) as response:
7679
if response.status != 200:
7780
_LOGGER.error("Failed to activate effect: %s", response.status)
81+
response_text = await response.text()
82+
_LOGGER.error("Response: %s", response_text)
7883
except (aiohttp.ClientError, TimeoutError) as error:
7984
_LOGGER.error("Error activating effect: %s", error)

custom_components/hyperhdr_control/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"codeowners": [],
77
"requirements": ["aiohttp", "zeroconf"],
88
"iot_class": "local_polling",
9-
"version": "1.3.0",
9+
"version": "1.3.1",
1010
"config_flow": true,
1111
"zeroconf": ["_hyperhdr-http._tcp.local."],
1212
"logo": "https://raw.githubusercontent.com/johnneerdael/hyperhdr_control/main/hyperhdr_control-logo.png"

custom_components/hyperhdr_control/number.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def device_info(self) -> DeviceInfo:
6363
manufacturer="HyperHDR",
6464
name=f"HyperHDR ({self._host})",
6565
model="HyperHDR LED Controller",
66-
sw_version="1.3.0",
66+
sw_version="1.3.1",
6767
)
6868

6969
async def _delayed_update(self) -> None:
@@ -106,10 +106,15 @@ async def _set_brightness(self, value: float) -> None:
106106
try:
107107
async with aiohttp.ClientSession() as session:
108108
url = f"http://{self._host}:{self._port}/json-rpc"
109+
params = {"request": json.dumps(request_data, separators=(',', ':'))}
110+
_LOGGER.debug("Sending brightness request to %s with params: %s", url, params)
111+
109112
async with async_timeout.timeout(10):
110-
async with session.get(url, params={"request": json.dumps(request_data)}) as response:
113+
async with session.get(url, params=params) as response:
111114
if response.status != 200:
112115
_LOGGER.error("Failed to set brightness: %s", response.status)
116+
response_text = await response.text()
117+
_LOGGER.error("Response: %s", response_text)
113118
except (aiohttp.ClientError, TimeoutError) as error:
114119
_LOGGER.error("Error setting brightness: %s", error)
115120

@@ -122,8 +127,10 @@ async def async_update(self) -> None:
122127
try:
123128
async with aiohttp.ClientSession() as session:
124129
url = f"http://{self._host}:{self._port}/json-rpc"
130+
params = {"request": json.dumps(request_data, separators=(',', ':'))}
131+
125132
async with async_timeout.timeout(10):
126-
async with session.get(url, params={"request": json.dumps(request_data)}) as response:
133+
async with session.get(url, params=params) as response:
127134
if response.status == 200:
128135
data = await response.json()
129136
adjustment = data.get("info", {}).get("adjustment", {})

custom_components/hyperhdr_control/switch.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import json
55
import logging
66
from typing import Any
7+
from urllib.parse import urlencode
78

89
import aiohttp
910
import async_timeout
@@ -57,7 +58,7 @@ def device_info(self) -> DeviceInfo:
5758
manufacturer="HyperHDR",
5859
name=f"HyperHDR ({self._host})",
5960
model="HyperHDR LED Controller",
60-
sw_version="1.3.0",
61+
sw_version="1.3.1",
6162
)
6263

6364
async def async_turn_on(self, **kwargs: Any) -> None:
@@ -81,9 +82,11 @@ async def _set_state(self, state: bool) -> None:
8182
try:
8283
async with aiohttp.ClientSession() as session:
8384
url = f"http://{self._host}:{self._port}/json-rpc"
84-
_LOGGER.debug("Sending request to %s: %s", url, json.dumps(request_data))
85+
params = {"request": json.dumps(request_data, separators=(',', ':'))}
86+
_LOGGER.debug("Sending request to %s with params: %s", url, params)
87+
8588
async with async_timeout.timeout(10):
86-
async with session.get(url, params={"request": json.dumps(request_data)}) as response:
89+
async with session.get(url, params=params) as response:
8790
if response.status == 200:
8891
self._attr_is_on = state
8992
_LOGGER.debug("Successfully set %s state to %s", self._component, state)
@@ -103,8 +106,10 @@ async def async_update(self) -> None:
103106
try:
104107
async with aiohttp.ClientSession() as session:
105108
url = f"http://{self._host}:{self._port}/json-rpc"
109+
params = {"request": json.dumps(request_data, separators=(',', ':'))}
110+
106111
async with async_timeout.timeout(10):
107-
async with session.get(url, params={"request": json.dumps(request_data)}) as response:
112+
async with session.get(url, params=params) as response:
108113
if response.status == 200:
109114
data = await response.json()
110115
components = data.get("info", {}).get("components", [])

0 commit comments

Comments
 (0)