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

Enable detached mode and add ability to skip exposing individual channels on Shelly 2 and 2.5 #307

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

BMDan
Copy link

@BMDan BMDan commented May 16, 2021

This PR enables device configurations like this (for two 2.5s):

[
    {
        "id": "0123456789ABCD",
        "channels": [
            {},
            {
                "type": "detachedContactSensor"
            }
        ]
    },
    {
        "id": "FEDCBA986754",
        "type": "detachedContactSensor",
        "channels": [
            {
                "type": "skip"
            }
        ]
    }
]

It also enhances logging in a few useful spots, and adds a hint for how to get describe to work for those who have enabled HTTP auth.

Tested only insofar as my little setup enables me to test. I apologize in advance for the crimes I have doubtless committed against idiomatic Node; I plead ignorance and a genuine belief that working, ugly code is better than no code at all.

Closes #87
Relevant to (but doesn't yet close) #219

@BMDan BMDan changed the title Feat detached and skip Enable detached mode and add ability to skip exposing individual channels on Shelly 2 and 2.5 May 16, 2021
@aschempp
Copy link

Does this "skipping" maybe conflict with #306 ?

@BMDan
Copy link
Author

BMDan commented May 19, 2021

Does this "skipping" maybe conflict with #306 ?

Yup. We're going a similar direction, though. If either of these get merged, the other of us should just rebase.

Alternatively, IMHO, yours is a clearly better implementation, but I prefer my own data structure (maps where the keyspace is dense, small and numeric give me fits 🤣 ). If you switch to arrays to describe the channels, I'd rebase atop yours immediately.

@aschempp
Copy link

I actually considered using an array, but the problem is that you can't configure channel 3 without configuring channel 0, 1, 2 then. What's your opinion on that?

@BMDan
Copy link
Author

BMDan commented May 29, 2021

I actually considered using an array, but the problem is that you can't configure channel 3 without configuring channel 0, 1, 2 then. What's your opinion on that?

My approach is to allow null (or { }, if that happens to be your preference) as a perfectly valid array entry, signifying "no overrides tor this channel". Not saying that's the prettiest solution, so I'm open to better approaches, but I think it is at least somewhat intuitive both at configuration-time and subsequently when reading.

@aschempp
Copy link

Thats a clever idea! I can see to adopt that asap 😊

@aschempp
Copy link

I just checked my code. Appart from the JSON schema and README, I think array syntax and null value is already fully supported, since there's no differences on accessing foo[0] whether that's an array or object. Or maybe I'm missing something?

@Krillle
Copy link

Krillle commented Dec 17, 2021

@BMDan Great addition. I would love to see the same for Shelly UNI
I feel like it would be easy with a few lines of code to enable detached mode and add ability to skip exposing individual channels on Shelly UNI as well. Yet the changes are too complex to find the right lines right away. Could you give me some hints?

@BMDan
Copy link
Author

BMDan commented May 2, 2022

I ended up abandoning this project in favor of https://github.com/mongoose-os-apps/shelly-homekit, which seems to be far more stable, if a bit more of a bear to set up initially. @alexryd is still welcome to merge the code, of course, but I won't be updating it further.

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 this pull request may close these issues.

Detached mode for shelly 1
3 participants