worked on audio edid
This commit is contained in:
1 parent
bcfaa83f10
commit
18b6613864
2 files changed
+74
-22
No files matched your search
@@ -178,9 +178,11 @@ vertex_2:
|
|||||||
0:
|
0:
|
||||||
name: TV
|
name: TV
|
||||||
icon: mdi:television
|
icon: mdi:television
|
||||||
|
use_audio_out_audio_flags: input_boolean.use_bravia_theater_for_the_frame
|
||||||
1:
|
1:
|
||||||
name: Projector
|
name: Projector
|
||||||
icon: mdi:projector
|
icon: mdi:projector
|
||||||
|
use_audio_out_audio_flags: True
|
||||||
|
|
||||||
# vertex2_power_plug:
|
# vertex2_power_plug:
|
||||||
# entity: switch.fibaro_vertex_plug_51
|
# entity: switch.fibaro_vertex_plug_51
|
||||||
@@ -191,8 +193,6 @@ vertex_2:
|
|||||||
# - binary_sensor.is_everybody_sleeping or binary_sensor.is_salon_sleeping
|
# - binary_sensor.is_everybody_sleeping or binary_sensor.is_salon_sleeping
|
||||||
# - binary_sensor.vertex2_unreachable and not binary_sensor.is_tv_on and not binary_sensor.projector_on
|
# - binary_sensor.vertex2_unreachable and not binary_sensor.is_tv_on and not binary_sensor.projector_on
|
||||||
|
|
||||||
mutetx0_conditions: input_boolean.use_bravia_theater_for_the_frame
|
|
||||||
|
|
||||||
#filmmaker_mode_conditions: sensor.vertex2_input_select_tx0 == 'AppleTV'
|
#filmmaker_mode_conditions: sensor.vertex2_input_select_tx0 == 'AppleTV'
|
||||||
|
|
||||||
output_selection:
|
output_selection:
|
||||||
|
|||||||
+72
-20
@@ -95,18 +95,33 @@ class Vertex2(SmartObject):
|
|||||||
if "filmmaker_mode_conditions" in self.args:
|
if "filmmaker_mode_conditions" in self.args:
|
||||||
self.filmmaker_mode_conditions = SmartCondition.Evaluator(self,self.args['filmmaker_mode_conditions'], condition_name = "filmmaker_mode_conditions",on_change_cb = self.on_filmmaker_mode_conditions_change)
|
self.filmmaker_mode_conditions = SmartCondition.Evaluator(self,self.args['filmmaker_mode_conditions'], condition_name = "filmmaker_mode_conditions",on_change_cb = self.on_filmmaker_mode_conditions_change)
|
||||||
|
|
||||||
if "mutetx0_conditions" in self.args:
|
|
||||||
self.mutetx0_conditions = SmartCondition.Evaluator(self,self.args['mutetx0_conditions'], condition_name = "mutetx0_conditions",on_change_cb = self.on_mute_tx0)
|
|
||||||
|
|
||||||
if "mutetx1_conditions" in self.args:
|
|
||||||
self.mutetx1_conditions = SmartCondition.Evaluator(self,self.args['mutetx1_conditions'], condition_name = "mutetx1_conditions",on_change_cb = self.on_mute_tx1)
|
|
||||||
|
|
||||||
self.input_selection_evaluators = list()
|
self.input_selection_evaluators = list()
|
||||||
if "input_selection" in self.args:
|
if "input_selection" in self.args:
|
||||||
for key in self.args["input_selection"]:
|
for key in self.args["input_selection"]:
|
||||||
self.input_selection_evaluators.append((SmartCondition.Evaluator(self,self.args["input_selection"][key], condition_name = key, on_update_cb = self.on_update_input_selection),key))
|
self.input_selection_evaluators.append((SmartCondition.Evaluator(self,self.args["input_selection"][key], condition_name = key, on_update_cb = self.on_update_input_selection),key))
|
||||||
self.on_update_input_selection()
|
self.on_update_input_selection()
|
||||||
|
|
||||||
|
self.output_config_conditions = {}
|
||||||
|
for output_key, config in self.args.get('output_config', {}).items():
|
||||||
|
if not isinstance(config, dict):
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
output_index = int(output_key)
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
continue
|
||||||
|
for condition_key in ('use_audio_out_audio_flags',):
|
||||||
|
condition_config = config.get(condition_key)
|
||||||
|
if not condition_config:
|
||||||
|
continue
|
||||||
|
self.output_config_conditions.setdefault(output_index, {})[condition_key] = SmartCondition.Evaluator(
|
||||||
|
self,
|
||||||
|
condition_config,
|
||||||
|
condition_name=f'output_config_tx{output_index}_{condition_key}',
|
||||||
|
on_update_cb=self.on_output_config_conditions_update,
|
||||||
|
pass_condition_name_to_cb=str(output_index),
|
||||||
|
trigger_callback_on_activation=False,
|
||||||
|
)
|
||||||
|
|
||||||
self.output_selection_evaluators = []
|
self.output_selection_evaluators = []
|
||||||
if "output_selection" in self.args:
|
if "output_selection" in self.args:
|
||||||
for key, conditions in self.args["output_selection"].items():
|
for key, conditions in self.args["output_selection"].items():
|
||||||
@@ -359,6 +374,7 @@ class Vertex2(SmartObject):
|
|||||||
self._refresh_selected_output_signal()
|
self._refresh_selected_output_signal()
|
||||||
|
|
||||||
self.log(f"Selecting TX{output_index} as the active output")
|
self.log(f"Selecting TX{output_index} as the active output")
|
||||||
|
self.apply_output_audio_settings(output_index)
|
||||||
if output_index == 0:
|
if output_index == 0:
|
||||||
self.force_tx1_plus5(False)
|
self.force_tx1_plus5(False)
|
||||||
self.set_edid_video_flags_to_tx0()
|
self.set_edid_video_flags_to_tx0()
|
||||||
@@ -384,18 +400,6 @@ class Vertex2(SmartObject):
|
|||||||
else:
|
else:
|
||||||
self.toggle_filmmaker_mode(False)
|
self.toggle_filmmaker_mode(False)
|
||||||
|
|
||||||
def on_mute_tx0(self,prev_result,result):
|
|
||||||
if result == SmartCondition.Result.Succeeded:
|
|
||||||
self.mute_tx0(True)
|
|
||||||
else:
|
|
||||||
self.mute_tx0(False)
|
|
||||||
|
|
||||||
def on_mute_tx1(self,prev_result,result):
|
|
||||||
if result == SmartCondition.Result.Succeeded:
|
|
||||||
self.mute_tx1(True)
|
|
||||||
else:
|
|
||||||
self.mute_tx1(False)
|
|
||||||
|
|
||||||
def on_change_power_plug_conditions(self,prev_result,result):
|
def on_change_power_plug_conditions(self,prev_result,result):
|
||||||
if result == SmartCondition.Result.Succeeded:
|
if result == SmartCondition.Result.Succeeded:
|
||||||
self.turn_on(self.power_plug_entity)
|
self.turn_on(self.power_plug_entity)
|
||||||
@@ -404,8 +408,13 @@ class Vertex2(SmartObject):
|
|||||||
|
|
||||||
def send_cmd(self,cmd,value = ''):
|
def send_cmd(self,cmd,value = ''):
|
||||||
request = f'{self.args["vertex2_address"]}/cmd?{cmd}={value}'
|
request = f'{self.args["vertex2_address"]}/cmd?{cmd}={value}'
|
||||||
try:
|
try:
|
||||||
r = get(request,timeout=5)
|
r = get(request, timeout=5)
|
||||||
|
if cmd == 'edid' and value.startswith(('audiotx', 'audioout')):
|
||||||
|
self.log_info(
|
||||||
|
f'Vertex2 audio EDID command response: HTTP {r.status_code}, '
|
||||||
|
f'{r.text[:160]!r}'
|
||||||
|
)
|
||||||
except (Timeout,ConnectionError):
|
except (Timeout,ConnectionError):
|
||||||
self.log(f"{request} is unreachable", level = "WARNING")
|
self.log(f"{request} is unreachable", level = "WARNING")
|
||||||
|
|
||||||
@@ -424,6 +433,48 @@ class Vertex2(SmartObject):
|
|||||||
self.log(f"Setting filmmaker mode to {value}")
|
self.log(f"Setting filmmaker mode to {value}")
|
||||||
self.send_cmd("filmmaker","on" if value else "off")
|
self.send_cmd("filmmaker","on" if value else "off")
|
||||||
|
|
||||||
|
def on_output_config_conditions_update(self, output_index):
|
||||||
|
try:
|
||||||
|
output_index = int(output_index)
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
return
|
||||||
|
if self.output_names.get(self.output_selected_sensor.get_state()) == output_index:
|
||||||
|
self.apply_output_audio_settings(output_index)
|
||||||
|
|
||||||
|
def apply_output_audio_settings(self, output_index):
|
||||||
|
conditions = self.output_config_conditions.get(output_index, {})
|
||||||
|
use_audio_out = conditions.get('use_audio_out_audio_flags')
|
||||||
|
use_audio_out = (
|
||||||
|
use_audio_out is not None
|
||||||
|
and use_audio_out.evaluate(False) == SmartCondition.Result.Succeeded
|
||||||
|
)
|
||||||
|
if use_audio_out:
|
||||||
|
self.set_edid_audio_flags_to_audio_out()
|
||||||
|
elif output_index == 0:
|
||||||
|
self.set_edid_audio_flags_to_tx0()
|
||||||
|
elif output_index == 1:
|
||||||
|
self.set_edid_audio_flags_to_tx1()
|
||||||
|
|
||||||
|
self.mute_output_audio(output_index, use_audio_out)
|
||||||
|
|
||||||
|
def mute_output_audio(self, output_index, mute):
|
||||||
|
if output_index == 0:
|
||||||
|
self.mute_tx0(mute)
|
||||||
|
elif output_index == 1:
|
||||||
|
self.mute_tx1(mute)
|
||||||
|
|
||||||
|
def set_edid_audio_flags_to_tx0(self):
|
||||||
|
self.log_info('Setting EDID Audio Flags to TX0 (edid=audiotx0 on)')
|
||||||
|
self.send_cmd('edid', 'audiotx0 on')
|
||||||
|
|
||||||
|
def set_edid_audio_flags_to_tx1(self):
|
||||||
|
self.log_info('Setting EDID Audio Flags to TX1 (edid=audiotx1 on)')
|
||||||
|
self.send_cmd('edid', 'audiotx1 on')
|
||||||
|
|
||||||
|
def set_edid_audio_flags_to_audio_out(self):
|
||||||
|
self.log_info('Setting EDID Audio Flags to AUDIO OUT (edid=audioout on)')
|
||||||
|
self.send_cmd('edid', 'audioout on')
|
||||||
|
|
||||||
def set_edid_video_flags_to_tx0(self):
|
def set_edid_video_flags_to_tx0(self):
|
||||||
self.log(f"Setting EDID Video Flags to TX0")
|
self.log(f"Setting EDID Video Flags to TX0")
|
||||||
self.send_cmd("edid","videotx0 on")
|
self.send_cmd("edid","videotx0 on")
|
||||||
@@ -467,6 +518,7 @@ class Vertex2(SmartObject):
|
|||||||
return {
|
return {
|
||||||
"name": config.get("name", default_config["name"]),
|
"name": config.get("name", default_config["name"]),
|
||||||
"icon": config.get("icon", default_config["icon"]),
|
"icon": config.get("icon", default_config["icon"]),
|
||||||
|
"use_audio_out_audio_flags": config.get("use_audio_out_audio_flags"),
|
||||||
}
|
}
|
||||||
return {"name": config, "icon": None}
|
return {"name": config, "icon": None}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user