Skip to content

Instantly share code, notes, and snippets.

@Garfonso
Garfonso / await-spielen.js
Created December 23, 2023 09:06
Await-Spielerei
async function Berechnung () {
console.log("Berechnung: Start");
const promise = new Promise(resolve => {
setTimeout(() => { resolve(1 + 1)}, 100);
});
console.log("Berechnung: Ende");
return promise;
}
@Garfonso
Garfonso / syncShoppingLists.js
Last active February 2, 2024 13:45
ioBroker: Sync Lovelace and Alexa Shopping Lists
const shoppingListId = 'lovelace.0.control.shopping_list';
const alexa2BaseId = 'alexa2.0.Lists.SHOPPING_LIST'; //important. Needed for delete & update also.
const alexaAddToList = alexa2BaseId + '.#New';
const alexaListId = alexa2BaseId + '.json';
//switch off to silence:
const printDebug = true;
function debug(msg) {
if (printDebug) {
@Garfonso
Garfonso / firtzBoxLibDataLua.js
Created May 17, 2020 12:22
Manipulate FritzBox 6490 (and maybe other) hosts lists.
//manipulate FritzBox Hosts list using data.lua!
'use strict';
const axios = require('axios').default;
const crypto = require('crypto');
function buildUrl(host, path) {
return 'http://' + host + path;
}
@Garfonso
Garfonso / AtmoLight-iobroker.js
Created May 8, 2020 13:17
Control AtmoLight with ioBroker
// I had an old AtmoLight ( http://www.mediacenter-pc.com/atmolight/ ) idling around.
// It is connected via USB (and creates a serial port) and controls four LED stripes
// So I wanted to control it with ioBroker. Here is the script for that.
// You should set the right serial port below:
//configure right serial port here. I recommend looking up the ID and replacing the scrint below by the id string.
//looks like: /dev/serial/by-id/usb-c@rstenpresser.de_AtmoLight_SMD_v04_23U9NVYR-if00-port0"
const portPath = "/dev/ttyUSB";
//also you can configure the name of a folder in javascript.* here. There will be two states, brighness and color in there.
@Garfonso
Garfonso / iobroker-aura.js
Last active November 7, 2020 23:17
Control Asus Aura LEDs from ioBroker
//use aura-sdk to switch aura light with iobroker :-)
//based on this: https://github.com/DanielRamosAcosta/aura-sdk/blob/master/example/rainbow.js
//known issue: The aura-sdk is not very reliable. I did not find a way to solve this, sadly. Sometimes it just won't switch at all.
//needs 32bit. For windows:
// * install iobroker instance using installer.
// * note node.js version that get's installed (or look it up after install by running node --version in iobroker terminal)
// * download the same node.js version in 32Bit (x86) from here: https://nodejs.org/dist/ as zip file,
// * make sure you download the file containinig win-x86, for example: https://nodejs.org/dist/v10.17.0/node-v10.17.0-win-x86.zip
// * go to the ioBroker-instance folder and rename the nodejs subfolder do nodejs_64
// * create a new folder named nodejs -> extract the zip contents there
@Garfonso
Garfonso / webos service send on private bus
Created September 29, 2014 06:00
webos service send on private bus
add
'"privatebus": true"'
to Service definition, i.e. on same scope as commands.