iklein99 / homebridge-smartthings

This is a plugin to Homebridge to connect your Smartthings network into Apple Home Kit.
Apache License 2.0
150 stars 52 forks source link

delay from motion detected to action #64

Closed cirrusflyer closed 1 year ago

cirrusflyer commented 1 year ago

Describe The Bug: 5-6 second delay from motion sensor detecting motion and lights turning on

To Reproduce: see above

Expected behavior: delay should be less, and was far less in the old Smartthings plugin for Homebridge

Plugin Config:

            "name": "Smartthings Plug (IK)",
            "BaseURL": "https://api.smartthings.com/v1/",
            "AccessToken": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "GarageDoorMaxPoll": 40,
            "PollLocksSeconds": 5,
            "PollDoorsSeconds": 10,
            "PollSensorsSeconds": 5,
            "PollSwitchesAndLightsSeconds": 5,
            "IgnoreDevices": [
                "Living Room Christmas Tree",
                "S31 Outlet",
                "Garage Bulb",
                "Motion Sensor 2",
                "Wireless Tag Motion",
                "Shed Door Tag",
                "Laundry Room Water Sensor",
                "Smartthings Water Sensor",
                "Garage Siren",
                "Button",
                "Office Smoke Alarm"
            ],
            "_bridge": {
                "username": "xxxxxxxxxxx",
                "port": 37871
            },
            "platform": "HomeBridgeSmartThings"

Environment: 1.5.1 Homebridge running on Docker and 1.4.9 of your plugin.

veonua commented 1 year ago

the plugin does pooling. For pushing you have to setup the https service.

cirrusflyer commented 1 year ago

No idea what you mean. It works fine - it's just slow. What are you talking about?

veonua commented 1 year ago

Every 10 seconds your Home bridge asks the Smartthings server “what is the status of the sensor”.

There is a way to subscribe to the ST server notifications, these notifications are way faster and less heavy for ST servers. But Samsung is all about security and willing to send these notifications only to trusted(TLS) servers

veonua commented 1 year ago

In fact, Samsung closed the old plugin because it is too expensive to host heavy apps in the cloud. Pooling many devices too often will affect new servers.

iklein99 commented 1 year ago

Because of the nature of the api the plug-in polls the devices.  You can change the time between checks but it won’t make calls to smartthings more frequently than once every 5 seconds. Works as intendedSent from my iPhoneOn Oct 27, 2022, at 5:30 PM, Andrew Me @.***> wrote: In fact, Samsung closed the old plugin because it is too expensive to host heavy apps in the cloud. Pooling many devices too often will affect new servers.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

cirrusflyer commented 1 year ago

Thanks. So before using this plugin, I was using Homeassistant with the Smartthings integration, and sharing those as a Homekit bridge. The response was nearly instant. How is the Homeassistant integration doing it so much faster? I went to your solution just to make things simpler.

veonua commented 1 year ago

How is the Homeassistant integration doing it so much faster?

... The preferred approach is to subscribe to Home Assistant Cloud (Nabu Casa) and the integration will configure and use a cloudhook automatically. ... 6.50 USD per month and the annual subscription 65 USD, plus your local sales tax. https://www.home-assistant.io/integrations/smartthings/#webhook

65 USD per year makes the integration much faster.

iklein99 commented 1 year ago

I really don't know that architecture so I couldn't say. Samsung has a web hook capability that I looked into a while ago, but it would require each user to set up a domain name and certificate as well as configure port forwarding and perhaps other things on their home network for this to work. This would allow ST to send events inbound rather than polling which is what this plugin does. I thought about creating a service but that would start costing $$ and I would have to charge for the use of the plugin to pay for the service. Didn't want yo go through all of that. May look to do that in the future.

cirrusflyer commented 1 year ago

I wasn't paying for any Homeassistant feature, and it was still faster. But no worries. It still works, is free, and a nice plugin. Thanks for the hard work making it happen.

Correction - I wasn't paying for Nabu Casa, but my HA was accessible from the outside and had a cert via Cloudflare, so that's why it was faster. If all it takes is for my Homebridge to be publicly accessible in the same way, I'd be happy to do this. So if your plugin could do the same thing as what HA is doing, why not?

iklein99 commented 1 year ago

Home Assistant supports the web hook capability. You either have to subscribe to a service for that or do a bunch of work on your own to allow for an inbound web hook call from SmartThings.

In order to do that, you have to have a domain name and certificate. A lot for people to set up generally.

On Oct 28, 2022, at 3:37 AM, Andrew Me @.***> wrote:

How is the Homeassistant integration doing it so much faster?

... The preferred approach is to subscribe to Home Assistant Cloud (Nabu Casa) and the integration will configure and use a cloudhook automatically. ... 6.50 USD per month and the annual subscription 65 USD, plus your local sales tax. https://www.home-assistant.io/integrations/smartthings/#webhook https://www.home-assistant.io/integrations/smartthings/#webhook 65 USD per year makes the integration much faster.

— Reply to this email directly, view it on GitHub https://github.com/iklein99/homebridge-smartthings/issues/64#issuecomment-1294598116, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABG55EVTGGLKDDEKXGXQ5ADWFN7CVANCNFSM6AAAAAARQOTNCY. You are receiving this because you commented.

cirrusflyer commented 1 year ago

It took me 15 minutes to setup HA in Docker, and I'm using Cloudflare tunnels so the internal proxy and cert is taken care of. It was easy. I wouldn't call it a bunch of work. For those using Homebridge, we already know more about these kinds of things than average Joe.

iklein99 commented 1 year ago

I hear you, but I don’t agree that everyone is as savvy and I’m not willing to handle support questions from everyone that hasn’t done that before.

The best approach would be to handle via a centralized service.

On Oct 28, 2022, at 10:05 AM, cirrusflyer @.***> wrote:

It took me 15 minutes to setup HA in Docker, and I'm using Cloudflare tunnels so the internal proxy and cert is taken care of. It was easy. I wouldn't call it a bunch of work. For those using Homebridge, we already know more about these kinds of things than average Joe.

— Reply to this email directly, view it on GitHub https://github.com/iklein99/homebridge-smartthings/issues/64#issuecomment-1295042471, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABG55EQQJ4YEIA6LWUCB54LWFPMRFANCNFSM6AAAAAARQOTNCY. You are receiving this because you commented.

iklein99 commented 1 year ago

I'm closing this as it is working as designed. I will add an issue as an enhancement to use the web hook (subscription) api for real-time updates. Have no idea if/when I will be adding that.