GithubHelp home page GithubHelp logo

Comments (9)

Supereg avatar Supereg commented on June 15, 2024

Iโ€˜m gonna look into it. Please have some patience, since I got very little time at the moment.

from homebridge-http-switch.

IT-Lueg avatar IT-Lueg commented on June 15, 2024

Okay, thanks, then I'll wait for an answer from you.

from homebridge-http-switch.

Supereg avatar Supereg commented on June 15, 2024

So I tried testing your configuration and couldn't find mistakes. So you get a clear 'works on my machine' ๐Ÿ˜„

However I published an update v0.5.13 which prints some more debug information. Would be great if you could update your homebridge-http-switch plugin and poste the log output. A snippet from everything printed when the plugin is loaded as well when a status requests is performed would be great.

Maybe you could also double check (with curl or something) if your pattern exactly matches the response from the shelly device. Every space or new line is relevant there.
Also the relevant json property from the response is 'ison' (isn't it?). Do the other properties change in runtime?

I noticed that this is some sort of Shelly Switch? I ordered some for me some weeks ago, they should get to me hopefully soon. Maybe I could help you more. However they need to arrive first ๐Ÿ˜…

Greets

from homebridge-http-switch.

IT-Lueg avatar IT-Lueg commented on June 15, 2024

so first I updatet the homebridge-http-switch plugin to version 0.5.13
version

When I start homebridge this is the output I get for homebridge-http-switch:
load1
load2

as soon as homebridge is started, I open the "home" app on my smartphone, switch on the "shelly" ๐Ÿ˜… and get the following output:
turnon

shelly is now turned on...
shelly_check
web

if I close the "Home" app now and open it again I get the following output
check

When I use curl (I hope I'm doing it right) I get the following message...
curl

That's right. Itยดs a "shelly2".
Oh, that's great. I hope you get it soon ๐Ÿ‘

Thanks for the great support.
I really appreciate that. ๐Ÿฅ‡

from homebridge-http-switch.

IT-Lueg avatar IT-Lueg commented on June 15, 2024

Also the relevant json property from the response is 'ison' (isn't it?). Do the other properties change in runtime?

Thats right, "ison" is the relevant property..

web
web2

I don't think the other parameters would change that way.
https://shelly-api-docs.shelly.cloud/#shelly-switch-relay-index

shelly_doc

from homebridge-http-switch.

Supereg avatar Supereg commented on June 15, 2024

Okay as I assumed there is probably some sort of character encoding problem in the config. I could be wrong what the exact cause is. Could also be confusion about the config file on your side.
When you look closely into the logs where it prints the statusPattern which is configured you can read: '..."iseon":true....'
So please double check your config, maybe retype the specific part.

from homebridge-http-switch.

IT-Lueg avatar IT-Lueg commented on June 15, 2024

Thatยดs it ! ๐Ÿ™ˆ
Now everything is working ๐Ÿ‘Œ

But why didn't it work with this configuration before ?

Can you please help me ?
I dont know what I am doing wrong...

code

cmd

[2018-11-22 09:06:42] [shelly2 2] Body of status response is: '{"ison":true,"has_timer":false,"overpower":false,"is_valid":true}'
[2018-11-22 09:06:42] [shelly2 2] Switch is currently OFF

Can you please help me to find the right statusPattern?

My config now for the 2 Switches:

 {
            "accessory": "HTTP-SWITCH",
            "name": "shelly2 1",
            "switchType": "stateful",
            "onUrl": {
                "url": "http://192.168.1.207/relay/0?turn=on",
                "method": "POST"
            },
            "offUrl": {
                "url": "http://192.168.1.207/relay/0?turn=off",
                "method": "POST"
            },
            "statusUrl": {
                "url": "http://192.168.1.207/relay/0",
                "method": "GET"
            },
            "statusPattern": "{\"ison\":true,\"has_timer\":false,\"overpower\":false,\"is_valid\":true}"
        },
        {
            "accessory": "HTTP-SWITCH",
            "name": "shelly2 2",
            "switchType": "stateful",
            "onUrl": {
                "url": "http://192.168.1.207/relay/1?turn=on",
                "method": "POST"
            },
            "offUrl": {
                "url": "http://192.168.1.207/relay/1?turn=off",
                "method": "POST"
            },
            "statusUrl": {
                "url": "http://192.168.1.207/relay/1",
                "method": "GET"
            },
            "statusPattern": "{\"ison\":true,\"has_timer\":false,\"overpower\":false,\"is_valid\":true}"
        }

from homebridge-http-switch.

Supereg avatar Supereg commented on June 15, 2024

But why didn't it work with this configuration before ?

I have absolutely no idea ๐Ÿ˜… But happy to hear, that it works now.

A little 'pro' tip, I don't know how well you know regex pattern. But in your case it would be enough to set the statusPattern to "\"ison\":true". This would ensure that the pattern matching is unaffected when the other values of the json changes somehow.
The pattern is matched if the pattern is contained in the text you want to test. Otherwise if you want to be sure that the complete response matches your body you can prepend ^ and append $ to your pattern wich match to the beginning or the end of a string.
Don't know if I explained it well enough, what I mean with that is that the pattern true matches the text 'true' as well as 'asdtrue asdkw'. However the pattern ^true$ only matches the first one.

from homebridge-http-switch.

cgilis avatar cgilis commented on June 15, 2024

Just for reference:

This worked for me (Shelly Dimmer):

{
    "accessory": "HTTP-SWITCH",
    "name": "NAME",
    "switchType": "stateful",
    "onUrl": {
        "url": "http://192.168.X.X/light/0?turn=on",
        "method": "POST"
    },
    "offUrl": {
        "url": "http://192.168.X.X/light/0?turn=off",
        "method": "POST"
    },
    "statusUrl": {
        "url": "http://192.168.X.X/light/0",
        "method": "GET"
    },
    "statusPattern": "\"ison\":true"
}

from homebridge-http-switch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.