Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implementing users remarks #5481

Merged
merged 115 commits into from
Jan 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
ffcf787
cec client object
Nov 28, 2016
e4f45db
cec command structure
Nov 28, 2016
d93e897
autodetect source
Nov 28, 2016
8da7167
volume support and native source select
Dec 2, 2016
689c29a
switch device
Dec 2, 2016
0abe667
media player device
Dec 2, 2016
311ab23
detecting of state
Dec 2, 2016
ac6278f
friendly names
Dec 2, 2016
f5b7949
hdmi cec properties
Dec 3, 2016
171893b
presence detection
Dec 3, 2016
25ae521
simplified callbacks
Dec 3, 2016
13adaf4
stable names
Dec 3, 2016
4fc9f9d
renamed methods
Dec 3, 2016
b8772fb
code cleanup
Dec 3, 2016
4820830
name with vendor
Dec 3, 2016
14f8d0e
fixed standby call name
Dec 3, 2016
33dcc21
fake standby/poweron
Dec 4, 2016
dc1a0eb
domain switch
konikvranik Dec 4, 2016
b17bdf9
domain switch
konikvranik Dec 4, 2016
aedb157
async updating
Dec 5, 2016
7298472
update separated
Dec 5, 2016
6bec80f
cec -> hass event bridge
Dec 5, 2016
faf5eea
fixed name generation
Dec 5, 2016
d8e2642
code cleanup
Dec 5, 2016
1375660
code cleanup
Dec 5, 2016
69cf4f4
icon constants
Dec 5, 2016
d2172e4
code cleanup
Dec 5, 2016
27199b4
do not register unavailable devices
Dec 5, 2016
83573bb
discovery of deevices
konikvranik Dec 5, 2016
9869a90
code cleanup
konikvranik Dec 5, 2016
61f3f45
cec device discovery
Dec 6, 2016
76085b5
moved method implementation into child
Dec 6, 2016
a07bff6
service descriptions
Dec 6, 2016
6ec532f
service descriptions
Dec 6, 2016
65bf940
service descriptions
Dec 6, 2016
6c756c8
changed entity init sequence
Dec 6, 2016
eaa16d3
logging cleanup
Dec 6, 2016
e6e3e51
add remove as job
Dec 8, 2016
eec8092
closing cec, no service schemas
Dec 8, 2016
a1a4e52
correct iterate over dictionary
Dec 8, 2016
2a36685
Volume by commands
konikvranik Dec 11, 2016
5242d89
threading
konikvranik Dec 11, 2016
10a170f
logging minimized
konikvranik Dec 11, 2016
2abae3a
get load out of main thread
konikvranik Dec 11, 2016
2b629c4
naming cleanup
konikvranik Dec 11, 2016
746fad8
get load out of main thread
konikvranik Dec 11, 2016
bb98400
optimized discovery
konikvranik Dec 11, 2016
d1d8a81
async where possible
Dec 12, 2016
e9a42f3
cleanup logging, constructors first
Dec 12, 2016
b8b35d4
pydoc
Dec 12, 2016
19e36d9
formatting
Dec 12, 2016
d05b0df
no async_update from out of loop
Dec 12, 2016
47aac7e
no async
Dec 14, 2016
4afdf29
working async cec
konikvranik Dec 14, 2016
1bcf23f
cec in thirdparty lib
Dec 15, 2016
19e2a08
cec initialized oudsice
Dec 15, 2016
668da72
working without SIGSEGV
Dec 16, 2016
6567ee6
rollbacked file changed by mistake
Dec 16, 2016
2ce64c6
sending of commands
Dec 16, 2016
8db0c74
working with ha
Dec 16, 2016
e0b6896
using hass loop and device driven updates
Dec 16, 2016
e13495d
version up
Dec 16, 2016
ab84aaf
version up
Dec 16, 2016
9317695
Command types in pycec, cleanup for HA integration
Dec 19, 2016
fb34988
Removed media player, state moved to switch
Dec 19, 2016
1aa0d4f
requirements: pyCEC
Dec 19, 2016
ba2b348
line width to 79
Dec 19, 2016
46914c3
doc
Dec 19, 2016
9a34812
doc
Dec 19, 2016
6ebfa7d
service descriptions
Dec 6, 2016
53a011f
overindentation solved
Dec 19, 2016
3374a8b
HDMI to uppercase
Dec 19, 2016
2fdcc3b
minimal dependency on cec
Dec 19, 2016
627aa9f
removed unwanted line
Dec 19, 2016
5fa11f6
doc wording
Dec 19, 2016
4879259
margin 79
Dec 19, 2016
6af706c
line continuation indent
Dec 19, 2016
1f06c83
imperative doc
Dec 19, 2016
3fa5a50
lint: indentation
Dec 19, 2016
3e2ab7a
fixed overindented
Dec 19, 2016
f289413
fixed overindented
Dec 19, 2016
603fa1e
fixed overindented
Dec 19, 2016
0e408ef
fixed overindented
Dec 19, 2016
4cb2d10
order of imports
Dec 19, 2016
821e317
PEP8
Dec 19, 2016
241f098
keep signature of overriding
konikvranik Dec 19, 2016
15049f2
removed redundant blank line
konikvranik Dec 19, 2016
06399d1
fixed update call method (#4)
konikvranik Dec 20, 2016
c96783b
Preparation for merge to upstream (#5)
konikvranik Dec 20, 2016
d7227c4
Dev (#6)
konikvranik Dec 20, 2016
e14b527
Dev (#7)
konikvranik Dec 20, 2016
647c8ee
Backwards compatibility of hdmi_cec (#10)
konikvranik Dec 21, 2016
b10bfe6
new version of pyCEC (#12)
konikvranik Dec 21, 2016
6557f7b
devices config (#13)
konikvranik Dec 21, 2016
88f099c
shutdown fix (#14)
konikvranik Dec 21, 2016
1ff62de
remove misplaced annotations (#15)
konikvranik Dec 21, 2016
86d000f
pyCEC version 0.3.6 (#18)
konikvranik Dec 23, 2016
78b83eb
support for media_player (#21)
konikvranik Dec 26, 2016
f5ffb1c
Dev (#23)
konikvranik Dec 26, 2016
e8de958
TCP CEC support (#24)
konikvranik Dec 27, 2016
254eebe
volume handling (#25)
konikvranik Dec 27, 2016
cfd0c12
Incorporated CR remarks (#26)
konikvranik Jan 1, 2017
7c9c359
implemented CR remarks (#27)
konikvranik Jan 5, 2017
ea80eeb
requirements (#28)
konikvranik Jan 20, 2017
3088205
incorporate remarks from users (#32)
konikvranik Jan 21, 2017
a149bdd
Home assistant 29 (#34)
konikvranik Jan 21, 2017
86f709c
Home assistant 31 (#35)
konikvranik Jan 21, 2017
782afab
Home assistant 31 (#36)
konikvranik Jan 21, 2017
0196714
Merge branch 'dev' into master
konikvranik Jan 21, 2017
d2fe6e9
formatting
konikvranik Jan 21, 2017
7b258a6
service description
konikvranik Jan 21, 2017
fa5a103
service description
konikvranik Jan 21, 2017
42e1d47
single attribute for volume
konikvranik Jan 21, 2017
35cef6b
fixed mute on -> mute off
konikvranik Jan 21, 2017
27853d7
moved config constant from core into component
konikvranik Jan 21, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions homeassistant/components/hdmi_cec.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity import Entity

REQUIREMENTS = ['pyCEC==0.4.6']
REQUIREMENTS = ['pyCEC==0.4.9']

DOMAIN = 'hdmi_cec'

_LOGGER = logging.getLogger(__name__)

DEFAULT_DISPLAY_NAME = "HomeAssistant"

ICON_UNKNOWN = 'mdi:help'
ICON_AUDIO = 'mdi:speaker'
ICON_PLAYER = 'mdi:play'
Expand Down Expand Up @@ -76,6 +78,9 @@
ATTR_DIR = 'dir'
ATTR_ABT = 'abt'
ATTR_NEW = 'new'
ATTR_ON = 'on'
ATTR_OFF = 'off'
ATTR_TOGGLE = 'toggle'

_VOL_HEX = vol.Any(vol.Coerce(int), lambda x: int(x, 16))

Expand All @@ -92,9 +97,7 @@
SERVICE_VOLUME_SCHEMA = vol.Schema({
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_MUTE): None,
vol.Optional(CMD_UNMUTE): None,
vol.Optional(CMD_MUTE_TOGGLE): None
vol.Optional(CMD_MUTE): vol.Any(ATTR_ON, ATTR_OFF, ATTR_TOGGLE),
}, extra=vol.PREVENT_EXTRA)

SERVICE_UPDATE_DEVICES = 'update'
Expand All @@ -118,6 +121,7 @@
SWITCH)
})

CONF_DISPLAY_NAME = 'osd_name'
CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({
vol.Optional(CONF_DEVICES): vol.Any(DEVICE_SCHEMA,
Expand All @@ -127,6 +131,7 @@
})),
vol.Optional(CONF_PLATFORM): vol.Any(SWITCH, MEDIA_PLAYER),
vol.Optional(CONF_HOST): cv.string,
vol.Optional(CONF_DISPLAY_NAME): cv.string,
})
}, extra=vol.ALLOW_EXTRA)

Expand Down Expand Up @@ -156,8 +161,9 @@ def setup(hass: HomeAssistant, base_config):
"""Setup CEC capability."""
from pycec.network import HDMINetwork
from pycec.commands import CecCommand, KeyReleaseCommand, KeyPressCommand
from pycec.const import KEY_VOLUME_UP, KEY_VOLUME_DOWN, KEY_MUTE, \
ADDR_AUDIOSYSTEM, ADDR_BROADCAST, ADDR_UNREGISTERED
from pycec.const import KEY_VOLUME_UP, KEY_VOLUME_DOWN, KEY_MUTE_ON, \
KEY_MUTE_OFF, KEY_MUTE_TOGGLE, ADDR_AUDIOSYSTEM, ADDR_BROADCAST, \
ADDR_UNREGISTERED
from pycec.cec import CecAdapter
from pycec.tcp import TcpAdapter

Expand All @@ -175,22 +181,27 @@ def setup(hass: HomeAssistant, base_config):
# Create own thread if more than 1 CPU
hass.loop if multiprocessing.cpu_count() < 2 else None)
host = base_config[DOMAIN].get(CONF_HOST, None)
display_name = base_config[DOMAIN].get(CONF_DISPLAY_NAME,
DEFAULT_DISPLAY_NAME)
if host:
adapter = TcpAdapter(host, name="HASS", activate_source=False)
adapter = TcpAdapter(host, name=display_name, activate_source=False)
else:
adapter = CecAdapter(name="HASS", activate_source=False)
adapter = CecAdapter(name=display_name, activate_source=False)
hdmi_network = HDMINetwork(adapter, loop=loop)

def _volume(call):
"""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():
if cmd == CMD_UP:
_process_volume(KEY_VOLUME_UP, att)
elif cmd == CMD_DOWN:
_process_volume(KEY_VOLUME_DOWN, att)
elif cmd == CMD_MUTE:
hdmi_network.send_command(
KeyPressCommand(KEY_MUTE, dst=ADDR_AUDIOSYSTEM))
KeyPressCommand(mute_key_mapping[att],
dst=ADDR_AUDIOSYSTEM))
hdmi_network.send_command(
KeyReleaseCommand(dst=ADDR_AUDIOSYSTEM))
_LOGGER.info("Audio muted")
Expand All @@ -207,7 +218,7 @@ def _process_volume(cmd, att):
hdmi_network.send_command(KeyReleaseCommand(dst=ADDR_AUDIOSYSTEM))
else:
att = 1 if att == "" else int(att)
for _ in range(1, att):
for _ in range(0, att):
hdmi_network.send_command(
KeyPressCommand(cmd, dst=ADDR_AUDIOSYSTEM))
hdmi_network.send_command(
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/media_player/hdmi_cec.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def send_playback(self, key):

def mute_volume(self, mute):
"""Mute volume."""
from pycec.const import KEY_MUTE
self.send_keypress(KEY_MUTE)
from pycec.const import KEY_MUTE_TOGGLE
self.send_keypress(KEY_MUTE_TOGGLE)

def media_previous_track(self):
"""Go to previous track."""
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ hdmi_cec:
down:
description: Decreases volume x levels.
example: 3
mute: Mutes audio system. Value is ignored.
unmute: Unmutes audio system. Value is ignored.
toggle mute: Toggles mute of audio system. Value is ignored.
mute:
description: Mutes audio system. Value should be on, off or toggle.
example: "toggle"

select_device:
description: Select HDMI device.
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ pwaqi==1.3
py-cpuinfo==0.2.3

# homeassistant.components.hdmi_cec
pyCEC==0.4.6
pyCEC==0.4.9

# homeassistant.components.switch.tplink
pyHS100==0.2.3
Expand Down