Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions haphilipsjs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ def __init__(
self.ambilight_current_configuration: Optional[
AmbilightCurrentConfiguration
] = None
self.huelamp_power: Optional[str] = None
self.powerstate = None
if auth_shared_key:
self.auth_shared_key = auth_shared_key
Expand Down Expand Up @@ -714,6 +715,7 @@ async def update(self):
await self.getAmbilightMode()
await self.getAmbilightPower()
await self.getAmbilightCurrentConfiguration()
await self.getHueLampPower()
self.on = True
return True
except ConnectionFailure as err:
Expand Down Expand Up @@ -972,6 +974,24 @@ async def setScreenState(self, state):
return True
return False

async def getHueLampPower(self):
if self.json_feature_supported("ambilight", "Hue"):
r = await self.getReq("HueLamp/power")
if r and "power" in r:
self.huelamp_power = cast(str, r["power"])
else:
self.huelamp_power = None
return r
return None

async def setHueLampPower(self, state):
if self.json_feature_supported("ambilight", "Hue"):
data = {"power": state}
if await self.postReq("HueLamp/power", data) is not None:
self.huelamp_power = state
return True
return False

async def setApplication(self, intent: ApplicationIntentType):
if self.json_feature_supported("activities", "intent"):
data = {"intent": intent}
Expand Down
1 change: 1 addition & 0 deletions haphilipsjs/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ async def run(args, parser, tv: PhilipsTV):
tv.ambilight_current_configuration
)
)
print("Ambilight+Hue State: {}".format(tv.huelamp_power))

elif args.command == "ambilight":
if args.ambilight_mode:
Expand Down
2 changes: 2 additions & 0 deletions haphilipsjs/data/v6.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,8 @@
POWERSTATE = {"powerstate": "On"}
SCREENSTATE = {"screenstate": "On"}

HUELAMPPOWER = {"power": "On"}

CONTEXT: ContextType = {
"data": "NA",
"level1": "WatchTv",
Expand Down
3 changes: 3 additions & 0 deletions tests/test_v6.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
SYSTEM_SAPHI_ENCRYPTED,
VOLUME,
SCREENSTATE,
HUELAMPPOWER,
)

MOCK_ANDROID_SOURCES = {
Expand Down Expand Up @@ -111,6 +112,7 @@ async def client_mock(loop, param: Param):
respx.get(f"{param.base}/ambilight/currentconfiguration").respond(
json=cast(Dict, AMBILIGHT_CURRENT_CONFIGURATION)
)
respx.get(f"{param.base}/HueLamp/power").respond(json=HUELAMPPOWER)
respx.get(f"{param.base}/menuitems/settings/structure").respond(
json=cast(Dict, MENUITEMS_SETTINGS_STRUCTURE)
)
Expand Down Expand Up @@ -161,6 +163,7 @@ async def test_basic_data(client_mock, param: Param):
}
assert client_mock.powerstate == POWERSTATE["powerstate"]
assert client_mock.screenstate == SCREENSTATE["screenstate"]
assert client_mock.huelamp_power == HUELAMPPOWER["power"]


async def test_current_channel_none(client_mock, param):
Expand Down