olofbokedal / homebridge-clap-sensor

Clap sensor for HomeKit via Homebridge.
1 stars 1 forks source link

Can't get it to work #2

Open WendelFelius opened 5 years ago

WendelFelius commented 5 years ago

Hi @olofbokedal,

I'm having trouble getting this plugin to work.

I've bought a microphone which works (I've tested it via onlinemictest.com), started by installing Sox (sudo apt-get install sox), followed by installing homebridge-clap-sensor (npm install -g homebridge-clap-sensor), added the clapsensor-accessory to my HomeBridge config.json file and set it up like this: { "accessory": "ClapSensor", "name": "Klapsensor", "numberOfClaps": 1, "clapInterval": 2000, "resetAfter": 5000, "clapDetectorConfig": { "AUDIO_SOURCE": "hw:1,0", "CLAP_AMPLITUDE_THRESHOLD": 0.7, "CLAP_ENERGY_THRESHOLD": 0.3 } }.

It won't work. Can you help me please? Maybe I missed something important?

olofbokedal commented 5 years ago

Hi! Thanks for trying this out.

I've only got it working with the built-in microphone in my MacBook. Also tested with another mic in a Raspberry Pi but couldn't get that one to work. So it's not unexpected, this plugin hasn't just been used nor tested enough.

Also note that the actual detection is handled by https://github.com/tom-s/clap-detector, so this plugin is merely a bridge between clap-detector and Homebridge. Without any deeper investigation I'd say its 50/50 whether the problem lies in homebridge-clap-sensor or clap-detector. Feel free to test clap-detector isolated, if you have the possibility.

dnicolson commented 1 year ago

There are two issues here for a Raspberry Pi:

Because the tom-s/clap-detector dependency uses app-root-path to get the directory to write the audio file to, the homebridge user doesn't have permission to write to /usr/lib/node_modules/homebridge/ which is owned by the root user.

A crude fix could be to change the directory permissions to allow the file to be written:

sudo chmod 0777 /usr/lib/node_modules/homebridge