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

Extend itach repeat functionality #36535

Merged
merged 3 commits into from
Jun 23, 2020
Merged

Extend itach repeat functionality #36535

merged 3 commits into from
Jun 23, 2020

Conversation

celestinjr
Copy link
Contributor

Proposed change

This change implements a per-device configuration parameter "ir_count", which is intended to be used when a particular ir sequence must be repeated some minimum number of times for the device to interpret the command (such as for Sony TVs, which require a code to be repeated 2-3 times.)

Using this new parameter, use of the "num_repeats" parameter is more consistent with the original intent.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml
remote:
  - platform: itach
    host: itach023fdc
    devices:
      - name: TV
        connaddr: 2
        ir_count: 3
        commands:
          - name: "ON"
            data: "0000 006D 0000 0022 00AC 00AC 0015 0040 0015 0040 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0040 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0015 0015 0015 0015 0040 0015 0040 0015 0015 0015 0015 0015 0040 0015 0015 0015 0040 0015 0040 0015 0015 0015 0015 0015 0040 0015 0040 0015 0015 0015 0689"
          - name: "OFF"
            data: "0000 006D 0000 0022 00AC 00AC 0015 0040 0015 0040 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0040 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0040 0015 0015 0015 0015 0015 0040 0015 0040 0015 0040 0015 0040 0015 0015 0015 0015 0015 0040 0015 0040 0015 0015 0015 0689"

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

@celestinjr celestinjr marked this pull request as ready for review June 7, 2020 17:22
for single_command in command:
self.itachip2ir.send(self._name, single_command, num_repeats)
self.itachip2ir.send(
self._name, single_command, self._ir_count * num_repeats
Copy link
Contributor

Choose a reason for hiding this comment

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

Say i had a TV that needed 3 ir count for power but i then sent a command of volume up or such. Will this mean that the volume raises once (ie all commands need the 3 ir) or will it raise volume 3x?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As long as ‘ir_count’ is a reasonable value, you won’t get repeat commands sent. It should be device specific, so if you need 3 repeats for power on a particular device, you should need the same number of repeats for one volume increment.

self.schedule_update_ha_state()

def turn_off(self, **kwargs):
"""Turn the device off."""
self._power = False
num_repeats = kwargs.get(ATTR_NUM_REPEATS, 1)
self.itachip2ir.send(self._name, "OFF", num_repeats)
self.itachip2ir.send(self._name, "OFF", self._ir_count)
Copy link
Member

Choose a reason for hiding this comment

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

You need to still respect NUM_REPEATS when it is passed in

num_repeats = kwargs.get(ATTR_NUM_REPEATS, self._ir_count)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So prior to PR 36362, NUM_REPEATS was never honored, neither for turn_on/off nor for send_command. I don’t think one should ever intend to repeat a turn_on or turn_off command, unless the device ‘needs’ to see a command repeated in order to respond, which was the driver for implementing this ‘ir_count’ parameter.

We can honor the NUM_REPEATS for turn_on/off, but I can’t think of a valid use case. Note that ‘send_command’ does in fact honor NUM_REPEATS, which can be useful for smooth volume adjustment among other things.

@balloob balloob merged commit 63baf6f into home-assistant:dev Jun 23, 2020
@lock lock bot locked and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants