homebridge-script2 icon indicating copy to clipboard operation
homebridge-script2 copied to clipboard

State polling interval/manual refresh

Open moshed opened this issue 5 years ago • 7 comments

is there a way to manually initiate a state poll or set the interval? Im working on a set of scripts to set the speaker for my Spotify music and the state refreshes reliably every time I close and reopen the home app, but doesn't refresh in any other instance.

moshed avatar Jan 06 '21 17:01 moshed

I've stopped using this plugin myself so have not fully tested this pull request. Though it seems to have worked for others. https://github.com/pponce/homebridge-script2/pull/15 If you use filestate the plugin should be checking for the existence of the file in order to set homekit state. And it should update homekit right away. So by manipulating the existence of the file you should get immediate updates in homekit. Would this work for you?

pponce avatar Jan 06 '21 18:01 pponce

it certainly is instant which is great, however im trying to wrap my head around how to carry out my intended workflow.

previously HomeKit would occasionally run my script which checked which speaker was active and turn that on even if I had chosen my speaker outside of HomeKit. currently, HomeKit only checks when I activate the speaker through homekit so if I choose a speaker by any other method nothing trips HomeKit to activate

I know you said you stopped developing this plugin so I dont want to bother you with my rambling, just thinking out loud!

thanks for all your hard work!

moshed avatar Jan 07 '21 06:01 moshed

Can you run your script external to homebridge to check state and delete/create the filestate file on a schedule, like every 10 seconds? Alternatively: In theory if an external method is used to turn on or off a speaker if that external method also added or deleted the state file i think homekit would then pick up the state change.

pponce avatar Jan 09 '21 05:01 pponce

hmm that's not a bad idea! I can just run a script on my pi to constantly check for these files... although I have too migrate the Spotify script over to the pi now... hmmm

thanks you've been a big help!

moshed avatar Jan 11 '21 19:01 moshed

Hope it works. Before doing a bunch of work. Can you try deleting the filestate file manually and adding it back to make sure HomeKit does indeed get pushed the state change. I never tested the PR update that added this check for filestate. So might be worth a check.

pponce avatar Jan 11 '21 19:01 pponce

I think I did that when I was messing around with it a few nights ago. I will do it again before I do all the work though. smart idea!

moshed avatar Jan 12 '21 04:01 moshed

it works! great! do you have any plans to work on this in the future would love these to be displayed as a speaker

moshed avatar Jan 12 '21 06:01 moshed