Closed klein0r closed 1 year ago
Yes, I guess the method was added on demand a long time ago and was only introduced for foreign objects, like some other not that common methods.
The problem I see is that we need to update all adapters and release new versions with the next controller Dep which use this atm (to get foreign stuff, own could be detected and handled), because breaking change.. no clue how many adapters are affected. @Apollon77 could grep, but maybe it would be a more realistic solution to document this behavior in docs + typings.
Seems 8 adapters ...
ioBroker.cameras/main.js: return adapter.setBinaryStateAsync(adapter.namespace + '.cameras.' + cam.name, Buffer.from(_imageData.body));
ioBroker.phantomjs/main.js: adapter.setBinaryState(adapter.namespace + '.pictures.' + fileName, data, function (err) {
ioBroker.ring/ring.js: if (snapshot) await adapter.setBinaryStateAsync(stateId, snapshot.image);
ioBroker.ring/ring.js: if (livestream) await adapter.setBinaryStateAsync(stateId, livestream.video);
ioBroker.sonos/main.js: adapter.setBinaryState(id, data, err => {
ioBroker.sonos/main.js: adapter.setBinaryState(stateName, fileData, () =>
ioBroker.sonos/main.js: adapter.setBinaryState(stateName, fileData, () =>
ioBroker.admin/lib/socket.js: socket.on('setBinaryState', function (id, base64, callback) {
ioBroker.admin/lib/socket.js: adapter.log.warn('[setBinaryState] Cannot convert base64 data: ' + e);
ioBroker.admin/lib/socket.js: adapter.setBinaryState(id, data, (err, ...args) =>
ioBroker.admin/lib/socket.js: adapter.log.warn('[setBinaryState] Invalid callback');
ioBroker.chromecast/lib/chromecastDevice.js: adapter.setBinaryState(exported_file_state, fs.readFileSync(url2play), err => {
ioBroker.javascript/lib/sandbox.js: const setStateFunc = isBinary ? adapter.setBinaryState.bind(adapter) : adapter.setForeignState.bind(adapter);
ioBroker.javascript/lib/sandbox.js: result.setBinaryState = function () {
ioBroker.javascript/lib/sandbox.js: result.setBinaryState = function (state, isAck, callback) {
ioBroker.javascript/lib/sandbox.js: result.setBinaryStateAsync(state, isAck).then(() => {
ioBroker.javascript/lib/sandbox.js: result.setBinaryStateAsync = async function (state, isAck) {
ioBroker.javascript/lib/sandbox.js: await adapter.setBinaryStateAsync(this[i], state);
ioBroker.javascript/lib/sandbox.js: setBinaryState: function (id, state, callback) {
ioBroker.javascript/lib/sandbox.js: 'setBinaryState',
ioBroker.sayit/lib/speech2device.js: adapter.setBinaryState(`${adapter.namespace}.tts.${options.outFileExt}`, fileData, callback);
ioBroker.javascript/lib/sandbox.js
Yeah this is going to break user scripts. Not sure how many are using this, but I'd expect at least some.
Ok, but here it is simple ... we can leave the name as is in Javascrit sandbox and just use the "foreign" name regads adapter class ... we do not have "foreign" differentiation in Javascript-scripts
TODOs:
Related issues:
If I call
this.setBinaryState('myId')
I receiveI have to use
this.setBinaryState(this.namespace + '.myId')
Why?
setForeignBinaryState
if it behaves like this or_fixId
should be called inside the functionhttps://github.com/ioBroker/ioBroker.js-controller/blob/adbf47e986cc9568187ab6953df3d37f2b5c6e41/packages/adapter/lib/adapter/adapter.js#L6583