Skip to content

Commit

Permalink
Merge pull request #5 from FyrfyX8/master
Browse files Browse the repository at this point in the history
Created v1.0.0 of Gravihub
  • Loading branch information
FyrfyX8 authored Oct 16, 2023
2 parents 7d4550e + 9cbb9bc commit d8b93be
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
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()
19 changes: 19 additions & 0 deletions Scripts/Template.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
from gravitraxconnect import gravitrax_bridge as gb
from gravitraxconnect import gravitrax_constants as gc

#NameCode:
#Start with colour channel script is listening for:
#Red, Green, Blue, Red-Green, Red-Blue, Blue-Green, All
#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, 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, 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
#(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
#your code here
Expand Down

0 comments on commit d8b93be

Please sign in to comment.