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

Add power on method to call a service #190

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rogelio-o
Copy link

I want to call an HA service to power on the TV instead of using the WOL method provided. In my case, I am using HA in the Kubernetes environment where the WOL does not reach the LAN where the TV is, and instead of that, I use the rest_command service.

I previously used the official integration, where I can configure turn_on_action to call that service. This MR will make it equivalent to that configuration. Even you could remove the WOL implementation, and the user could rely on the Wake On LAN HA integration by calling its service.

@ollo69
Copy link
Owner

ollo69 commented Dec 12, 2022

Could you rebase this?

@rogelio-o
Copy link
Author

Could you rebase this?

Sure! Done.

Comment on lines +489 to +500
vol.Required(
CONF_POWER_ON_METHOD,
default=options.get(
CONF_POWER_ON_METHOD, str(PowerOnMethod.WOL.value)
),
): SelectSelector(_dict_to_select(POWER_ON_METHODS)),
vol.Required(
CONF_POWER_ON_SERVICE_DATA,
default=options.get(
CONF_POWER_ON_SERVICE_DATA, "{}"
),
): cv.string,
Copy link
Owner

@ollo69 ollo69 Dec 13, 2022

Choose a reason for hiding this comment

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

In this way we are going to provide a SmartThings option also if SmartThings is not enabled (not good) and we also add a text field that should be useless in some cases. This will probably confuse "normal" user and cause false issues, because I'm trying to simplify option flow (I will introduce some changes shortly), I do not like very match this approach.

I suggest to add only the text field in the advanced option:

  • if it contain some values, the power-on based on service will be used (may be you could also hide the power on method field in main form in this case)
  • if empty, everything will normally

from homeassistant.helpers import entity_registry as er
from homeassistant.helpers import config_validation as cv, entity_registry as er
Copy link
Owner

Choose a reason for hiding this comment

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

Do not import cv only for cv.string. Is enought use str

@ollo69 ollo69 self-assigned this Dec 15, 2022
@ollo69 ollo69 mentioned this pull request Jan 6, 2024
@felipecrs
Copy link

Just to mention that Home Assistant official integrations with similar needs are adopting the trigger mechanism, where you can implement your own automation for.

Example, triggers when the TV is requested to power on:

platform: samsungtv.turn_on
entity_id: media_player.samsung_tv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants