-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from FyrfyX8/master
Created v1.0.0 of Gravihub
- Loading branch information
Showing
5 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
37 changes: 37 additions & 0 deletions
37
Scripts/Scripts from YT/All-rT(f)bT(f)gT-to-gS_rt(f)gT(f)bT-to-bS.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters