Here I can write down some notes
Last active
November 1, 2024 18:32
-
-
Save gitfvb/74bebe3ab773348d3386cf2e5f3f1a06 to your computer and use it in GitHub Desktop.
Some notes about the usage of hyperion
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
import requests | |
import json | |
# settings | |
url = 'http://192.168.2.154:8090/json-rpc' | |
effects=["Knight rider", "Atomic swirl", "Rainbow swirl fast"] | |
# create a session | |
s = requests.Session() | |
# Switch to effect instance | |
switchjson = {'command': 'instance', 'subcommand': 'switchTo', 'instance': 1 } | |
i = s.post(url, json = switchjson) | |
# Find out the active effect | |
activeEffectsJson = {'command': 'serverinfo', 'tan': 1 } | |
si = s.post(url, json = activeEffectsJson ) | |
info = si.json() | |
j = 0 | |
if len(info['info']['activeEffects']) > 0 : | |
# body of if statement | |
activeEffectName = info['info']['activeEffects'][0]['name'] | |
i = effects.index(activeEffectName) | |
j = i+1 | |
# end of list reached | |
if j >= len(effects) : | |
j = 0 | |
# Change effect | |
effectjson = {'command': 'effect', 'effect': {'name': effects[j]}, 'priority': 50 } | |
e = s.post(url, json = effectjson) | |
print (e.text) |
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
import requests | |
import json | |
# settings | |
url = 'http://192.168.2.154:8090/json-rpc' | |
effects=["Knight rider", "Atomic swirl", "Rainbow swirl fast"] | |
# create a session | |
s = requests.Session() | |
# Switch to effect instance | |
switchjson = {'command': 'instance', 'subcommand': 'switchTo', 'instance': 1 } | |
i = s.post(url, json = switchjson) | |
# Find out the active effect | |
activeEffectsJson = {'command': 'serverinfo', 'tan': 1 } | |
si = s.post(url, json = activeEffectsJson ) | |
info = si.json() | |
j = 0 | |
if len(info['info']['activeEffects']) > 0 : | |
# body of if statement | |
activeEffectName = info['info']['activeEffects'][0]['name'] | |
i = effects.index(activeEffectName) | |
j = i-1 | |
# end of list reached | |
if j < 0 : | |
j = len(effects) -1 | |
# Change effect | |
effectjson = {'command': 'effect', 'effect': {'name': effects[j]}, 'priority': 50 } | |
e = s.post(url, json = effectjson) | |
print (e.text) |
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
!/bin/bash | |
#instance=$( curl --header "Content-Type: application/json" --request POST --data '{"command":"serverinfo","tan":1}' http://192.168.2.154:8090/json-rpc | jq --raw-output '.instance' ) | |
# Find out the status of the second instance for effects. If it is not running, start it. Otherwise switch back and turn it off | |
instance=$(curl --header "Content-Type: application/json" --request POST --data '{"command":"serverinfo","tan":1}' http://192.168.2.154:8090/json-rpc | jq --raw-output '.info.instance[] | select(.instance==1)> | |
if [ $instance = false ]; then | |
curl --header "Content-Type: application/json" --request POST --data '{ "command": "componentstate", "componentstate": {"component": "ALL", "state": false} }' http://192.168.2.154:8090/json-rpc | |
curl --header "Content-Type: application/json" --request POST --data '{ "command": "instance", "subcommand": "startInstance", "instance": 1 }' http://192.168.2.154:8090/json-rpc | |
curl --header "Content-Type: application/json" --request POST --data '{ "command": "instance", "subcommand": "switchTo", "instance": 1 }' http://192.168.2.154:8090/json-rpc | |
else | |
curl --header "Content-Type: application/json" --request POST --data '{ "command": "instance", "subcommand": "stopInstance", "instance": 1 }' http://192.168.2.154:8090/json-rpc | |
curl --header "Content-Type: application/json" --request POST --data '{ "command": "instance", "subcommand": "switchTo", "instance": 0 }' http://192.168.2.154:8090/json-rpc | |
curl --header "Content-Type: application/json" --request POST --data '{ "command": "componentstate", "componentstate": {"component": "ALL", "state": true} }' http://192.168.2.154:8090/json-rpc | |
sleep 5s | |
curl --header "Content-Type: application/json" --request POST --data '{ "command": "componentstate", "componentstate": {"component": "SMOOTHING", "state": true} }' http://192.168.2.154:8090/json-rpc | |
fi |
Good hints to allow access to the linux machine without entering password:
https://linuxize.com/post/how-to-setup-passwordless-ssh-login/
The hints here did the missing part to connect without password: https://forums.raspberrypi.com/viewtopic.php?t=226203
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
top
shows processesgetent passwd
shows users from passwd filesudo updateHyperionUser
change hyperion service to the current usersystemctl status [email protected]
show current service status