mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
implementing users remarks (#5481)
* cec client object * cec command structure * autodetect source * volume support and native source select * switch device * media player device * detecting of state * friendly names * hdmi cec properties * presence detection * simplified callbacks * stable names * renamed methods * code cleanup * name with vendor * fixed standby call name * fake standby/poweron * domain switch * domain switch * async updating * update separated * cec -> hass event bridge * fixed name generation * code cleanup * code cleanup * icon constants * code cleanup * do not register unavailable devices * discovery of deevices * code cleanup * cec device discovery * moved method implementation into child * service descriptions * service descriptions * service descriptions * changed entity init sequence * logging cleanup * add remove as job * closing cec, no service schemas * correct iterate over dictionary * Volume by commands * threading * logging minimized * get load out of main thread * naming cleanup * get load out of main thread * optimized discovery * async where possible * cleanup logging, constructors first * pydoc * formatting * no async_update from out of loop no hiding entities removed redundant device_state_attributes async updating presence * no async * working async cec * cec in thirdparty lib * cec initialized oudsice * working without SIGSEGV * rollbacked file changed by mistake * sending of commands * working with ha * using hass loop and device driven updates * version up * version up * Command types in pycec, cleanup for HA integration * Removed media player, state moved to switch * service descriptions * requirements: pyCEC * line width to 79 * doc * doc * overindentation solved * HDMI to uppercase * minimal dependency on cec * removed unwanted line * doc wording * margin 79 * line continuation indent * imperative doc * lint: indentation * fixed overindented * fixed overindented * fixed overindented * fixed overindented * order of imports * PEP8 * keep signature of overriding * removed redundant blank line * fixed update call method (#4) * Preparation for merge to upstream (#5) * newer version of pyCEC * updated services.yaml * fixed lint scrpt to operate only on python files * pycec version up * update services * no coverage report * exclude non python files from lint * lint only on python files * Dev (#6) * reordered * sending nonserialized data through hass.data * code formatting * code formatting * import order * Dev (#7) * newer version of pyCEC * updated services.yaml * fixed lint scrpt to operate only on python files * pycec version up * update services * no coverage report * exclude non python files from lint * lint only on python files * reordered * sending nonserialized data through hass.data * import order * fixed object handling * code formatting * Backwards compatibility of hdmi_cec (#10) * services: power_on standby active_source * new version of pyCEC (#12) * newer version of pyCEC * devices config (#13) * getting device name from config * shutdown fix (#14) * correct call on shutdown * remove misplaced annotations (#15) * Preparation for merge to upstream (#5) * newer version of pyCEC * updated services.yaml * reordered * sending nonserialized data through hass.data * services: power_on standby active_source * code formatting * getting device name from config * correct call on shutdown * pyCEC version 0.3.6 (#18) * newer version of pyCEC * updated services.yaml * sending nonserialized data through hass.data * services: ** power_on ** standby ** active_source * getting device name from config * correct call on shutdown * fork new thread on multicore machines * support both config schemas: original and new (#16) * volume press and release support (#17) * support for media_player (#21) * accept hexadecimal format of commands * support for media player * platform customization * type constants * Dev (#23) * accept hexadecimal format of commands * support for media player * platform customization * TCP CEC support (#24) * accept hexadecimal format of commands * support for media player * platform customization * preparing tcp support * volume handling (#25) * Incorporated CR remarks (#26) * cleanup imports * cleanup and enhance services description * removed unwanted file * implemented CR remarks (#27) * pyCEC v0.4.6 * pined dependency version * tighten service schemas * requirements (#28) * incorporate remarks from users (#32) * home-assistant-31 make mute schema better (#31) * pycec-30 pyCEC version up (#30) * pycec-30 pyCEC version up (#30) * home-assistant-30 OSD display name from configuration (#30) (#33) * Home assistant 29 (#34) * home-assistant-29 counting from 0 (#29) * Home assistant 31 (#35) * home-assistant-31 add support for mute-on and mute-off (#31) * home-assistant-31 pyCEC version up (#31) * Home assistant 31 (#36) * home-assistant-31 Limit OSD name to 13 chars (#31) * home-assistant-31 Limit OSD name to 13 chars moved to CEC adapter (#31) * home-assistant-31 version up (#31) * home-assistant-31 formatting (#31) * formatting * service description * service description * single attribute for volume * fixed mute on -> mute off * moved config constant from core into component
This commit is contained in:
parent
a89a4f39dc
commit
06361b1ed1
@ -26,12 +26,14 @@ from homeassistant.const import (EVENT_HOMEASSISTANT_START, STATE_UNKNOWN,
|
|||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
REQUIREMENTS = ['pyCEC==0.4.6']
|
REQUIREMENTS = ['pyCEC==0.4.9']
|
||||||
|
|
||||||
DOMAIN = 'hdmi_cec'
|
DOMAIN = 'hdmi_cec'
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
DEFAULT_DISPLAY_NAME = "HomeAssistant"
|
||||||
|
|
||||||
ICON_UNKNOWN = 'mdi:help'
|
ICON_UNKNOWN = 'mdi:help'
|
||||||
ICON_AUDIO = 'mdi:speaker'
|
ICON_AUDIO = 'mdi:speaker'
|
||||||
ICON_PLAYER = 'mdi:play'
|
ICON_PLAYER = 'mdi:play'
|
||||||
@ -76,6 +78,9 @@ ATTR_RAW = 'raw'
|
|||||||
ATTR_DIR = 'dir'
|
ATTR_DIR = 'dir'
|
||||||
ATTR_ABT = 'abt'
|
ATTR_ABT = 'abt'
|
||||||
ATTR_NEW = 'new'
|
ATTR_NEW = 'new'
|
||||||
|
ATTR_ON = 'on'
|
||||||
|
ATTR_OFF = 'off'
|
||||||
|
ATTR_TOGGLE = 'toggle'
|
||||||
|
|
||||||
_VOL_HEX = vol.Any(vol.Coerce(int), lambda x: int(x, 16))
|
_VOL_HEX = vol.Any(vol.Coerce(int), lambda x: int(x, 16))
|
||||||
|
|
||||||
@ -92,9 +97,7 @@ SERVICE_VOLUME = 'volume'
|
|||||||
SERVICE_VOLUME_SCHEMA = vol.Schema({
|
SERVICE_VOLUME_SCHEMA = vol.Schema({
|
||||||
vol.Optional(CMD_UP): vol.Any(CMD_PRESS, CMD_RELEASE, vol.Coerce(int)),
|
vol.Optional(CMD_UP): vol.Any(CMD_PRESS, CMD_RELEASE, vol.Coerce(int)),
|
||||||
vol.Optional(CMD_DOWN): vol.Any(CMD_PRESS, CMD_RELEASE, vol.Coerce(int)),
|
vol.Optional(CMD_DOWN): vol.Any(CMD_PRESS, CMD_RELEASE, vol.Coerce(int)),
|
||||||
vol.Optional(CMD_MUTE): None,
|
vol.Optional(CMD_MUTE): vol.Any(ATTR_ON, ATTR_OFF, ATTR_TOGGLE),
|
||||||
vol.Optional(CMD_UNMUTE): None,
|
|
||||||
vol.Optional(CMD_MUTE_TOGGLE): None
|
|
||||||
}, extra=vol.PREVENT_EXTRA)
|
}, extra=vol.PREVENT_EXTRA)
|
||||||
|
|
||||||
SERVICE_UPDATE_DEVICES = 'update'
|
SERVICE_UPDATE_DEVICES = 'update'
|
||||||
@ -118,6 +121,7 @@ CUSTOMIZE_SCHEMA = vol.Schema({
|
|||||||
SWITCH)
|
SWITCH)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
CONF_DISPLAY_NAME = 'osd_name'
|
||||||
CONFIG_SCHEMA = vol.Schema({
|
CONFIG_SCHEMA = vol.Schema({
|
||||||
DOMAIN: vol.Schema({
|
DOMAIN: vol.Schema({
|
||||||
vol.Optional(CONF_DEVICES): vol.Any(DEVICE_SCHEMA,
|
vol.Optional(CONF_DEVICES): vol.Any(DEVICE_SCHEMA,
|
||||||
@ -127,6 +131,7 @@ CONFIG_SCHEMA = vol.Schema({
|
|||||||
})),
|
})),
|
||||||
vol.Optional(CONF_PLATFORM): vol.Any(SWITCH, MEDIA_PLAYER),
|
vol.Optional(CONF_PLATFORM): vol.Any(SWITCH, MEDIA_PLAYER),
|
||||||
vol.Optional(CONF_HOST): cv.string,
|
vol.Optional(CONF_HOST): cv.string,
|
||||||
|
vol.Optional(CONF_DISPLAY_NAME): cv.string,
|
||||||
})
|
})
|
||||||
}, extra=vol.ALLOW_EXTRA)
|
}, extra=vol.ALLOW_EXTRA)
|
||||||
|
|
||||||
@ -156,8 +161,9 @@ def setup(hass: HomeAssistant, base_config):
|
|||||||
"""Setup CEC capability."""
|
"""Setup CEC capability."""
|
||||||
from pycec.network import HDMINetwork
|
from pycec.network import HDMINetwork
|
||||||
from pycec.commands import CecCommand, KeyReleaseCommand, KeyPressCommand
|
from pycec.commands import CecCommand, KeyReleaseCommand, KeyPressCommand
|
||||||
from pycec.const import KEY_VOLUME_UP, KEY_VOLUME_DOWN, KEY_MUTE, \
|
from pycec.const import KEY_VOLUME_UP, KEY_VOLUME_DOWN, KEY_MUTE_ON, \
|
||||||
ADDR_AUDIOSYSTEM, ADDR_BROADCAST, ADDR_UNREGISTERED
|
KEY_MUTE_OFF, KEY_MUTE_TOGGLE, ADDR_AUDIOSYSTEM, ADDR_BROADCAST, \
|
||||||
|
ADDR_UNREGISTERED
|
||||||
from pycec.cec import CecAdapter
|
from pycec.cec import CecAdapter
|
||||||
from pycec.tcp import TcpAdapter
|
from pycec.tcp import TcpAdapter
|
||||||
|
|
||||||
@ -175,14 +181,18 @@ def setup(hass: HomeAssistant, base_config):
|
|||||||
# Create own thread if more than 1 CPU
|
# Create own thread if more than 1 CPU
|
||||||
hass.loop if multiprocessing.cpu_count() < 2 else None)
|
hass.loop if multiprocessing.cpu_count() < 2 else None)
|
||||||
host = base_config[DOMAIN].get(CONF_HOST, None)
|
host = base_config[DOMAIN].get(CONF_HOST, None)
|
||||||
|
display_name = base_config[DOMAIN].get(CONF_DISPLAY_NAME,
|
||||||
|
DEFAULT_DISPLAY_NAME)
|
||||||
if host:
|
if host:
|
||||||
adapter = TcpAdapter(host, name="HASS", activate_source=False)
|
adapter = TcpAdapter(host, name=display_name, activate_source=False)
|
||||||
else:
|
else:
|
||||||
adapter = CecAdapter(name="HASS", activate_source=False)
|
adapter = CecAdapter(name=display_name, activate_source=False)
|
||||||
hdmi_network = HDMINetwork(adapter, loop=loop)
|
hdmi_network = HDMINetwork(adapter, loop=loop)
|
||||||
|
|
||||||
def _volume(call):
|
def _volume(call):
|
||||||
"""Increase/decrease volume and mute/unmute system."""
|
"""Increase/decrease volume and mute/unmute system."""
|
||||||
|
mute_key_mapping = {ATTR_TOGGLE: KEY_MUTE_TOGGLE, ATTR_ON: KEY_MUTE_ON,
|
||||||
|
ATTR_OFF: KEY_MUTE_OFF}
|
||||||
for cmd, att in call.data.items():
|
for cmd, att in call.data.items():
|
||||||
if cmd == CMD_UP:
|
if cmd == CMD_UP:
|
||||||
_process_volume(KEY_VOLUME_UP, att)
|
_process_volume(KEY_VOLUME_UP, att)
|
||||||
@ -190,7 +200,8 @@ def setup(hass: HomeAssistant, base_config):
|
|||||||
_process_volume(KEY_VOLUME_DOWN, att)
|
_process_volume(KEY_VOLUME_DOWN, att)
|
||||||
elif cmd == CMD_MUTE:
|
elif cmd == CMD_MUTE:
|
||||||
hdmi_network.send_command(
|
hdmi_network.send_command(
|
||||||
KeyPressCommand(KEY_MUTE, dst=ADDR_AUDIOSYSTEM))
|
KeyPressCommand(mute_key_mapping[att],
|
||||||
|
dst=ADDR_AUDIOSYSTEM))
|
||||||
hdmi_network.send_command(
|
hdmi_network.send_command(
|
||||||
KeyReleaseCommand(dst=ADDR_AUDIOSYSTEM))
|
KeyReleaseCommand(dst=ADDR_AUDIOSYSTEM))
|
||||||
_LOGGER.info("Audio muted")
|
_LOGGER.info("Audio muted")
|
||||||
@ -207,7 +218,7 @@ def setup(hass: HomeAssistant, base_config):
|
|||||||
hdmi_network.send_command(KeyReleaseCommand(dst=ADDR_AUDIOSYSTEM))
|
hdmi_network.send_command(KeyReleaseCommand(dst=ADDR_AUDIOSYSTEM))
|
||||||
else:
|
else:
|
||||||
att = 1 if att == "" else int(att)
|
att = 1 if att == "" else int(att)
|
||||||
for _ in range(1, att):
|
for _ in range(0, att):
|
||||||
hdmi_network.send_command(
|
hdmi_network.send_command(
|
||||||
KeyPressCommand(cmd, dst=ADDR_AUDIOSYSTEM))
|
KeyPressCommand(cmd, dst=ADDR_AUDIOSYSTEM))
|
||||||
hdmi_network.send_command(
|
hdmi_network.send_command(
|
||||||
|
@ -59,8 +59,8 @@ class CecPlayerDevice(CecDevice, MediaPlayerDevice):
|
|||||||
|
|
||||||
def mute_volume(self, mute):
|
def mute_volume(self, mute):
|
||||||
"""Mute volume."""
|
"""Mute volume."""
|
||||||
from pycec.const import KEY_MUTE
|
from pycec.const import KEY_MUTE_TOGGLE
|
||||||
self.send_keypress(KEY_MUTE)
|
self.send_keypress(KEY_MUTE_TOGGLE)
|
||||||
|
|
||||||
def media_previous_track(self):
|
def media_previous_track(self):
|
||||||
"""Go to previous track."""
|
"""Go to previous track."""
|
||||||
|
@ -192,9 +192,9 @@ hdmi_cec:
|
|||||||
down:
|
down:
|
||||||
description: Decreases volume x levels.
|
description: Decreases volume x levels.
|
||||||
example: 3
|
example: 3
|
||||||
mute: Mutes audio system. Value is ignored.
|
mute:
|
||||||
unmute: Unmutes audio system. Value is ignored.
|
description: Mutes audio system. Value should be on, off or toggle.
|
||||||
toggle mute: Toggles mute of audio system. Value is ignored.
|
example: "toggle"
|
||||||
|
|
||||||
select_device:
|
select_device:
|
||||||
description: Select HDMI device.
|
description: Select HDMI device.
|
||||||
|
@ -378,7 +378,7 @@ pwaqi==1.3
|
|||||||
py-cpuinfo==0.2.3
|
py-cpuinfo==0.2.3
|
||||||
|
|
||||||
# homeassistant.components.hdmi_cec
|
# homeassistant.components.hdmi_cec
|
||||||
pyCEC==0.4.6
|
pyCEC==0.4.9
|
||||||
|
|
||||||
# homeassistant.components.switch.tplink
|
# homeassistant.components.switch.tplink
|
||||||
pyHS100==0.2.3
|
pyHS100==0.2.3
|
||||||
|
Loading…
x
Reference in New Issue
Block a user