Git Product home page Git Product logo

Comments (6)

devvthedev avatar devvthedev commented on June 8, 2024 1

Thanks @dgreif makes sense :)

If anyone wants to monitor alarm modes for their project hopefully this will be useful :)

if (locations.length) {
        const myHome = locations[1]

        myHome.onDeviceDataUpdate.subscribe(({mode}) => {
            if (mode as AlarmMode) {
                switch (mode as AlarmMode) {
                    case 'all':
                        console.log("away")
                        break;
                    case 'some':
                        console.log("home")
                        break;
                    case 'none':
                        console.log("disarmed")
                        break
                    default:
                        console.log("unknown")
                        break;
                }
            }
        });

    }

from ring.

devvthedev avatar devvthedev commented on June 8, 2024

Sorry!
As soon as I opened the enhancement I find that on Location you can have onDeviceDataUpdate so perhaps this is what I need!
Will update issue if this works out !

from ring.

devvthedev avatar devvthedev commented on June 8, 2024

I've written this to subscribe to LocationMode events and console.log(newMode) is never hit again after changing the alarm status from the ring app or keypad.

const myHome = locations[1]

        console.log(myHome.name)

        myHome.onLocationMode.subscribe((newMode) => {
            console.log(newMode)
        });

Any ideas?

from ring.

devvthedev avatar devvthedev commented on June 8, 2024

I've found the following which may help me

https://github.com/daneedk/com.amazon.ring/blob/4fca9947da608f2fe0b8e4f5dc8016d2d8bec4f8/lib/Api.js#L133

from ring.

devvthedev avatar devvthedev commented on June 8, 2024

Settled on this but I'm new to typescript!

myHome.onDeviceDataUpdate.subscribe(({mode}) => {
            if (mode as AlarmMode) {
                console.log(mode)
            }
        });

Wondering why mode encompasses both AlarmMode and ThermostatMode.

Is it nicer to make them separate in the API? Or is there something better I can do in my code?

Thanks! And sorry for all the comments on this thread!

from ring.

dgreif avatar dgreif commented on June 8, 2024

I do think onDeviceDataUpdate is the best option for you to use. Keep in mind this is a fairly generic observable which emits data that matched the RingDeviceData interface. Since this is a generic type, mode can be for an alarm security panel or a thermostat, which is why you get both of those mode types. This interface is blindly passing along the data from Ring, so there isn't any other more specific types available at the momemnt.

from ring.

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.