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

Summary - Broken and Attempted fixes #41

Open
ninadpchaudhari opened this issue Jun 6, 2022 · 3 comments · May be fixed by #49
Open

Summary - Broken and Attempted fixes #41

ninadpchaudhari opened this issue Jun 6, 2022 · 3 comments · May be fixed by #49

Comments

@ninadpchaudhari
Copy link

ninadpchaudhari commented Jun 6, 2022

As this tool was broken for new versions of HA,
Tried to change the WebSocket API and the commands to work with the new versions :

  sendBroadlinkLearnCmd(targetKey) {
    store.state.socket.send(JSON.stringify({
      id: store.state.socketId++,
      type: "call_service",
      service: "learn_command",
      domain: "remote",
      service_data: {
        command: targetKey,
        command_type: "ir",
        device: "remote.corridor_pro_controller_remote",
        timeout: 10
      },
      target: {
        entity_id: "remote.corridor_pro_controller_remote"
      }
    }));
  },

Sadly, the new learn_command does not give back, it only stores the same into the file. I confirmed this via the source code in HA Core's Broadlink integration: Function async_learn_command, Line

Screenshot after the change! Command is sent successfully, but the response is just the notification!
Screen Shot 2022-06-06 at 1 03 10 PM

Even earlier the HA's remote.py's learn command function did not return anything, but based on this project, I think, we are expecting an event type of state changed with the irCode let irCode = message.replace("Received packet is: ", "");
Perma Link to the function
As of now, only thing that HA send back is

{
  "id": 70,
  "type": "event",
  "event": {
    "event_type": "state_changed",
    "data": {
      "entity_id": "persistent_notification.learn_command",
      "old_state": null,
      "new_state": {
        "entity_id": "persistent_notification.learn_command",
        "state": "notifying",
        "attributes": {
          "message": "Press the 'cool_auto_19' button.",
          "title": "Learn command",
          "friendly_name": "Learn command"
        },
        "last_changed": "2022-06-06T16:55:16.622753+00:00",
        "last_updated": "2022-06-06T16:55:16.622753+00:00",
        "context": {
          "id": "01G4WZ2BWEB9TXFT4CMG6R21M2",
          "parent_id": null,
          "user_id": null
        }
      }
    },
    "origin": "LOCAL",
    "time_fired": "2022-06-06T16:55:16.622753+00:00",
    "context": {
      "id": "01G4WZ2BWEB9TXFT4CMG6R21M2",
      "parent_id": null,
      "user_id": null
    }
  }
}

I wonder

  • How did HA return back the code earier
  • How can we get the same code now! Last option is always to parse the storage file located under .storage directory
@victorigualada
Copy link

After spending the entire afternoon after this, I came to the same conclusions and ended up getting the commands from the .storage file.

I listened to all the events HA is firing when sending an IR command and the base64 is not present in any of them. So I guess there is no way with the current integration to get them as in the past.

It would be nice to create a fork of this project and at least push these findings.

I managed to get it running locally so it could be run as a docker container or an add-on.

@callumgare
Copy link

Building on your work @ninadpchaudhari and @victorigualada I've forked and updated the project. I've made a PR to merge those changes back but in the mean time you can use it at https://callumgare.github.io/BroadlinkIRTools/

@suvl
Copy link

suvl commented May 2, 2024

@victorigualada thing is, it was using a ≠ service, from the broadlink direct integration, that did return the command.
Now, these new services do not return it. That's why we'll prolly always need to parse from the .storage file.

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 a pull request may close this issue.

4 participants