sinricpro / nodejs-sdk

Nodejs library for https://sinric.pro
11 stars 7 forks source link

ENODEV: no such device, write #48

Closed AlarmeOrphee5 closed 9 months ago

AlarmeOrphee5 commented 9 months ago

Hello guys,

I control a GPIO which is connected to a relay. It works perfectly for the first hour, and then if I want to activate it, Sinric tells me that the device is not connected and I receive this log on rpi.

log on the first hour :

<< {"header":{"payloadVersion":2,"signatureVersion":1},"payload":{"action":"setPowerState","clientId":"alexa-skill","createdAt":1700337625,"deviceId":"xxx","replyToken":"a4cd1c46-2e17-411d-9b9a-90c629ce3555","type":"request","value":{"state":"Off"}},"signature":{"HMAC":"DH6JxakW2JCTHEaO7XEKjhEg5ttwuQmLYslc7R7y2+0="}}

{"header":{"payloadVersion":2,"signatureVersion":1},"payload":{"action":"setPowerState","clientId":"alexa-skill","createdAt":1700337625,"deviceId":"xxx","message":"OK","replyToken":"a4cd1c46-2e17-411d-9b9a-90c629ce3555","success":true,"type":"response","value":{"state":"Off"}},"signature":{"HMAC":"KVo47zETJ6LJ+RtXTpPjEMpB5U0xhU6z0rmCvDzp6IA="}}

log after 1 hour :

<< {"header":{"payloadVersion":2,"signatureVersion":1},"payload":{"action":"setPowerState","clientId":"alexa-skill","createdAt":1700395253,"deviceId":"xx","replyToken":"0be6ce43-cedf-4fc9-8b7e-81ccfffb88c9","type":"request","value":{"state":"On"}},"signature":{"HMAC":"fFOS6VeyTXx4jGI7ISQSACJm69iJILd9xEHJ4TNX+k8="}}

ENODEV: no such device, write <----- _ don't understaind this line :(

undefined

From what I understand Sinric communicates with my RPI but does not recover any data. I specify that no action happens to my light which does not change state.

the code from my RPI :

`process.env.SR_DEBUG = '1'; // Enable debug logs
const {
  SinricPro, startSinricPro, raiseEvent, eventNames,
} = require('sinricpro'); // require('../../index');

const Gpio = require('onoff').Gpio; //include onoff to interact with the GPIO
const LED = new Gpio(23, 'out'); //use GPIO pin 23, and specify that it is output

const APPKEY = 'xxx';
const APPSECRET = 'xxx';
const device1 = 'xxx;
const deviceIds = [device1];

const setPowerState = async (deviceid, data) => {

console.log('\n');

  console.log(deviceid, data);
  switch (data) { //I sort the input, and act according to the input "ON" and "OFF"
  case 'on':
  case 'On':
    console.log('\nON note\n');
    LED.writeSync(1); //set pin state to 1 (turn LED on)
    break;
  case 'off':
  case 'Off':
    console.log('\nOFF note\n');
    LED.writeSync(0); //set pin state to 0 (turn LED off)
    break;
  default:
    console.log(`\ndefaut survenu\n`);
}
  return true;
};

const sinricpro = new SinricPro(APPKEY, deviceIds, APPSECRET, true);
const callbacks = { setPowerState };

startSinricPro(sinricpro, callbacks);

Do you have any idea why it disconnects after an hour? Thanks a lot :)

kakopappa commented 9 months ago

I think

ENODEV: no such device, write

Error message is related to GPIO library.

have you tried the empty sketch running over 1 hour?

AlarmeOrphee5 commented 9 months ago

Ho it's my GPIO library... Ok I will try to changes it for testing. Thanks you :)