videv audio_player implemented
This commit is contained in:
parent
40570998d0
commit
be3d70f942
@ -7,7 +7,7 @@ import devices
|
|||||||
from function.modules import brightness_choose_n_action, heating_function
|
from function.modules import brightness_choose_n_action, heating_function
|
||||||
import logging
|
import logging
|
||||||
from function.rooms import room
|
from function.rooms import room
|
||||||
from function.videv import videv_switching, videv_switch_brightness_color_temp, videv_heating, videv_multistate
|
from function.videv import videv_switching, videv_switch_brightness_color_temp, videv_heating, videv_multistate, videv_audio_player
|
||||||
import task
|
import task
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -152,6 +152,8 @@ class ground_floor_west_dirk(room):
|
|||||||
self.desk_light_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_ZIGBEE)
|
self.desk_light_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_ZIGBEE)
|
||||||
self.button_tradfri = devices.tradfri_button(mqtt_client, config.TOPIC_GFW_DIRK_INPUT_DEVICE)
|
self.button_tradfri = devices.tradfri_button(mqtt_client, config.TOPIC_GFW_DIRK_INPUT_DEVICE)
|
||||||
self.remote_amplifier = devices.remote(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_REMOTE)
|
self.remote_amplifier = devices.remote(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_REMOTE)
|
||||||
|
self.spotify_state = devices.audio_status(mqtt_client, config.TOPIC_GFW_DIRK_SPOTIFY)
|
||||||
|
self.mpd_state = devices.audio_status(mqtt_client, config.TOPIC_GFW_DIRK_MPD)
|
||||||
self.heating_valve = devices.brennenstuhl_heatingvalve(mqtt_client, config.TOPIC_GFW_DIRK_HEATING_VALVE_ZIGBEE)
|
self.heating_valve = devices.brennenstuhl_heatingvalve(mqtt_client, config.TOPIC_GFW_DIRK_HEATING_VALVE_ZIGBEE)
|
||||||
super().__init__(mqtt_client)
|
super().__init__(mqtt_client)
|
||||||
#
|
#
|
||||||
@ -178,9 +180,6 @@ class ground_floor_west_dirk(room):
|
|||||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_LEFT,
|
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_LEFT,
|
||||||
self.powerplug_common.toggle_output_3_mcb)
|
self.powerplug_common.toggle_output_3_mcb)
|
||||||
|
|
||||||
# Mediaplayer - Spotify / MPD state
|
|
||||||
self.spotify_state = devices.audio_status(mqtt_client, config.TOPIC_GFW_DIRK_SPOTIFY)
|
|
||||||
self.mpd_state = devices.audio_status(mqtt_client, config.TOPIC_GFW_DIRK_MPD)
|
|
||||||
# Mediaplayer - Amplifier auto on
|
# Mediaplayer - Amplifier auto on
|
||||||
self.powerplug_common.add_callback(self.KEY_POWERPLUG_CD_PLAYER, 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(devices.status.KEY_STATE, None, self.powerplug_common.set_output_0_mcb, True)
|
self.spotify_state.add_callback(devices.status.KEY_STATE, None, self.powerplug_common.set_output_0_mcb, True)
|
||||||
@ -295,6 +294,10 @@ class ground_floor_west_dirk(room):
|
|||||||
mqtt_client, config.TOPIC_GFW_DIRK_ACTIVE_BRIGHTNESS_DEVICE_VIDEV,
|
mqtt_client, config.TOPIC_GFW_DIRK_ACTIVE_BRIGHTNESS_DEVICE_VIDEV,
|
||||||
brightness_choose_n_action.KEY_ACTIVE_DEVICE, self.brightness_functions, 3
|
brightness_choose_n_action.KEY_ACTIVE_DEVICE, self.brightness_functions, 3
|
||||||
)
|
)
|
||||||
|
self.audio_player_videv = videv_audio_player(
|
||||||
|
mqtt_client, config.TOPIC_GFW_DIRK_AUDIO_PLAYER_VIDEV,
|
||||||
|
self.spotify_state, self.mpd_state
|
||||||
|
)
|
||||||
#
|
#
|
||||||
# Other stuff
|
# Other stuff
|
||||||
#
|
#
|
||||||
|
@ -16,9 +16,7 @@ Targets:
|
|||||||
|
|
||||||
from base import mqtt_base
|
from base import mqtt_base
|
||||||
import devices
|
import devices
|
||||||
import inspect
|
|
||||||
import json
|
import json
|
||||||
import logging
|
|
||||||
|
|
||||||
BASETOPIC = "videv"
|
BASETOPIC = "videv"
|
||||||
|
|
||||||
@ -99,10 +97,10 @@ class base_routing(base):
|
|||||||
l1 = []
|
l1 = []
|
||||||
for k, v in self.__device_list__.items():
|
for k, v in self.__device_list__.items():
|
||||||
if v.__class__.__name__ == "group":
|
if v.__class__.__name__ == "group":
|
||||||
if device in v:
|
if id(device) in [id(d) for d in v]:
|
||||||
l1.append(k)
|
l1.append(k)
|
||||||
else:
|
else:
|
||||||
if v == device:
|
if id(v) == id(device):
|
||||||
l1.append(k)
|
l1.append(k)
|
||||||
l2 = [k for k, v in self.__device_key__.items() if v == key]
|
l2 = [k for k, v in self.__device_key__.items() if v == key]
|
||||||
try:
|
try:
|
||||||
@ -234,15 +232,38 @@ class videv_heating(base_routing):
|
|||||||
|
|
||||||
|
|
||||||
class videv_multistate(base):
|
class videv_multistate(base):
|
||||||
def __init__(self, mqtt_client, topic, key_for_topic, device, num_states, default_values=None):
|
def __init__(self, mqtt_client, topic, key_for_device, device, num_states, default_values=None):
|
||||||
dv = dict.fromkeys(["state_%d" % i for i in range(0, num_states)])
|
dv = dict.fromkeys(["state_%d" % i for i in range(0, num_states)])
|
||||||
for key in dv:
|
for key in dv:
|
||||||
dv[key] = False
|
dv[key] = False
|
||||||
super().__init__(mqtt_client, topic, (key_for_topic, device), default_values=dv)
|
super().__init__(mqtt_client, topic, (key_for_device, device), default_values=dv)
|
||||||
#
|
#
|
||||||
device.add_callback(key_for_topic, None, self.__index_rx__, True)
|
device.add_callback(key_for_device, None, self.__index_rx__, True)
|
||||||
|
|
||||||
def __index_rx__(self, device, key, data):
|
def __index_rx__(self, device, key, data):
|
||||||
for index, key in enumerate(self):
|
for index, key in enumerate(self):
|
||||||
self.set(key, index == data)
|
self.set(key, index == data)
|
||||||
self.__tx__(key, self[key])
|
self.__tx__(key, self[key])
|
||||||
|
|
||||||
|
|
||||||
|
class videv_audio_player(base_routing):
|
||||||
|
KEY_ACTIVE_PLAYER = 'player_%d'
|
||||||
|
KEY_TITLE = 'title'
|
||||||
|
NO_TITLE = '---'
|
||||||
|
|
||||||
|
def __init__(self, mqtt_client, topic, *args):
|
||||||
|
dv = dict.fromkeys([self.KEY_ACTIVE_PLAYER % i for i in range(0, len(args))])
|
||||||
|
for key in dv:
|
||||||
|
dv[key] = False
|
||||||
|
dv[self.KEY_TITLE] = self.NO_TITLE
|
||||||
|
super().__init__(
|
||||||
|
mqtt_client, topic,
|
||||||
|
*[[self.KEY_ACTIVE_PLAYER % i, device, devices.audio_status.KEY_STATE] for i, device in enumerate(args)],
|
||||||
|
default_values=dv
|
||||||
|
)
|
||||||
|
for audio_device in args:
|
||||||
|
audio_device.add_callback(audio_device.KEY_TITLE, None, self.__title_rx__, True)
|
||||||
|
|
||||||
|
def __title_rx__(self, device, key, data):
|
||||||
|
self.set(self.KEY_TITLE, data or self.NO_TITLE)
|
||||||
|
self.__tx__(self.KEY_TITLE, self[self.KEY_TITLE])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user