Quand je démarre mon service, tout va bien. Le premier poll
récupere les valeur que j’attends, etc.
Quand je change la couleur de l’ampoule, mon service recoit bien les nouvelles valeurs de l’ampoule mais c’est gladys.event.emit
qui envoi ca:
2019-11-17T20:06:06+0100 <debug> gateway.forwardWebsockets.js:21 (Gateway.forwardWebsockets) Unable to forward websocket to Gladys Gateway
2019-11-17T20:06:06+0100 <debug> gateway.forwardWebsockets.js:22 (Gateway.forwardWebsockets) Error: Not connected to socket, cannot send message
at GladysGatewayJs.sendMessageAllUsers (/home/renaiku/repo/Gladys/server/node_modules/@gladysassistant/gladys-gateway-js/index.js:848:13)
at GladysGatewayJs.newEventInstance (/home/renaiku/repo/Gladys/server/node_modules/@gladysassistant/gladys-gateway-js/index.js:878:17)
at Gateway.forwardWebsockets (/home/renaiku/repo/Gladys/server/lib/gateway/gateway.forwardWebsockets.js:18:38)
at EventEmitter.<anonymous> (/home/renaiku/repo/Gladys/server/utils/functionsWrapper.js:13:13)
at EventEmitter.emit (events.js:194:15)
at Event.emit (/home/renaiku/repo/Gladys/server/lib/event/index.js:8:16)
at db.sequelize.transaction (/home/renaiku/repo/Gladys/server/lib/device/device.saveState.js:54:23)
2019-11-17T20:06:06+0100 <debug> gateway.forwardWebsockets.js:13 (Gateway.forwardWebsockets) Gateway : Forward websocket message : device.new-state
Le code qui produit ça (après avoir changé la valeur. La premiere récuperation du premier poll ne declenche pas d’erreur):
// COLOR
const colorFeature = getDeviceFeature(device, DEVICE_FEATURE_CATEGORIES.LIGHT, DEVICE_FEATURE_TYPES.LIGHT.COLOR);
const lastValue = colorFeature ? colorFeature.last_value : null;
const currentColorState = convert.rgb.hex([response.color.red, response.color.green, response.color.blue]);
const intColor = parseInt(`0x${currentColorState}`);
console.debug('intColor: ' + intColor);
console.debug('lastValue: ' + lastValue);
console.debug('currentColorState: ' + currentColorState + ":" + parseInt(`0x${currentColorState}`) + ":" + convert.hex.keyword(currentColorState));
if (colorFeature && lastValue !== intColor) {
this.gladys.event.emit(EVENTS.DEVICE.NEW_STATE, {
device_feature_external_id: `magic-devices:${macAdress}:${DEVICE_FEATURE_TYPES.LIGHT.COLOR}`,
state: intColor,
});
} else {
logger.debug('COLOR FEATURE HAS THE SAME VALUE THAN BEFORE: ' + currentColorState);
}
EDIT:
Pour info voici les console.debug que l’on voit dans la portion de code avant que je change de valeur (premier poll, et les suivant tant que je ne change pas la couleur de l’ampoule depuis mon smartphone) et après que je change la valeur (et que l’erreur s’affiche a chaque poll ensuite).
intColor: 16729645
lastValue: 16729645
currentColorState: FF462D:16729645:tomato
intColor: 3887359
lastValue: 16729645
currentColorState: 3B50FF:3887359:royalblue