GithubHelp home page GithubHelp logo

iobroker / iobroker.javascript Goto Github PK

View Code? Open in Web Editor NEW
320.0 30.0 118.0 231.39 MB

Script engine for JavaScript and Blockly

License: MIT License

JavaScript 99.31% HTML 0.38% CSS 0.02% TypeScript 0.02% SCSS 0.26%
iobroker smarthome home-automation script-engine blockly javascript

iobroker.javascript's Introduction

Logo

Javascript Script Engine

Number of Installations Number of Installations NPM version

Test and Release Translation status Downloads This adapter uses Sentry libraries to automatically report exceptions and code errors to the developers. For more details and for information how to disable the error reporting see Sentry-Plugin Documentation! Sentry reporting is used starting with js-controller 3.0.

Executes Javascript, Typescript Scripts.

Documentation

Forbidden directories for Script Filesystem Mirroring

The Script Filesystem Mirroring will store all Source Files of the Scripts in your Filesystem to allow you to edit the Files in your favourite Script editor beside the Web-Editor. All changes are synced in both directions.

When enabling the Script Filesystem mirroring, please make sure to create a dedicated new directory and do not use an existing directory with other content. Please also make sure that no other script or process changes files in the provided directory to prevent access issues. Any location needs to be writable by the "iobroker" user!

Since v5.5.0 of the JavaScript adapter the following locations (relative to the ioBroker Base directory, usually /opt/iobroker) are not allowed to be used:

  • The ioBroker base directory itself and any path above!
  • ./iobroker-data itself, custom subdirectory (choose a name that do not overlap with any adapter!)
  • ./iobroker-data/backup-objects or the anything below
  • ./iobroker-data/files or the anything below
  • ./iobroker-data/backitup or the anything below
  • ./backups or the anything below
  • ./node_modules or the anything below
  • ./log or the anything below

Changelog

WORK IN PROGRESS

  • (PeterVoronov) Added toArray to result object of $-selector

8.1.1 (2024-05-03)

  • (klein0r) Updated Blockly/JS and Rules/JS image (as svg)

8.1.0 (2024-05-03)

  • (bluefox) Updated admin config to jsonConfig (dropped materialize)

8.0.3 (2024-04-11)

  • (klein0r) Updates dependencies (latest adapter-react-v5 framework)

8.0.2 (2024-04-08)

  • (klein0r) Forced downgrade of socket-client (object change issues)

8.0.1 (2024-04-08)

  • (klein0r) Fixed some missing translations (uk)
  • (klein0r) Raised supported ecmaVersion from es2021 to es2022 (node18)

License

The MIT License (MIT)

Copyright (c) 2014-2024 bluefox [email protected],

Copyright (c) 2014 hobbyquaker

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

iobroker.javascript's People

Contributors

agross avatar alcalzone avatar anzic23 avatar apollon77 avatar buzzy1337 avatar dependabot[bot] avatar dilesoft avatar dmtrsmkv avatar dutchmannl avatar foxriver76 avatar garfonso avatar germanbluefox avatar hobbyquaker avatar homoran avatar klein0r avatar ldittmar81 avatar mcm1957 avatar mfal avatar paul53 avatar petervoronov avatar rantanplan01 avatar slix185 avatar soef avatar thetagamma avatar thewhobox avatar twonky4 avatar unclesamswiss avatar vesler avatar winnyschuster avatar zalash333 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iobroker.javascript's Issues

Wunsch: Prüfung bei Instanzänderung, ob gespeichert wurde

Derzeit passiert es mir immer wieder, dass ich ein Skript anlege, die Engine ändere den Namen eintrage und mir dann einfällt, dass ich es in einer anderen Instanz anlegen will.

Wenn man nun ohne zu speichern die Instanz ändert, darf man alles die Schritte wieder von Vorne beginnen.

Hilfreich wäre, wenn eine Instanzänderung prüft, ob das Speichern schon durchgeführt wurde und wenn nicht, nachfragt.

[Problem] Problem when moving script groups

I'amnot sure if this issue is a issue of the javascript adapter or the admin adapter. Please move it if it is a admin issue.

When creating a new child group this is working fine. If i will move this new group to top level (choosing "no group" as parent group) then i will see this new goup in top level but it is still existing as a child group (it is existing twice).
This isn't just a browser cache issue. I have to remove the child group in group menu then to get a clean solution.

Tested with Admin 3.2.3 and Javascript 3.6.4
Browser: Firefox 58.0.2 (64-Bit)

