Skip to content

Commit

Permalink
Merge pull request #3 from FyrfyX8/V1
Browse files Browse the repository at this point in the history
Added First YT script and fixed naming
  • Loading branch information
FyrfyX8 authored Oct 8, 2023
2 parents ef938f0 + 1d4dae1 commit 9cbb9bc
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from gravitraxconnect import gravitrax_bridge as gb
from gravitraxconnect import gravitrax_constants as gc
#this script waits for the sequence red blue green or red green blue
#from triggers, to determine to send Blue/Green signal.

sequence = []

async def notification_callback(bridge: gb.Bridge, **signal): # Code runs when receving a signal
global sequence
if signal.get("Header") == gc.MSG_DEFAULT_HEADER:
status = signal.get("Status")
color = signal.get("Color")
stone = signal.get("Stone")
if stone == gc.STONE_TRIGGER and color == gc.COLOR_RED and len(sequence) == 0:
sequence.append("red")
elif stone == gc.STONE_TRIGGER and len(sequence) == 1:
if color == gc.COLOR_GREEN:
sequence.append("green")
elif color == gc.COLOR_BLUE:
sequence.append("blue")
else:
sequence = []
elif stone == gc.STONE_TRIGGER and len(sequence) == 2:
if ((color == gc.COLOR_GREEN and sequence[1] == "blue") or
(color == gc.COLOR_BLUE and sequence[1] == "green")):
await bridge.send_signal(status=gc.STATUS_SWITCH, color_channel=color, stone=gc.STONE_BRIDGE,
resends=12)
sequence = []


async def GBsetup(bridge, bridgeCount=None): # Code runs shortly after connecting
if bridgeCount == 1:
await bridge.start_bridge_mode()

async def GBshutdown(bridge, bridgeCount=None): # Code runs shortly before disconnecting
if bridgeCount == 1:
await bridge.stop_bridge_mode()
13 changes: 9 additions & 4 deletions Scripts/Template.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@
#Next is what the Script does, all Parts are marked with colour:
#r, g, b, rg, rb, bg, a
#First is the stone that the signal was send from:
#Trigger: T, Finish-Trigger: Z, Controller: C, Connect: B, Dome-Stater: D
#if your script waits for an sequence of signals use ">"
#Trigger: T, Finish-Trigger: Z, Controller: C, Connect: B, Dome-Stater: D, All: A
#if your script waits for an sequence of signals use "(f)"
#Followed by the stone receiving the signal:
#Dome-Stater: D, Switch: S, Sound: Sm, Lever: L, Connect: B
#Dome-Stater: D, Switch: S, Sound: Sm, Lever: L, Connect: B, All: A
#if your script listens to all or is sending to all stones only use the colour
#if the signal is send directly you use "to" if not here are some examples
#Red_rT-70%r-30%b, Green-Red_rT>gT-2*rS, All_rT>gZ-to-g_rT>bZ-to-b
#(p)= %, (f)= followed by, (t)= times
#Red_rT-70(p)r-30(p)b, Green-Red_rT(f)gT-2(t)rS, All_rT(f)gZ-to-g_rT(f)bZ-to-b
#Scripts using counter can be show using numbers like: Red_rt-2b-3r
#this means red triggers receiving 5 signals send the firt two as blue
#and the last 3 as red
#More naming Examples are in the Scripts from YT folder!


async def notification_callback(bridge: gb.Bridge, **signal): #Code runs when receving a signal
Expand Down

0 comments on commit 9cbb9bc

Please sign in to comment.