Node-Blue: Beispiel-Flows (Bewegungsmelder, zigbee2mqtt/harmony-api, Xiaomi Aqara Switch, Squeezebox)


#1

Licht mit Aus-timer

Ich habe hier einen Subflow für meine Bewegungsmelder-Licht-Steuerung.
Beim Eingang von true wird das Licht und ein 5 Minuten Timer eingeschaltet. Jedes weitere true am Eingang setzt den Timer zurück. Eingang ist Bewegungsmelder, Ausgänge gehen an eine Hue Lampe (STATE, BRIGHTNESS, COLOR_TEMPERATURE)

expire 5 minutes.txt (1,1 KB)


#2

zigbee2mqtt / harmony-api

Hier ist mein flow, um den State eines per zigbee2mqtt/harmony-api angeschlossenen Gerätes in eine Systemvariable und wieder zurück zu übertragen. Dadurch kann die Systemvariable wie eine Hue- oder Homematic-Devicevariable verwendet werden. (Es wird nur On/Off geschaltet, bei mir ist es ein Osram Smart Plug.)

zigbee2mqtt-systemvariable.txt (2,5 KB)

Hier ist ein Beispiel, wie diese Systemvariablen dann verwendet werden können. (Es werden drei Smart Plugs und eine Lampe ausgeschaltet.):

image


#3

Xiaomi Mi Aqara switch

Here is a more or less trivial subflow to decode the Xiaomi Mi Aqara Keys if connected via Zigbee2mqtt. These Keys report single, double, triple and quadruple clicks:

image

zigbee2mqtt-aqara.txt (591 Bytes)

I use these to toggle several Osram Smart Plugs and Hue-Lights

image


Neue Gerätefamilien / Nodes für Node Blue
#4

Squeezebox

Hier ist meine simple Umsetzung des Squeezebox-Http-Protokolls für Node-Blue. Umsetzung ist schon fast zuviel gesagt.

So sieht das Ding in Benutzung aus:

MAn füllt über die Template-Node folgende JSON-Struktur aus:

{   
    "p0": "",
    "p1": "",
    "p2": "",
    "p3": "",
    "p4": "",
    "server": "", 
    "port": "",
    "player": "" 
}

Die Werte für p0 bis p4 sind der folgenden Tabelle zu entnehmen:

p0 p1 p2 p3 p4 Description
play Start the player playing
pause (0,1,) Pause/unpause player. p1=1 to pause, p1=0 to unpause, omit p1 to toggle
stop Stop the player
sleep (0…n) (Play for p1 seconds and then sleep
playlist play Replace the current playlist with the song, playlist or directory specified by p2
playlist add Append the song, playlist or directory specified by p2 to the end of the current playlist
playlist insert Insert the song, playlist or directory specified by p2 to be played immediately after the current song.
playlist resume Replace the current playlist with the playlist specified by p2, starting at the song that was playing when the file was saved. (Resuming works only with M3U files saved with the playlist save command below.) Shortcut: use a bare playlist name (without leading directories or trailing .m3u suffix to load a playlist in the saved playlists folder.
playlist loadalbum Replace the current playlist with all songs for a given genre, artist, and album. Use a value of “*” for p2, p3, or p4 as a wildcard. Note: the server’s cache must contain the items for this to work.
playlist save Save a playlist file in the saved playlists directory. Accepts a playlist filename (without .m3u suffix) and saves in the top level of the playlists directory.
playlist addalbum Add all songs for a given genre, artist, and album. Use a value of “*” for p2, p3, or p4 as a wildcard. Note: the server’s cache must contain the items for this to work.
playlist clear Clear the current playlist
playlist repeat (0,1,2,) Change the repeat mode. p1=0 no repeat, stop at the end of the playlist, p1=1 repeat the current song, p1=2 repeat the entire playlist. Omit p1 to cycle through values.
playlist shuffle (0,1,2,) Shuffle the playlist. p1=0 no shuffle, p1=1 shuffle songs in the playlist, p1=2 shuffle albums in the playlist. Omit p1 to toggle shuffle mode.
playlist move Move the song in the offset specified by p2 to the offset specified by p3 in the playlist.
playlist delete Delete the song in the playlist at the offset specified by p2
playlist jump Make the song at the offset specified by p2 in the playlist the currently playing song
mixer volume (0 … 100) (-100 … +100)
mixer balance (0 … 100) (-100 … +100)
mixer base (0 … 100) (-100 … +100)
mixer treble (0 … 100) (-100 … +100)
status Return the current status of the player without any change.
display Put text on the player’s display. line 1 is specified by p1, line 2 is specified by p2. The text is displayed for a number of seconds as specified by p3. If p3 is omitted, then a default time is used of approximately 1.5 seconds.
button Simulate a button press from the infrared remote, where is a function name per the Default.map file.
rescan Start a rescan of the music library
pref Set the value of a preference. Use a value of “?” to get the value in the returned p2 header
pref ? Get the value of a preference. The value is returned in the returned p2 header
playerpref Set the value of a player specific preference. Use a value of “?” to get the value in the returned p2 header
playerpref ? Get the value of a player-specific preference. The value is returned in the returned p2 header
debug Set the value of a debugging variable, for example, set “d_ir” to “1” to have infrared debugging output.

Der Subflow ist im Gegensatz dazu ziemlich einfach:

image

squeezebox.txt (619 Bytes)