Steps:
grafik

grafik

grafik

Version 3.6.0 [Blockly]

Bei der 3.6.0 kommt bei vielen Scripts die Meldung:
"Cannot extract Blockly code"
Warum es bei einigen klappt und bei den meisten nicht, kann ich nicht sagen.
Kann, bei denen wo es nicht klappt, keine Gemeinsamkeiten feststellen.

Mit der 3.5.1 ist dann alles wieder in Ordnung.

getObject(id, "rooms") liefert nicht die Raumnamen

Ich habe ein Objekt 'hm-rpc.0.NEQ0184905.1', welchem die Räume 'Wohnzimmer' und 'Erdgeschoss' zugewiesen sind:
image

Diese Räume möchte ich jetzt ermitteln. Prinzipiell sollte es auch auf dem untergeordneten Datenpunkt möglioch sein, es wird jedoch ein leeres Array zurückgeliefert:

var id = 'hm-rpc.0.NEQ0184905.1.LEVEL';
var raumobj = getObject(id, "rooms");
log(JSON.stringify(raumobj));

//Ergebnis:
//{"def":0,"type":"number","read":true,"write":true,"min":0,"max":100,"unit":"%","role":"level.dimmer","workingID":"WORKING","name":"K14_110_WZ_Licht_LED_Dimmer.LEVEL"},"native":{"CONTROL":"DIMMER.LEVEL","DEFAULT":0,"FLAGS":1,"ID":"LEVEL","MAX":1,"MIN":0,"OPERATIONS":7,"TAB_ORDER":0,"TYPE":"FLOAT","UNIT":"100%"},"_id":"hm-rpc.0.NEQ0184905.1.LEVEL","acl":{"object":1636,"state":1636,"owner":"system.user.admin","ownerGroup":"system.group.administrator"},"enumIds":[],"enumNames":[]}

Ich kann die Objekte auch einzeln durchprobieren, es kommt das selbe Ergebnis:

var dp = getObject("hm-rpc.0.NEQ0184905.1.LEVEL","rooms");
log ("Raum: " + dp.enumNames);
log ("RaumID: " + dp.enumIds);

var dp = getObject("hm-rpc.0.NEQ0184905.1","rooms");
log ("Raum: " + dp.enumNames);
log ("RaumID: " + dp.enumIds);

var dp = getObject("hm-rpc.0.NEQ0184905","rooms");
log ("Raum: " + dp.enumNames);
log ("RaumID: " + dp.enumIds);

Ergebnis:

23:14:07.292   [info]   javascript.0 script.js.common.Test: Raum:
23:14:07.292   [info]   javascript.0 script.js.common.Test: RaumID:
23:14:07.292   [info]   javascript.0 script.js.common.Test: Raum:
23:14:07.292   [info]   javascript.0 script.js.common.Test: RaumID:
23:14:07.292   [info]   javascript.0 script.js.common.Test: Raum:
23:14:07.292   [info]   javascript.0 script.js.common.Test: RaumID:

Was mache ich falsch?

[Problem] Javascript Instance Dropdown doesn't open sometimes

Description
When i try to switch Javascript Instances for Scripts which are part of a group then this doesn't work sometimes. It looks like that instance dropdown will open for a short moment and then close automatic again. This happen also if i try to do it multiple times. It's not possible to get instance dropdown open and choose an instance then.
When i close the group (tree) of this script one time and open it again then can change the instance without any problem.

Tested with Admin 3.2.3 and Javascript 3.6.4
Browser: Firefox 58.0.2 (64-Bit)

[Problem] Scriptname and Code will be remove when switching Instances

Same here. Not sure if it is related to Javascript or Admin Adapter. Please move this issue if required.

Problem:
When creating a new script (javascript), i fill in scriptname, put in my code. Then before i've saved this new script i will script javascript instance (because i use 0 for TEST and 1 for PRD).
When switching the instance, then scriptname will be set to default name "Skript1" and code was removed.

Tested in Admin 3.2.3 and Javascript Adapter 3.6.4

grafik

grafik

When testing the same in another ioBroker Installation with Admin 3.2.0 and Javascript Adapter 3.5.1 then the Instance Switch won't remove Scriptname or Coding.

Browser: Firefox 58.0.2 (64-Bit) for both Testscenarios.

getIdByName liefert zwei identische Werte

Seit Version 3.0.10 liefert getIdByName bei manchen Aktoren zwei mal den gleichen Wert in einem Array.

Testskript:
log(getIdByName("RL Arbeit"));

