From d25e0167a7079c9bb7b48dc5f5405295c87b9a48 Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Fri, 5 Jul 2024 14:34:13 +0200 Subject: [PATCH] phono added to gfw.dirk --- devices/mydevices.py | 12 +++++++++++- function/ground_floor_west.py | 14 ++++++++++++++ topics.py | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/devices/mydevices.py b/devices/mydevices.py index 9d417f5..658ffac 100644 --- a/devices/mydevices.py +++ b/devices/mydevices.py @@ -172,7 +172,9 @@ class remote(base): """ KEY_CD = "CD" KEY_LINE1 = "LINE1" + KEY_LINE2 = "LINE2" KEY_LINE3 = "LINE3" + KEY_PHONO = "PHONO" KEY_MUTE = "MUTE" KEY_POWER = "POWER" KEY_VOLDOWN = "VOLDOWN" @@ -181,7 +183,7 @@ class remote(base): TX_TOPIC = '' TX_TYPE = base.TX_VALUE # - RX_IGNORE_TOPICS = [KEY_CD, KEY_LINE1, KEY_LINE3, KEY_MUTE, KEY_POWER, KEY_VOLUP, KEY_VOLDOWN] + RX_IGNORE_TOPICS = [KEY_CD, KEY_LINE1, KEY_LINE2, KEY_LINE3, KEY_PHONO, KEY_MUTE, KEY_POWER, KEY_VOLUP, KEY_VOLDOWN] def __state_logging__(self, inst, key, data): pass # This is just a TX device using self.set_* @@ -194,10 +196,18 @@ class remote(base): self.logger.info("Changing amplifier source to LINE1") self.send_command(self.KEY_LINE1, None) + def set_line2(self, device=None, key=None, data=None): + self.logger.info("Changing amplifier source to LINE2") + self.send_command(self.KEY_LINE2, None) + def set_line3(self, device=None, key=None, data=None): self.logger.info("Changing amplifier source to LINE3") self.send_command(self.KEY_LINE3, None) + def set_phono(self, device=None, key=None, data=None): + self.logger.info("Changing amplifier source to PHONO") + self.send_command(self.KEY_PHONO, None) + def set_mute(self, device=None, key=None, data=None): self.logger.info("Muting / Unmuting amplifier") self.send_command(self.KEY_MUTE, None) diff --git a/function/ground_floor_west.py b/function/ground_floor_west.py index 44c892b..33bcd2b 100644 --- a/function/ground_floor_west.py +++ b/function/ground_floor_west.py @@ -103,6 +103,7 @@ class ground_floor_west_dirk(room): AUDIO_SOURCE_PC = 0 AUDIO_SOURCE_CD = 1 AUDIO_SOURCE_RASPI = 2 + AUDIO_SOURCE_PHONO = 3 def __init__(self, mqtt_client, pd, vd): roo = props.ROO_DIR @@ -116,6 +117,7 @@ class ground_floor_west_dirk(room): # powerplug self.powerplug_common = pd.get(props.STG_MYA, loc, roo, props.FUN_MPP) self.KEY_POWERPLUG_AMPLIFIER = self.powerplug_common.KEY_OUTPUT_0 + self.KEY_POWERPLUG_PHONO = self.powerplug_common.KEY_OUTPUT_1 self.KEY_POWERPLUG_CD_PLAYER = self.powerplug_common.KEY_OUTPUT_2 # dock self.dock_tradfri = pd.get(props.STG_ZGW, loc, roo, props.FUN_DCK) @@ -156,6 +158,7 @@ class ground_floor_west_dirk(room): self.dock_tradfri.toggle_output_0_mcb) # Mediaplayer - Amplifier auto on + self.powerplug_common.add_callback(self.KEY_POWERPLUG_PHONO, None, self.powerplug_common.set_output_0_mcb, True) self.powerplug_common.add_callback(self.KEY_POWERPLUG_CD_PLAYER, None, self.powerplug_common.set_output_0_mcb, True) self.spotify_state.add_callback(self.spotify_state.KEY_STATE, None, self.powerplug_common.set_output_0_mcb, True) self.mpd_state.add_callback(self.mpd_state.KEY_STATE, None, self.powerplug_common.set_output_0_mcb, True) @@ -163,6 +166,7 @@ class ground_floor_west_dirk(room): # Mediaplayer - Audio source selection self.powerplug_common.add_callback(self.KEY_POWERPLUG_AMPLIFIER, True, self.audio_source_selector, True) self.powerplug_common.add_callback(self.KEY_POWERPLUG_CD_PLAYER, True, self.audio_source_selector, True) + self.powerplug_common.add_callback(self.KEY_POWERPLUG_PHONO, True, self.audio_source_selector, True) self.spotify_state.add_callback(self.spotify_state.KEY_STATE, True, self.audio_source_selector, True) self.mpd_state.add_callback(self.mpd_state.KEY_STATE, True, self.audio_source_selector, True) self.bt_state.add_callback(self.bt_state.KEY_STATE, True, self.audio_source_selector, True) @@ -195,6 +199,10 @@ class ground_floor_west_dirk(room): mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_VIDEV, self.powerplug_common, self.KEY_POWERPLUG_AMPLIFIER ) + self.phono_videv = videv_switching( + mqtt_client, config.TOPIC_GFW_DIRK_PHONO_VIDEV, + self.powerplug_common, self.KEY_POWERPLUG_PHONO + ) self.cd_player_videv = videv_switching( mqtt_client, config.TOPIC_GFW_DIRK_CD_PLAYER_VIDEV, self.powerplug_common, self.KEY_POWERPLUG_CD_PLAYER @@ -224,6 +232,9 @@ class ground_floor_west_dirk(room): if device == self.powerplug_common and key == self.KEY_POWERPLUG_CD_PLAYER: # switch on of cd player self.audio_source = self.AUDIO_SOURCE_CD + elif device == self.powerplug_common and key == self.KEY_POWERPLUG_PHONO: + # switch on of phono + self.audio_source = self.AUDIO_SOURCE_PHONO elif device in [self.spotify_state, self.mpd_state, self.bt_state]: # switch on raspi-source self.audio_source = self.AUDIO_SOURCE_RASPI @@ -238,6 +249,9 @@ class ground_floor_west_dirk(room): elif self.audio_source == self.AUDIO_SOURCE_CD: logger.info("Sending IR command to change audio source to cd") self.remote_amplifier.set_cd() + elif self.audio_source == self.AUDIO_SOURCE_PHONO: + logger.info("Sending IR command to change audio source to phono") + self.remote_amplifier.set_line2() elif self.audio_source == self.AUDIO_SOURCE_RASPI: logger.info("Sending IR command to change audio source to raspi") self.remote_amplifier.set_line1() diff --git a/topics.py b/topics.py index d1a2b95..5baa3d8 100644 --- a/topics.py +++ b/topics.py @@ -17,6 +17,7 @@ TOPIC_GFW_MARION_HEATING_VALVE_VIDEV = "videv/gfw/marion/heating_valve" TOPIC_GFW_DIRK_MAIN_LIGHT_VIDEV = "videv/gfw/dirk/main_light" TOPIC_GFW_DIRK_DESK_LIGHT_VIDEV = "videv/gfw/dirk/desk_light" TOPIC_GFW_DIRK_AMPLIFIER_VIDEV = "videv/gfw/dirk/amplifier" +TOPIC_GFW_DIRK_PHONO_VIDEV = "videv/gfw/dirk/phono" TOPIC_GFW_DIRK_CD_PLAYER_VIDEV = "videv/gfw/dirk/cd_player" TOPIC_GFW_DIRK_PC_DOCK_VIDEV = "videv/gfw/dirk/pc_dock" TOPIC_GFW_DIRK_ACTIVE_BRIGHTNESS_DEVICE_VIDEV = "videv/gfw/dirk/active_brightness_device"