-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
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
Added support for tellstick devices and sensors #5
Conversation
import tellcore.constants as tellcore_constants | ||
except ImportError: | ||
logger.exception( | ||
"Failed to import TelldusCore") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This module should be added to requirements.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that it might be unnecessary to install the tellcore if you don't want to use the tellstick feature? But I can add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I currently have no good way yet of distinguishing between required and optional dependencies so for now all go in requirements.txt.
Thanks for your contribution, this looks great! Next to the comments I just added to the pull request, would you also take the time to update the demo component to include the new devices? |
I just read up on the Telldus device and it looks like it can be used to control wall-plug socket receivers. This seems very similar to the wemo switch that is currently supported. It would be best if we merge wemo and telldus_device into a new domain called 'switch' and differentiate in the config with a type attribute which devices are to be used. This is also how it is done in the If you can wait an hour I'll refactor wemo into a switch domain and push it out so you can add your telldus to it. |
That would be nice. But Tellstick also have devices with dim functionality. I haven't implemented any support for that a the moment since I don't own any dim capable switches. But that might be possible to add to the switch class also? |
Yes. Not all types will have to implement the same features. We would add dim as an attribute to the turn_on service. Something similar is done with color for the light/turn_on service. The attribute can be ignored by devices that do not support it. |
Made the changes to the sensors part of the commit. Will try to add the changes to work with the new switch domain tomorrow when you are done refactoring. |
Registers services `tellstick_device/turn_on` and `tellstick_device/turn_off` to turn a or all tellstick devices on or off. | ||
|
||
**tellstick_sensor** | ||
Shows the values of that sensors that is connected to your Tellstick. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shows the values of the sensors that are connected to your Tellstick.
Tellstick sensors now uses the unit_of_measurement attribute and tellstick devices is now a part of the switch component |
def is_on(self): | ||
""" True if switch is on. """ | ||
try: | ||
import tellcore.constants as tellcore_constants |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems more appropriate in the get_tellstick_switches method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I move it, pylint complains about undefined variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's disable that warning, a linter should get better code, not force worse ☺. To disable warning you can use # pylint: disable=NAME-OF-WARNING
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If i put it in get_tellstick_switches I get the error:
NameError: name 'tellcore_constants' is not defined
So I guess it's not possible to move it?
Can you make sure the PyLint and pep8 validators are fine with the code? The code has some minor style issues. From the command line in the root dir of the gir repo run: |
@@ -238,3 +256,40 @@ def is_on(self): | |||
def get_state_attributes(self): | |||
""" Returns optional state attributes. """ | |||
return self.state_attr | |||
|
|||
class TellstickSwitch(Switch): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a small change, you have to extend homeassistant.components.ToggleDevice instead of Switch. I promise I won't make any breaking changes anymore before your pull request gets merged.
I messed up my branch a bit so forced a new commit with the new content. |
Weird, I was commenting from my phone and it seems that my comments didn't make it into the normal code review tab, must have clicked something weird. Anyway, a few minor changes and it should be good to go ! |
PEP8 and PyLint still find these errors which also should be fixed: Pylint: |
""" Turns the switch on. """ | ||
self.tellstick.turn_on() | ||
|
||
def turn_off(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also take **kwargs
I still see the following PEP8 errors: Fix these and add **kwargs to turn_off and I'll merge it! Thanks for your patience |
""" True if switch is on. """ | ||
|
||
try: | ||
import tellcore.constants as tellcore_constants |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I never realized that importing it inside a method does not add it to the global scope but it does make sense. Let's leave it like it is for now. In the future it might be neater to cache the turn on / off command mask but I won't make it a show stopper for the pull request.
I want to refactor a bit in switches so I'm going to merge it right now and do the few fixes myself. Thanks for your contribution! |
This has just been merged! |
We must have different settings for PEP8 because I didn't get any errors while running PEP8. |
* 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)
* 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
* 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 * check cec message length when asking physical address (#38) (#38) * cec turn on/turn off commands instead of power * cec turn on/turn off commands instead of power
Draft: Resolve "Rebase with the latest upstream/dev" Closes #5 See merge request group-91450937/core!2
Adds the functionality to track and control tellstick devices and sensors