Log:
javascript.4 script.js.Test.Skript11: hm-rpc.0.LEQ1020140.1,hm-rpc.0.LEQ1020140

Blockly "Letzte Änderung" und "Zeitstempel" liefern gleiche Werte

Wenn man in dem Baustein "Wert von..." "Zeitstempel" bzw. "Letzte Änderung" auswählt wird die gleiche Zeit ausgegeben.
Dafür zwei Auswahlen bereitzustellen macht nicht viel Sinn.
"vorherige letzte Änderung" wäre besser.

Zumal, wenn man einen Datenpunkt nicht triggert, keine Möglichkeit besteht "vorherige letzte Änderung" abzufragen.

Sendto Objekt

Das Sendto Objekt lässt sich nicht ins Script hinein ziehen. Es verschwindet immer wieder

EDIT by BuZZy1337:
Duplicate of #46

Sendto-Blocks not selectable

Status:
iobroker installed on Raspberry Pi 3 with latest Jessie
node v6.11.2
iobroker Admin v. 2.0.7
Javascript/Blockly engine v. 3.4.0
Telegram v1.0.8
Email v1.0.2
Browsers tested: Firefox, Chrome, IE10

Issue:
Under "SendTo" only the telegram-block is visible, sometimes it will be be covered by the sidebar.
The block won't be highlighted with a yellow edge when mouse hovers over it, it is not drag&drop-able.

grafik

Behaviour for all other blocks is fine (highlight+drag+drop):
grafik

[Feature Request] Order in "Javascript Group Dropdown Field"

Description (related to Admin 3.2.3/Javascript 3.6.4)
I'd like to working with groups and different javascript instances for TEST and PRD.
Therefore i have groups were my PRD script are located and a have a group tree which is starting with _DEV and below i have the same groupname like in the PRD tree.

When i now want to move any script i have to use the group dropdown.
But in this group dropdown there is any other kind of order then in the group tree on the left side.

Example:
I have a group "Anwesenheit" which contains productive scripts and i have a group "Anwesenheit" in my "_DEV" group which contains presence scripts which are in development progress or testing.

When i have a look in the group dropdown i will see this two "Anwesenheit" groups one below the other. It is also no alphabetical order because this two group starting with "A" are in the middle of this dropdown.

grafik

Feature Request
Is it possible to use the same oder for groupname dropdown like for the group tree in script area?
In my example this means for a new dropdown order that my first group "Anwesenheit" will be at the top of this list (like in the left menu) and the second "Anwesenheit" group is below the "_DEV" group.
So it's easy to find out which group is the correct one without "try and error" method.

[Future] Support coffeescript v2 (requires NodeJS 6+)

Installing outputs the following warning:

npm WARN deprecated [email protected]: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)

However we cannot just switch the package name because https://github.com/alexgorbatchev/coffee-compiler also has the old module dependency.
Do you know if there's a possibility to tell NodeJS to actually load "coffeescript" when requiring "coffee-script"? If so, we could support CoffeeScript v2.

Of course we could just fork the coffee-compiler, change the dependency and use our fork - but I'm not sure if that's worth the effort.

Using \r\n in sendTo telegram

sendTo in Blockly replaces \r\n from parameter values with \\r\\n, which of course does not work as an line break in Telegram for example.

This
unbenannt

becomes this

sendTo("telegram.0", "send", {
   "text": 'Lorem ipsum\\r\\ndolor sit amet.'
});

Please make \r\n immune to rewrite.

Fehler: event.enumNames.indexOf is not a function, seit Version 3.4.1

Bezugnehmend auf diesen Forumthread: http://forum.iobroker.net/viewtopic.php?f=22&t=10843

Hier wie gewünscht ein neuer issue. Ich habe den Fehler dass mir der Log nach dem Update auf eine Version höher der 3.4.0 lauter Fehler im Log produziert. Für jeden "Datenpunkt/Gerät"

