Skip to content

Commit

Permalink
Fix API calls
Browse files Browse the repository at this point in the history
  • Loading branch information
bramstroker committed Nov 27, 2022
1 parent 3f167fc commit 75eedb1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions utils/measure/config.py
Expand Up @@ -72,6 +72,8 @@

CSV_ADD_DATETIME_COLUMN = config("CSV_ADD_DATETIME_COLUMN", default=False, cast=bool)

SELECTED_DEVICE_TYPE = config("SELECTED_DEVICE_TYPE")

try:
RESUME = config("RESUME", cast=bool)
except UndefinedValueError:
Expand Down
8 changes: 6 additions & 2 deletions utils/measure/measure.py
Expand Up @@ -92,8 +92,12 @@ def start(self) -> None:
if DeviceType.LIGHT:
_LOGGER.info(f"Selected light controller: {config.SELECTED_LIGHT_CONTROLLER}")

self.device_type = inquirer.list_input("What kind of device do you want to measure the power of?",
choices=[cls.value for cls in DeviceType])
if config.SELECTED_DEVICE_TYPE:
self.device_type = DeviceType(config.SELECTED_DEVICE_TYPE)
else:
self.device_type = inquirer.list_input("What kind of device do you want to measure the power of?",
choices=[cls.value for cls in DeviceType])

self.runner = RunnerFactory().create_runner(self.device_type)

answers = self.ask_questions()
Expand Down
4 changes: 2 additions & 2 deletions utils/measure/media_controller/hass.py
Expand Up @@ -18,7 +18,7 @@ def set_volume(self, volume: int) -> None:
self.client.trigger_service("media_player", "volume_set", entity_id=self._entity_id, volume_level=round(volume/100, 2))

def mute_volume(self) -> None:
self.client.trigger_service("media_player", "mute_volume")
self.client.trigger_service("media_player", "mute_volume", entity_id=self._entity_id)

def play_audio(self, stream_url: str) -> None:
self.client.trigger_service(
Expand All @@ -30,7 +30,7 @@ def play_audio(self, stream_url: str) -> None:
)

def turn_off(self) -> None:
self.client.trigger_service('media_player', 'turn_off')
self.client.trigger_service("media_player", "turn_off", entity_id=self._entity_id)

def get_questions(self) -> list[inquirer.questions.Question]:
entities = self.client.get_entities()
Expand Down

0 comments on commit 75eedb1

Please sign in to comment.