home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.66k stars 30.41k forks source link

Broadlink integration, need an option to choose a delay between rf/ir commands #49390

Open refaelsommer opened 3 years ago

refaelsommer commented 3 years ago

The problem

I see that when I call “hey Siri turn on kitchen main light” then it always works! But when I set a scene with many multiple light switches, about 10 switches, then some do not go on, also in a scene of turning off the lights some stay on, then Running the same scene again turns off some more lights, but many times missing some. I think the issue is that when using a scene of many switches then the rm pro shoots all the codes one after another without a delay and then my switches do not catch it as a code then stop then code then stop. I really need an option to set a delay of let’s say 1 second to separate the codes when shooting a batch of many.

please update me if it is possible and please if yes then I really need that fix ASAP 🙏🏻

What is version of Home Assistant Core has the issue?

Latest specially

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Broadlink

Link to integration documentation on our website

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

felipediel commented 3 years ago

This is already possible with the delay_secs option.

refaelsommer commented 3 years ago

Where do I add it? Please Is the delay_secs per remote or per switch? I am using HomeKit for all automations and scenes so I need a general delay for all commands sent from HomeKit to home assistant so that the home assistant should delay between RF codes on the RMPro

felipediel commented 3 years ago

Example:

script:
  turn_on_ac:
    sequence:
      - service: remote.send_command
        target:
          entity_id: remote.bedroom
        data:
          device: air conditioner
          command:
            - turn on
            - turn off display
          delay_secs: 1
elupus commented 3 years ago

@felipediel he is using scenes. He can't set delay_sec. It just normal light turn on commands. All executing as fast as possible. If async, all in paralell even.

It needs to be a global setting.

@refaelsommer theoretically you can solve it by adjusting your IR codes with added delays in the code strings. But i agree we should have some support for that.

felipediel commented 3 years ago

Got it. I think this can be achieved with a lock and a global variable defined via config options.

probot-home-assistant[bot] commented 3 years ago

Hey there @danielhiversen, mind taking a look at this issue as its been labeled with an integration (broadlink) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

probot-home-assistant[bot] commented 3 years ago

broadlink documentation broadlink source (message by IssueLinks)

felipediel commented 3 years ago

Ok, let's start simple. I added a lock to BroadlinkRemote.async_send_command(). No debouncer for now.

I don't have the tech to reproduce the issue here, so I don't know if the code fixes it. Mind helping with tests? https://github.com/home-assistant/core/pull/49534.

I have a second option with a debouncer. I will make it available if the lock doesn't work.

Edit: Just realized that the homeassistant.helpers.debounce.Debouncer class can only schedule 1 extra call, not exactly what we need here. The homeassistant.util.Throttle decorator also doesn't suit our needs, because it ignores any call within the interval. We need a cooldown mechanism that schedules all the calls subsequently. If the lock doesn't work, I guess I will have to create this :(

AThomsen commented 3 years ago

I'm struggling with this as well. @felipediel, did you give up on this? :-)

felipediel commented 3 years ago

Hi. I made a patch on the same day and no one has tested it in 5 months, so the answer is yes.

AThomsen commented 3 years ago

I'd like to test it - but would that be enough to complete the pull?

felipediel commented 3 years ago

Awesome. I think so, if it works I will reopen the PR. I recommend you to set up a dev environment to test it. VsCode + devcontainer is the way to go. Then you checkout to this branch ​https://github.com/home-assistant/core/pull/49534, adjust your config files, run hass -c config and try to control the devices with Homekit.

kylehakala commented 9 months ago

Did this end up getting resolved? It’s probably a bit stale at this point but I figured I would bump this to see if it was still relevant after 2.5 years of idle time 😄