Hier ein Auszug:
2018-02-05 22:20:52.078 - �[31merror�[39m: javascript.0 message system.adapter.simple-api.0.memRss [object Object] event.enumNames.indexOf is not a function 2018-02-05 22:20:52.079 - �[31merror�[39m: javascript.0 TypeError: event.enumNames.indexOf is not a function at Array.<anonymous> (/opt/iobroker/node_modules/iobroker.javascript/lib/patternCompareFunctions.js:342:60) at patternMatching (/opt/iobroker/node_modules/iobroker.javascript/javascript.js:3283:36) at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/javascript.js:386:28) at Object.change (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:3190:37) at Socket.<anonymous> (/opt/iobroker/node_modules/iobroker.js-controller/lib/states/statesInMemClient.js:48:30) at Socket.Emitter.emit (/opt/iobroker/node_modules/socket.io-client/node_modules/component-emitter/index.js:133:20) at Socket.onevent (/opt/iobroker/node_modules/socket.io-client/lib/socket.js:270:10) at Socket.onpacket (/opt/iobroker/node_modules/socket.io-client/lib/socket.js:228:12) at Manager.<anonymous> (/opt/iobroker/node_modules/component-bind/index.js:21:15) at Manager.Emitter.emit (/opt/iobroker/node_modules/socket.io-client/node_modules/component-emitter/index.js:133:20) at Manager.ondecoded (/opt/iobroker/node_modules/socket.io-client/lib/manager.js:332:8) at Decoder.<anonymous> (/opt/iobroker/node_modules/component-bind/index.js:21:15) at Decoder.Emitter.emit (/opt/iobroker/node_modules/component-emitter/index.js:134:20) at Decoder.add (/opt/iobroker/node_modules/socket.io-parser/index.js:246:12) at Manager.ondata (/opt/iobroker/node_modules/socket.io-client/lib/manager.js:322:16) at Socket.<anonymous> (/opt/iobroker/node_modules/component-bind/index.js:21:15) at Socket.Emitter.emit (/opt/iobroker/node_modules/engine.io-client/node_modules/component-emitter/index.js:133:20) at Socket.onPacket (/opt/iobroker/node_modules/engine.io-client/lib/socket.js:451:14) at WS.<anonymous> (/opt/iobroker/node_modules/engine.io-client/lib/socket.js:268:10) at WS.Emitter.emit (/opt/iobroker/node_modules/engine.io-client/node_modules/component-emitter/index.js:133:20) at WS.Transport.onPacket (/opt/iobroker/node_modules/engine.io-client/lib/transport.js:145:8) at WS.Transport.onData (/opt/iobroker/node_modules/engine.io-client/lib/transport.js:137:8) at WebSocket.ws.onmessage (/opt/iobroker/node_modules/engine.io-client/lib/transports/websocket.js:146:10) at WebSocket.onMessage (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/WebSocket.js:442:14) at emitTwo (events.js:106:13) at WebSocket.emit (events.js:191:7) at Receiver.ontext (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/WebSocket.js:841:10) at /opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/Receiver.js:536:18 at Receiver.applyExtensions (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/Receiver.js:371:5) at /opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/Receiver.js:508:14 at Receiver.flush (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/Receiver.js:347:3) at Receiver.finish (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/Receiver.js:541:12) at Receiver.expectHandler (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/Receiver.js:499:31) at Receiver.add (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/Receiver.js:103:24) at Socket.realHandler (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/WebSocket.js:825:20) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at readableAddChunk (_stream_readable.js:176:18) at Socket.Readable.push (_stream_readable.js:134:10) at TCP.onread (net.js:547:20)
.................... usw..............................
2018-02-05 22:21:31.889 - �[31merror�[39m: javascript.0 message system.adapter.hm-rega.0.alive [object Object] event.enumNames.indexOf is not a function 2018-02-05 22:21:31.890 - �[31merror�[39m: javascript.0 TypeError: event.enumNames.indexOf is not a function at Array.<anonymous> (/opt/iobroker/node_modules/iobroker.javascript/lib/patternCompareFunctions.js:342:60) at patternMatching (/opt/iobroker/node_modules/iobroker.javascript/javascript.js:3283:36) at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/javascript.js:386:28) at Object.change (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:3190:37) at Socket.<anonymous> (/opt/iobroker/node_modules/iobroker.js-controller/lib/states/statesInMemClient.js:48:30) at Socket.Emitter.emit (/opt/iobroker/node_modules/socket.io-client/node_modules/component-emitter/index.js:133:20) at Socket.onevent (/opt/iobroker/node_modules/socket.io-client/lib/socket.js:270:10) at Socket.onpacket (/opt/iobroker/node_modules/socket.io-client/lib/socket.js:228:12) at Manager.<anonymous> (/opt/iobroker/node_modules/component-bind/index.js:21:15) at Manager.Emitter.emit (/opt/iobroker/node_modules/socket.io-client/node_modules/component-emitter/index.js:133:20) at Manager.ondecoded (/opt/iobroker/node_modules/socket.io-client/lib/manager.js:332:8) at Decoder.<anonymous> (/opt/iobroker/node_modules/component-bind/index.js:21:15) at Decoder.Emitter.emit (/opt/iobroker/node_modules/component-emitter/index.js:134:20) at Decoder.add (/opt/iobroker/node_modules/socket.io-parser/index.js:246:12) at Manager.ondata (/opt/iobroker/node_modules/socket.io-client/lib/manager.js:322:16) at Socket.<anonymous> (/opt/iobroker/node_modules/component-bind/index.js:21:15) at Socket.Emitter.emit (/opt/iobroker/node_modules/engine.io-client/node_modules/component-emitter/index.js:133:20) at Socket.onPacket (/opt/iobroker/node_modules/engine.io-client/lib/socket.js:451:14) at WS.<anonymous> (/opt/iobroker/node_modules/engine.io-client/lib/socket.js:268:10) at WS.Emitter.emit (/opt/iobroker/node_modules/engine.io-client/node_modules/component-emitter/index.js:133:20) at WS.Transport.onPacket (/opt/iobroker/node_modules/engine.io-client/lib/transport.js:145:8) at WS.Transport.onData (/opt/iobroker/node_modules/engine.io-client/lib/transport.js:137:8) at WebSocket.ws.onmessage (/opt/iobroker/node_modules/engine.io-client/lib/transports/websocket.js:146:10) at WebSocket.onMessage (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/WebSocket.js:442:14) at emitTwo (events.js:106:13) at WebSocket.emit (events.js:191:7) at Receiver.ontext (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/WebSocket.js:841:10) at /opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/Receiver.js:536:18 at Receiver.applyExtensions (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/Receiver.js:371:5) at /opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/Receiver.js:508:14 at Receiver.flush (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/Receiver.js:347:3) at Receiver.finish (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/Receiver.js:541:12) at Receiver.expectHandler (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/Receiver.js:499:31) at Receiver.add (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/Receiver.js:103:24) at Socket.realHandler (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/WebSocket.js:825:20) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at readableAddChunk (_stream_readable.js:176:18) at Socket.Readable.push (_stream_readable.js:134:10) at TCP.onread (net.js:547:20)
............................ usw. ...............................
2018-02-05 22:21:53.444 - �[31merror�[39m: javascript.0 message hm-rpc.0.OEQxxxxxxxx.4.VALVE_STATE [object Object] enumIds.indexOf is not a function 2018-02-05 22:21:53.445 - �[31merror�[39m: javascript.0 TypeError: enumIds.indexOf is not a function at getObjectEnumsSync (/opt/iobroker/node_modules/iobroker.javascript/javascript.js:3409:29) at getObjectEnumsSync (/opt/iobroker/node_modules/iobroker.javascript/javascript.js:3419:28) at EventObj.get (/opt/iobroker/node_modules/iobroker.javascript/javascript.js:186:17) at Array.<anonymous> (/opt/iobroker/node_modules/iobroker.javascript/lib/patternCompareFunctions.js:342:30) at patternMatching (/opt/iobroker/node_modules/iobroker.javascript/javascript.js:3283:36) at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/javascript.js:386:28) at Object.change (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:3190:37) at Socket.<anonymous> (/opt/iobroker/node_modules/iobroker.js-controller/lib/states/statesInMemClient.js:48:30) at Socket.Emitter.emit (/opt/iobroker/node_modules/socket.io-client/node_modules/component-emitter/index.js:133:20) at Socket.onevent (/opt/iobroker/node_modules/socket.io-client/lib/socket.js:270:10) at Socket.onpacket (/opt/iobroker/node_modules/socket.io-client/lib/socket.js:228:12) at Manager.<anonymous> (/opt/iobroker/node_modules/component-bind/index.js:21:15) at Manager.Emitter.emit (/opt/iobroker/node_modules/socket.io-client/node_modules/component-emitter/index.js:133:20) at Manager.ondecoded (/opt/iobroker/node_modules/socket.io-client/lib/manager.js:332:8) at Decoder.<anonymous> (/opt/iobroker/node_modules/component-bind/index.js:21:15) at Decoder.Emitter.emit (/opt/iobroker/node_modules/component-emitter/index.js:134:20) at Decoder.add (/opt/iobroker/node_modules/socket.io-parser/index.js:246:12) at Manager.ondata (/opt/iobroker/node_modules/socket.io-client/lib/manager.js:322:16) at Socket.<anonymous> (/opt/iobroker/node_modules/component-bind/index.js:21:15) at Socket.Emitter.emit (/opt/iobroker/node_modules/engine.io-client/node_modules/component-emitter/index.js:133:20) at Socket.onPacket (/opt/iobroker/node_modules/engine.io-client/lib/socket.js:451:14) at WS.<anonymous> (/opt/iobroker/node_modules/engine.io-client/lib/socket.js:268:10) at WS.Emitter.emit (/opt/iobroker/node_modules/engine.io-client/node_modules/component-emitter/index.js:133:20) at WS.Transport.onPacket (/opt/iobroker/node_modules/engine.io-client/lib/transport.js:145:8) at WS.Transport.onData (/opt/iobroker/node_modules/engine.io-client/lib/transport.js:137:8) at WebSocket.ws.onmessage (/opt/iobroker/node_modules/engine.io-client/lib/transports/websocket.js:146:10) at WebSocket.onMessage (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/WebSocket.js:442:14) at emitTwo (events.js:106:13) at WebSocket.emit (events.js:191:7) at Receiver.ontext (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/WebSocket.js:841:10) at /opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/Receiver.js:536:18 at Receiver.applyExtensions (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/Receiver.js:371:5) at /opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/Receiver.js:508:14 at Receiver.flush (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/Receiver.js:347:3) at Receiver.finish (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/Receiver.js:541:12) at Receiver.expectHandler (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/Receiver.js:499:31) at Receiver.add (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/Receiver.js:103:24) at Socket.realHandler (/opt/iobroker/node_modules/engine.io-client/node_modules/ws/lib/WebSocket.js:825:20) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at readableAddChunk (_stream_readable.js:176:18) at Socket.Readable.push (_stream_readable.js:134:10) at TCP.onread (net.js:547:20)

Gruß
Peoples

Unable to switch Instances with 3.5.0 adapter

see also: http://forum.iobroker.net/viewtopic.php?f=17&t=9467 (including video)

I was not able to switch between instances on 3.5.0. Switching back to 3.4.0 everything worked fine again. It would always directly switch back to instance0 and execute the script there.

Node v6.10.3
JavaScript Controller 1.2.3
ioBroker Admin 3.0.1
Script had Exec Command and Send to Object enabled.

I did not try to update to 3.5.0 again yet, if that issue only exists for me then it might have been a failed installation. Will see if I can check that again the next days.

Keinerlei Scriptaktivität mehr nach letztem Update

Hallo zusammen,
ich habe heute ein Update aller Adapter auf den letzten Stand gefahren.
Seitdem habe ich keinerlei Script-Aktivität mehr.

Beispiel Geofency:

on('geofency.0.Alex.Home.entry', function(dp) { log('I am here!'); setState('hm-rega.0.12389', toBoolean(dp.state.val)); // Pushover if (toBoolean(dp.state.val)) { sendTo("pushover", { message: 'A1', // mandatory - your text message title: 'SweetHome', // optional - your message's title, otherwise your app's name is used }); } else { sendTo("pushover", { message: 'A0', // mandatory - your text message title: 'SweetHome', // optional - your message's title, otherwise your app's name is used }); } });

-> löst nicht aus, egal, wie sich der Wert Entry ändert. Auch "I am here!", was ich zu Testzwecken eingefügt habe, wird nicht in den Log geschrieben.

on({id: 'hm-rega.0.1329', change: "ne"}, function (obj) { var value = obj.state.val; var oldValue = obj.oldState.val; sendTo("pushover", "send", { message: getState("hm-rega.0.1329").val, sound: "", title: 'Servicemeldung' }); });

Das ist ein per Blockly generiertes Skript, das Systemmeldungen der CCU automatisch an Pushover schicken soll. Auch hier: Egal, wie sich 1329 ändert: Keine Reaktion.

Bitte dringend um Abhilfe.
Danke.

getAstroDate() doesn't know 'night' and 'nightEnd' anymore?!?

Something has recently changed to the astro functions as the following script doesn't return valid times for "night" and "nightEnd" anymore:

var night = getAstroDate("night");
var nightEnd = getAstroDate("nightEnd");
log("night starts today at " + night.toLocaleTimeString());
log("night ends today at " + nightEnd.toLocaleTimeString());

Result is:

09:28:29.783	[info]	javascript.0 script.js.Licht.Lichtsteuerung: night starts today at Invalid Date
09:28:29.783	[info]	javascript.0 script.js.Licht.Lichtsteuerung: night ends today at Invalid Date

This is with the latest version of ioBroker.javascript (v3.3.8)

extra NPM-Module textarea dosen´t work

this message is in consol log

Uncaught TypeError: $(...).chips is not a function
    at list2chips (index_m.html?0:150)
    at load (index_m.html?0:133)
    at n.<anonymous> (adapter-settings.js:266)
    at n.onack (universalModuleDefinition:3)
    at n.onpacket (universalModuleDefinition:3)
    at n.<anonymous> (universalModuleDefinition:3)
    at n.emit (universalModuleDefinition:2)
    at n.ondecoded (universalModuleDefinition:1)
    at s.<anonymous> (universalModuleDefinition:3)
    at s.r.emit (universalModuleDefinition:1)

[AdminV3] Script Log empty

under Scripts in Admin log is everytime empty:
image

Used:
Admin 3.1.6
Javascript 3.6.1

This was working properly under Admin Version 2.x.

Unsubscribe funktioniert nicht, wenn Adapter auf "Nicht auf alle Zustände beim Start abonnieren" konfiguriert ist

Wenn der javascript Adapter auf "nicht auf alle Zustände beim Start abonnieren" konfiguriert ist, führt der Aufruf von unsubscribe() mit einer handler-Instanz zu einem TypeError.

Fehler aus Log:

at sandbox.unsubscribe (/opt/iobroker/node_modules/iobroker.javascript/javascript.js:1409:29)
at unsubscribePattern (/opt/iobroker/node_modules/iobroker.javascript/javascript.js:684:34)
TypeError: Cannot read property 'undefined' of undefined
uncaught exception: Cannot read property 'undefined' of undefined

Ist die obige Konfiguration nicht gesetzt, tritt der Fehler nicht auf.
Mit folgendem Test-Skript kann ich den Fehler zuverlässig reproduzieren:

createState("test1", false, true)
var sub = on("test1", function(obj) {
    unsubscribe(sub)
})

setStateDelayed("test1", true, 1000)

Ich verwende die Version 3.3.6 der js Engine.

Experten Button in Scripten

Sehr viele Neulinge speichern ihre Scripte unter "global".
Ist es möglich einen "Experten Button" einzurichten und den Ordner "global" nur anzuzeigen, wenn der "Experten Modus" aktiv ist?

Can not open script tab in admin

Why is this MSG object there?

MSG.catSystem = Blockly.Words['System'][systemLang];

I get a javascript error:

Uncaught ReferenceError: MSG is not defined
at tab.js:1777
at loadScripts (tab.js:1721)
at loadCustomBlockly (tab.js:1749)
at Scripts.init (tab.js:1776)
at tab.js:1769

And the scripts tab in admin doesn't opened.

If I add a var MSG = new Object(); before this line the scripts tab opened. But I don't if it is correct.

Can you please check this?

Filter

Hallo,

ich würde gerne Objekte anhand des Namens filtern - aber es klappt nicht. Versucht habe ich es z.B. wie folgt:
var fensterZustand= $('channel[name=Fenster, state.id=*.State]'); (da sind Sternchen vor/hinter "Fenster", die man leider nicht sieht)

Ich habe mehrere andere Möglichkeiten ausprobiert; hat aber alles nicht geklappt. Siehe auch Forum: http://forum.iobroker.net/viewtopic.php?p=56724#p56724

Too many warnings - state not set

I have an script where I looks for homematic states that have not been ACKnowledge yet so I can retry them.

I use $('channel[state.id=hm-rpc.0.*]').each() to get all states but then I get a lot of warnings for all objects that do not have states. For example: State "hm-rpc.0.FEQ0081419.4.PRESS_LONG" not found

Is there a way to avoid this warning? I get the log full of them.

Blocky for Telegram: setting user name field does not work

So if you want to send a message to a specific person instead of everyone on Telegram you will have to type the specific user to the username field in blocky, however that does not work.

  • First of for some reasonTelegram detects first name as username instead of the actual username its not reliable to use since its not unique.
  • Even if I enter the username as Telegram detects to the user name field in Blocky it does not do anything, no one will receive a message.
  • when switching blocky to written js it will work however from the 2nd or 3rd trial but not immediately.
  • if I change "user" in the code to "chatId" and use the chatId for the specific person, it works normally and without troubles.

I think its more reliable to use the chatId since its unique and detected properly by the Adapter unlike the username.

Thanks in advance!

nadir Problem

Wie schon im Forum angemeldet funktioniert die Astro-Funktion nadir nicht!

  1. Grund: Bei astroList und AstroListLow fehlt 'nadir' komplett, vielleicht aus dem Grund da es nicht funktioniert hat wegen der suncalc Probleme damit!

  2. Grund suncalc kalkuliert den nadir der leider immer in der Vergangenheit liegt da es indirekt einen Tag abzieht.

Lösung:
if (pattern == 'nadir')
date = new Date(date.getTime() + 1000 * 60 * 60 * 24);
var ts = mods.suncalc.getTimes(date, adapter.config.latitude, adapter.config.longitude)[pattern];

wenn nach nadir gefragt wird muss ein Tag dazugezählt werden damit nadie nicht in der Vergangenheit liegt und das nächste nadir zurückgegeben wird!

Diese 2 patches machten nadir verfügbar.

LG
Frank

schedule

Do't work by the hours task
schedule("* */1 * * *", function () {
var date = new Date();
var hour = date.getHours();
log("Время "+ hour);
});

schedule("* 0-23 * * *", function () {
log("Will be triggered every 1 hour!");
});

javascript-0 2015-08-02 13:37:00 info script.js.Script1: Время 13
javascript-0 2015-08-02 13:36:00 info script.js.Script1: Время 13
javascript-0 2015-08-02 13:35:00 info script.js.Script1: Время 13
javascript-0 2015-08-02 13:34:00 info script.js.Script1: Время 13
javascript-0 2015-08-02 13:33:00 info script.js.Script1: Время 13
javascript-0 2015-08-02 13:32:00 info script.js.Script1: Время 13
javascript-0 2015-08-02 13:31:00 info script.js.Script1: Время 13
javascript-0 2015-08-02 13:30:35 info script.js.Script1: registered 0 subscriptions and 1 schedule
javascript-0 2015-08-02 13:30:35 info Start javascript script.js.Script1

TypeScript-Unterstützung

Neben JavaScript und CoffeeScript sollte der Adapter IMO noch TypeScript unterstützen. Die nötigen Schritte wären:

  • Compiler einbinden => Dazu habe ich ein Paket geschrieben (https://www.npmjs.com/package/virtual-tsc), muss nur eingebunden werden
  • .d.ts-Datei für im Skript-Adapter verfügbare Funktionen schreiben
  • TypeScript als zusätzliche Engine verfügbar machen
  • Editor-Support (hier muss vermutlich noch etwas getan werden)

Was bedeuten diese Warnings über deprecated Variablen?

Hallo,

bekomme seit dem Update auf die neueste Version diese Warnungen:

javascript-0    25 10:08:03.424 warn    Wrong type of hm-rega.0.12391: "boolean". Please fix, while deprecated and will not work in next versions.
javascript-0    25 10:08:03.392 warn    Wrong type of hm-rega.0.12389: "string". Please fix, while deprecated and will not work in next versions.

Was bedeutet das?

Wunsch: compareTime sollte Astrobegriffe akzeptieren

Dafür müsste man ein paar Zeilen in der javascript.js hinzufügen. Hier mein aktueller benutzter code:

function compareAstroTime(startTime, endTime, operation, time) { var astroList = ["sunrise", "sunset", "sunriseEnd", "sunsetStart", "dawn", "dusk", "nauticalDawn", "nauticalDusk", "nightEnd", "night", "goldenHourEnd", "goldenHour"]; if (typeof startTime === 'string') { if (astroList.indexOf(startTime) !== -1) { startTime = getAstroDate(startTime); startTime = startTime.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit', hour12: false}); } } if (endTime && typeof endTime === 'string') { if (astroList.indexOf(endTime) !== -1) { endTime = getAstroDate(endTime); endTime = endTime.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit', hour12: false}); } } return compareTime(startTime, endTime, operation, time); }

Man sollte dann entsprechend auch Blocky und die Doku anpassen...

Zur Zeit bin ich noch dabei mich in die ganze Thematik einzuarbeiten und meine System umzustellen, aber wenn alles soweit ist, könnte ich dann bei der Weiterentwicklung helfen.

Grüße,
ldittmar

state.val

Die Erweiterung der Abfrage abhängig vom typeof state ist nicht ausreichend, da in den nächsten Zeilen ein Vergleiche mit state.val vorgenommen wird.
Ich habe es so gelöst, dass vor allen Abfragen immer ein Objekt-Typ erzeugt wird mit

if (!isAck) isAck = false;

vor der Prüfung von isAck. Oder funktioniert es so nicht korrekt ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.