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

media_player doesn't send off IR command if entity is off but TV is on #156

Open
rafareusch opened this issue Nov 23, 2024 · 9 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@rafareusch
Copy link

rafareusch commented Nov 23, 2024

I'm having a issue with the debug logs and will update this post with relevant logs and yaml shortly

Home Assistant version
2024.11.2

SmartIR version
1.19.0

SmartIR configuration

media_player:
  - platform: smartir
    name: Smartir TV sala
    unique_id: smartir_tvsala
    device_code: 1060
    controller_data:
      controller_type: Broadlink
      remote_entity: remote.rm4new
      delay_secs: 0.5
      num_repeats: 1

Describe the bug
AFTER 1.17.15, if the TV is ON but the TV media player entity is OFF (turned on via real remote). HA wont turn TV off using the media_player.turn_off service. The IR command is not sent

If I turn the entity ON, then OFF, the OFF IR command will be sent.
(either via UI or service)

Expected behavior
To HA always send the IR turn off command independently to the entity state (climate entity works exactly like that!)
(works this way before 1.17.15)

To Reproduce

  1. Turn on TV manually
  2. send media_player.turn_off command to the corresponding TV entity

Debug log
(it's the only log related to smartir i see after reproducing the bug)

2024-11-23 17:52:58.030 DEBUG (MainThread) [custom_components.smartir.media_player] Setting up the SmartIR media player platform

Additional context
I want to reinforce that the climate entity works exactly in the way described in Expected field. I was using the "official" SmartIR integration and never encountered this issue. I'm currently reinstalling it to check and will update this post with the information

@rafareusch
Copy link
Author

rafareusch commented Nov 23, 2024

I can confirm that in 1.17.14, this behavior is not present. The media_player works as I described in the Expected field.

@rafareusch
Copy link
Author

The issue is present after 1.17.15
Seems to be related to this commit from @litinoveweedle

@litinoveweedle
Copy link
Owner

Hello, can you please check, if the ON and OFF code are different or same?

@rafareusch
Copy link
Author

Hello, can you please check, if the ON and OFF code are different or same?

In this case yes, the repo has discrete on and off commands

@litinoveweedle
Copy link
Owner

Yep, I can confirm this bug. The proposed correction is to sent always ON or OFF command except the case, when ON and OFF codes are same - then the current functionality will be kept.

@litinoveweedle litinoveweedle added bug Something isn't working and removed potential bug labels Dec 5, 2024
@rafareusch
Copy link
Author

rafareusch commented Dec 5, 2024

Yep, I can confirm this bug. The proposed correction is to sent always ON or OFF command except the case, when ON and OFF codes are same - then the current functionality will be kept.

I would suggest always send the command, independly of the state of the entity because the entity state doesn't have a direct relation to the real tv state. (This is the exact way Tuya impleents it's fantastic IR service)

Imagine this situation:

  • ON and OFF codes are equal, mediaplayer entity is OFF and TV is OFF
  • I Turn on TV by the physical remote
  • I call alexa: "Alexa, turn off the TV"
  • SmartIR would not turn off the tv, because both codes are equal and entity state is off
    Doesn't sound good

The only case in which this makes sense is if both codes are equal AND the feature of power_sensor is enabled (entity attributed to it)

@litinoveweedle
Copy link
Owner

While I understand you explanation, the feature to prevent sending again ON/OFF commands was implemented based on #70 and you can read very good reasoning behind it as well. So if we will not come with some smart idea how to accommodate both cases.....

@rafareusch
Copy link
Author

While I understand you explanation, the feature to prevent sending again ON/OFF commands was implemented based on #70 and you can read very good reasoning behind it as well. So if we will not come with some smart idea how to accommodate both cases.....

Okay, good point, but... Make it configurable!
We have the same issues with cover_template, in yaml we have a field called optimistic
if it's true, the HA stores the internal state and will refuse to send a command to lower the cover if it's already in lowered state.
if it's false, you can send whatever command whenever you want to.

@litinoveweedle
Copy link
Owner

Good point. Even I am not much of a fan of inflating configuration to include options for every single use case, this one is probably deserved. To keep backward compatibility, by default this option would be set to false. It will be only used in case when the power sensor is not used. I think then similar change needs to be implemented in all classes across SmartIR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants