Bon et bien voilà ! La fonction est exposée
Voilà des premiers logs :
2020-05-12T16:55:35+0200 <debug> scene.executeSingleAction.js:15 (SceneManager.executeSingleAction) Executing action of type device.set-value
2020-05-12T16:55:35+0200 <debug> device.setValue.js:15 (ArduinoManager.setValue) arduino: Changing value !! New value => 0
2020-05-12T16:55:35+0200 <debug> device.setValue.js:16 (ArduinoManager.setValue) { id: '9679f014-f5df-45aa-ad05-f0405f90038f',
service_id: '683503cf-c265-480d-a410-6dede6301116',
room_id: 'e3f0189d-e0a9-4c50-8089-d0bd5ea87301',
name: 'test',
selector: 'test',
model: null,
external_id: '852d2ed6-3afb-46f2-b879-8cf3bcb50189',
should_poll: false,
poll_frequency: null,
createdAt: 2020-05-12T10:06:44.351Z,
updatedAt: 2020-05-12T10:06:44.351Z,
features:
[ { id: '88bd694c-4748-4ce6-8afc-c0aeaed034c7',
device_id: '9679f014-f5df-45aa-ad05-f0405f90038f',
name: 'test',
selector: 'test',
external_id: '852d2ed6-3afb-46f2-b879-8cf3bcb50189',
category: 'switch',
type: 'binary',
read_only: false,
keep_history: false,
has_feedback: false,
unit: null,
min: 0,
max: 1,
last_value: 1,
last_value_string: null,
last_value_changed: 2020-05-12T14:54:59.415Z,
createdAt: 2020-05-12T10:06:44.410Z,
updatedAt: 2020-05-12T14:52:19.804Z } ],
params:
[ { id: '9f8a3be3-214a-4010-a44d-7bf36c421504',
device_id: '9679f014-f5df-45aa-ad05-f0405f90038f',
name: 'DATA_PIN',
value: '2',
createdAt: 2020-05-12T10:06:44.429Z,
updatedAt: 2020-05-12T10:06:44.429Z },
{ id: '78d63e83-2d83-4c5c-9f1f-d70bedc8e648',
device_id: '9679f014-f5df-45aa-ad05-f0405f90038f',
name: 'FUNCTION',
value: 'emit_433',
createdAt: 2020-05-12T10:06:44.430Z,
updatedAt: 2020-05-12T10:06:44.430Z },
{ id: '1089f07e-76a0-41b3-a4ce-02c8b7958ebc',
device_id: '9679f014-f5df-45aa-ad05-f0405f90038f',
name: 'ARDUINO_LINKED',
value: 'arduino-1',
createdAt: 2020-05-12T10:06:44.432Z,
updatedAt: 2020-05-12T10:06:44.432Z },
{ id: '29cafc77-660b-46e7-a8b4-cfcdf8325d5a',
device_id: '9679f014-f5df-45aa-ad05-f0405f90038f',
name: 'CODE',
value: '0',
createdAt: 2020-05-12T10:06:44.433Z,
updatedAt: 2020-05-12T10:06:44.433Z },
{ id: '6af71eca-ca23-451e-8536-35892b362d72',
device_id: '9679f014-f5df-45aa-ad05-f0405f90038f',
name: 'CODE_ON',
value: '0',
createdAt: 2020-05-12T10:06:44.434Z,
updatedAt: 2020-05-12T10:06:44.434Z },
{ id: 'd14269d8-03b8-41f9-aab8-2fc586c156b1',
device_id: '9679f014-f5df-45aa-ad05-f0405f90038f',
name: 'CODE_OFF',
value: '0',
createdAt: 2020-05-12T10:06:44.436Z,
updatedAt: 2020-05-12T10:06:44.436Z },
{ id: '94258157-bc83-427a-8684-fe6e294ffabd',
device_id: '9679f014-f5df-45aa-ad05-f0405f90038f',
name: 'BIT_LENGTH',
value: '24',
createdAt: 2020-05-12T10:06:44.437Z,
updatedAt: 2020-05-12T10:06:44.437Z } ],
room:
{ id: 'e3f0189d-e0a9-4c50-8089-d0bd5ea87301',
house_id: '9077ff85-438f-4a76-9493-caeb0650da15',
name: 'Salon',
selector: 'salon',
createdAt: 2020-05-11T02:20:24.506Z,
updatedAt: 2020-05-11T02:20:24.506Z },
service:
{ id: '683503cf-c265-480d-a410-6dede6301116',
pod_id: null,
name: 'arduino',
selector: 'arduino',
version: '0.1.0',
enabled: true,
has_message_feature: false,
createdAt: 2020-05-11T02:19:03.662Z,
updatedAt: 2020-05-11T02:19:03.662Z } }
2020-05-12T16:55:35+0200 <debug> device.setValue.js:17 (ArduinoManager.setValue) { id: '88bd694c-4748-4ce6-8afc-c0aeaed034c7',
device_id: '9679f014-f5df-45aa-ad05-f0405f90038f',
name: 'test',
selector: 'test',
external_id: '852d2ed6-3afb-46f2-b879-8cf3bcb50189',
category: 'switch',
type: 'binary',
read_only: false,
keep_history: false,
has_feedback: false,
unit: null,
min: 0,
max: 1,
last_value: 1,
last_value_string: null,
last_value_changed: 2020-05-12T14:54:59.415Z,
createdAt: 2020-05-12T10:06:44.410Z,
updatedAt: 2020-05-12T14:52:19.804Z }
2020-05-12T16:55:35+0200 <debug> device.saveState.js:16 (DeviceManager.saveState) device.saveState of deviceFeature test
2020-05-12T16:55:35+0200 <debug> gateway.forwardWebsockets.js:14 (Gateway.forwardWebsockets) Gateway: not connected. Prevent forwarding event.
2020-05-12T16:55:35+0200 <debug> scene.checkTrigger.js:12 (SceneManager.checkTrigger) Trigger: new event checkTrigger "device.new-state"
Dans mon setValue, je récupère donc le path de l’Arduino, je crée le JSON, et j’appelle la fonction send. Je suis pas loin d’avoir fini tout ça, et une fois qu’on y sera, la partie « émission » sera « finie ». Plus qu’à optimiser, et m’occuper de la partie « réception »
Pour info, comme on s’est mit d’accord, voilà le standard de JSON avec lequel je suis parti :
{
"function": "emit_433",
"parameters": {
"code": "4464676",
"bit_length": "24",
"data_pin": "4"
}
}
{
"function": "emit_433_chacon",
"parameters": {
"code": "1536116369",
"data_pin": "4"
}
}
{
"function": "emit_ir",
"parameters": {
"code": "0xF720DF",
"data_pin": "3"
}
}