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

Can't find accessories #21

Open
stevedekorte opened this issue Sep 16, 2023 · 1 comment
Open

Can't find accessories #21

stevedekorte opened this issue Sep 16, 2023 · 1 comment

Comments

@stevedekorte
Copy link

stevedekorte commented Sep 16, 2023

I'm using the following test page to get a list of my accessories (I have many, and they are all visible in the HOOBS desktop app's Accessories menu), but the response from the plugin is: {"topic":"accessories","payload":{}}. I was expecting to see a list of accessories in that payload. Am I doing something wrong?


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>WebSocket Client</title>
</head>
<body>
    <button onclick="connectWebSocket()">Connect and Send Message</button>
    <div id="output"></div>

    <script>
        function connectWebSocket() {
            const outputDiv = document.getElementById('output');

            // Create a new WebSocket connection
            const socket = new WebSocket('ws://hoobs.local:4050');

            socket.onopen = () => {
                console.log('WebSocket is connected');

                // Send the message once the connection is established
                socket.send(JSON.stringify({
                    "topic": "get",
                    "payload": {
                        "name": "all"
                    }
                }));
            };

            socket.onerror = (error) => {
                outputDiv.innerHTML = 'Error occurred: ' + JSON.stringify(error);
            };

            socket.onmessage = (event) => {
                outputDiv.innerHTML = 'Received: ' + event.data;
            };

            socket.onclose = () => {
                console.log('WebSocket is closed');
            };
        }
    </script>
</body>
</html>

@stevedekorte
Copy link
Author

stevedekorte commented Sep 16, 2023

Sorry, I just noticed the note about needing to add the accessories first. It would be helpful if this was mentioned directly in the get and add examples. Now I'm trying to add my accessories (I got the list via http://hoobs.local:51826/accessories - would be nice if homebridge-websocket used this when possible) but it doesn't seem to be working. Does this look correct?:

WebSocket sent [{"topic":"add","payload":{"name":"Master Bath Motion","service":"MotionSensor"}}]
Received: {"topic":"response","payload":{"ack":false,"message":"topic 'undefined' unknown."}}

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

No branches or pull requests

1 participant