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

Added support for tellstick devices and sensors #5

Closed
wants to merge 2 commits into from
Closed

Added support for tellstick devices and sensors #5

wants to merge 2 commits into from

Conversation

Gyran
Copy link
Contributor

@Gyran Gyran commented Nov 8, 2014

Adds the functionality to track and control tellstick devices and sensors

import tellcore.constants as tellcore_constants
except ImportError:
logger.exception(
"Failed to import TelldusCore")
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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.

@balloob
Copy link
Member

balloob commented Nov 8, 2014

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?

@balloob
Copy link
Member

balloob commented Nov 8, 2014

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 light and device_tracker components. (Next step would be to support multiple types, I have some ideas about that and will try to implement that later).

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.

@Gyran
Copy link
Contributor Author

Gyran commented Nov 8, 2014

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?

@balloob
Copy link
Member

balloob commented Nov 8, 2014

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.

@Gyran
Copy link
Contributor Author

Gyran commented Nov 9, 2014

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.
Copy link
Member

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.

@Gyran
Copy link
Contributor Author

Gyran commented Nov 9, 2014

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
Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Member

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

Copy link
Contributor Author

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?

@balloob
Copy link
Member

balloob commented Nov 9, 2014

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:
pylint homeassistant > pylint.txt
pep8 homeassistant --exclude bower_components,external > pep8.txt

@@ -238,3 +256,40 @@ def is_on(self):
def get_state_attributes(self):
""" Returns optional state attributes. """
return self.state_attr

class TellstickSwitch(Switch):
Copy link
Member

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.

@Gyran
Copy link
Contributor Author

Gyran commented Nov 11, 2014

I messed up my branch a bit so forced a new commit with the new content.

@balloob
Copy link
Member

balloob commented Nov 11, 2014

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 !

@balloob
Copy link
Member

balloob commented Nov 11, 2014

PEP8 and PyLint still find these errors which also should be fixed:
PEP8:
homeassistant/components/tellstick_sensor.py:18:80: E501 line too long (86 > 79 characters)
homeassistant/components/tellstick_sensor.py:67:13: E126 continuation line over-indented for hanging indent
homeassistant/components/tellstick_sensor.py:70:13: E126 continuation line over-indented for hanging indent
homeassistant/components/tellstick_sensor.py:72:13: E126 continuation line over-indented for hanging indent
homeassistant/components/tellstick_sensor.py:74:13: E126 continuation line over-indented for hanging indent
homeassistant/components/tellstick_sensor.py:76:13: E126 continuation line over-indented for hanging indent
homeassistant/components/tellstick_sensor.py:78:13: E126 continuation line over-indented for hanging indent
homeassistant/components/tellstick_sensor.py:80:13: E126 continuation line over-indented for hanging indent
homeassistant/components/tellstick_sensor.py:97:17: E126 continuation line over-indented for hanging indent

Pylint:
************* Module homeassistant.components.switch
W:228, 4: Arguments number differs from overridden method (arguments-differ)
************* Module homeassistant.components.tellstick_sensor
C: 65, 4: Invalid variable name "sensor_value_datatype_descriptions" (invalid-name)
C: 83, 4: Missing function docstring (missing-docstring)
C: 84, 8: Invalid variable name "sensor_value_datatype_description" (invalid-name)
C:112, 4: Missing function docstring (missing-docstring)
C:126, 4: Missing function docstring (missing-docstring)

""" Turns the switch on. """
self.tellstick.turn_on()

def turn_off(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also take **kwargs

@balloob
Copy link
Member

balloob commented Nov 12, 2014

I still see the following PEP8 errors:
homeassistant/components/tellstick_sensor.py:68:13: E126 continuation line over-indented for hanging indent
homeassistant/components/tellstick_sensor.py:71:13: E126 continuation line over-indented for hanging indent
homeassistant/components/tellstick_sensor.py:73:13: E126 continuation line over-indented for hanging indent
homeassistant/components/tellstick_sensor.py:75:13: E126 continuation line over-indented for hanging indent
homeassistant/components/tellstick_sensor.py:77:13: E126 continuation line over-indented for hanging indent
homeassistant/components/tellstick_sensor.py:79:13: E126 continuation line over-indented for hanging indent
homeassistant/components/tellstick_sensor.py:81:13: E126 continuation line over-indented for hanging indent
homeassistant/components/tellstick_sensor.py:99:17: E126 continuation line over-indented for hanging indent

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
Copy link
Member

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.

@balloob
Copy link
Member

balloob commented Nov 12, 2014

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!

@balloob
Copy link
Member

balloob commented Nov 12, 2014

This has just been merged!

@balloob balloob closed this Nov 12, 2014
@Gyran
Copy link
Contributor Author

Gyran commented Nov 12, 2014

We must have different settings for PEP8 because I didn't get any errors while running PEP8.
Thanks for the merge and the awesome project!

@Gyran Gyran deleted the tellstick branch November 13, 2014 20:16
@BornTKill BornTKill mentioned this pull request Feb 15, 2016
balloob pushed a commit that referenced this pull request Jan 20, 2017
* 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)
balloob pushed a commit that referenced this pull request Jan 21, 2017
* 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
balloob pushed a commit that referenced this pull request Jan 23, 2017
* 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
@home-assistant home-assistant locked and limited conversation to collaborators Mar 17, 2017
siamzam referenced this pull request in siamzam/home-assistant-core Oct 5, 2023
Draft: Resolve "Rebase with the latest upstream/dev"

Closes #5

See merge request group-91450937/core!2
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants