NRCHKB / node-red-contrib-homekit-bridged

Node-RED Contribution - HomeKit Bridged : Node-RED nodes to simulate Apple HomeKit devices.
https://nrchkb.github.io
MIT License
414 stars 51 forks source link

Output Home.app refresh event #392

Closed MyOzCam closed 2 months ago

MyOzCam commented 3 years ago

Can we make a new output to fire whenever a HomeKit controller request the current value of the characteristic?

It could be necessary when the HomeKit node is used to control a TV which is based on webService API. Currently I am triggering a query to the TV periodically (say 1 min) to update the latest status of TV to Homekit node. So, currently status displaying on home.app may not be real time. If we can have a 'get' event output, we can fire an trigger of query to update the latest status in almost realtime.

Shaquu commented 3 years ago

So basically you would like to hook into nrchkb/HapNodeJS internals? I don't see a problem, actually feature which will allow that is planned (plugin system).

crxporter commented 3 years ago

I think the get event is called when the home app opens up and "refreshes" the item state? If I understand, basically you want to poll another api in nodered whenever someone opens up the home app, right?

MyOzCam commented 3 years ago

Yes. I believe “get” event is there for this purpose.

Shaquu commented 3 years ago

image Second output will contain msg.hap.event

Shaquu commented 3 years ago

image image

Shaquu commented 3 years ago

Together with NRCHKB 2.0.0 onSet and onChange will be merged into unified output called events It will output data for all event types defined below:

Until then node service2 might be released as experimental feature.

Node output will look like:

type HAPServiceNodeEvent = {name: CharacteristicEventTypes, context?: any}

type HAPServiceNodeOutput = {
    payload: { [key: string]: any }
    hap: {
        oldValue?: any
        newValue?: any
        context?: any
        event: HAPServiceNodeEvent
        session?: {
            sessionID?: SessionIdentifier,
            username?: HAPUsername,
            remoteAddress?: string,
            localAddress?: string,
            httpPort?: number,
        }
    }
    name?: string
    topic: string
}
crxporter commented 3 years ago

Anything with ? is optional and anything without will always be defined? It's looking good!

All of these messages are from one single output, correct?

Shaquu commented 3 years ago

Indeed,? means that undefined is allowed so value can be empty :)

crxporter commented 3 years ago

So a switch node watching for

msg.hap.event == "onSet"

we would expect to see the same output as current first output?

crxporter commented 2 years ago

This is available now in "experimental" using Service 2 node!

@Shaquu can you provide or point us to some quick nodes on how to enable experimental?

Shaquu commented 2 years ago

@crxporter here it is described how to enable experimental mode https://nrchkb.github.io/wiki/discover-more/experimental/#getting-started

ralphwetzel commented 2 years ago

What's the schedule to move this into the standard ... perhaps (initially) as an alternative node?

Shaquu commented 2 months ago

@ralphwetzel no schedule :) Sorry, doing my best. If it ever reaches stable, I will post a huge banner on a website somewhere!