aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.dockerignore1
-rw-r--r--.gitmodules3
-rw-r--r--docker-compose.yml2
-rw-r--r--mqtt-client/mqtt-client.py28
m---------mqtt-client/omada-api0
-rw-r--r--mqtt-client/omada.cfg6
-rw-r--r--switch-snmp/omada-switches.conf7
7 files changed, 40 insertions, 7 deletions
diff --git a/.dockerignore b/.dockerignore
index 9481f42..8cf10b3 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -2,3 +2,4 @@ power.env
db.env
*.pub
*.pem
+*.cfg
diff --git a/.gitmodules b/.gitmodules
index 6933443..cc3beca 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,6 @@
[submodule "mqtt-client/TasmotaCLI"]
path = mqtt-client/TasmotaCLI
url = git@github.com:jwansek/TasmotaCLI.git
+[submodule "mqtt-client/omada-api"]
+ path = mqtt-client/omada-api
+ url = git@github.com:thannerfabian/omada-api
diff --git a/docker-compose.yml b/docker-compose.yml
index fe8fd2e..86ee909 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -31,6 +31,8 @@ services:
build:
context: ./mqtt-client
dockerfile: Dockerfile
+ volumes:
+ - ./mqtt-client/omada.cfg:/app/omada.cfg
env_file:
- ./config.env
depends_on:
diff --git a/mqtt-client/mqtt-client.py b/mqtt-client/mqtt-client.py
index cd38944..8c7bd23 100644
--- a/mqtt-client/mqtt-client.py
+++ b/mqtt-client/mqtt-client.py
@@ -14,6 +14,9 @@ sys.path.insert(1, os.path.join(os.path.dirname(__file__), "TasmotaCLI"))
import tasmotaMQTTClient
import tasmotaHTTPClient
+sys.path.insert(2, os.path.join(os.path.dirname(__file__), "omada-api"))
+from omada import Omada
+
class MQTTClient:
def __init__(self, mqtt_client_name = "reg.reaweb.uk/mqtt-client", loop_forever = True):
self.influxc = InfluxDBClient(
@@ -95,17 +98,18 @@ class MQTTClient:
if status_before == "OFF":
print("TV was formerly off, so its being turned on, so we're going to turn the firestick on.")
- tasmotaMQTTClient.MQTTClient(MQTT_HOST, "TasmotaFirestick", os.environ["MQTT_USER"], os.environ["MQTT_PASSWD"], "OFF")
+
+ set_omada_poe("Firestick", 0)
print("Waiting...")
time.sleep(8)
- tasmotaMQTTClient.MQTTClient(MQTT_HOST, "TasmotaFirestick", os.environ["MQTT_USER"], os.environ["MQTT_PASSWD"], "ON")
+ set_omada_poe("Firestick", 1)
print("Turned firestick on.")
else:
print("TV was formerly on, so its being turned off, so we're going to turn the firestick off.")
- tasmotaMQTTClient.MQTTClient(MQTT_HOST, "TasmotaFirestick", os.environ["MQTT_USER"], os.environ["MQTT_PASSWD"], "ON")
+ set_omada_poe("Firestick", 1)
print("Waiting...")
time.sleep(8)
- tasmotaMQTTClient.MQTTClient(MQTT_HOST, "TasmotaFirestick", os.environ["MQTT_USER"], os.environ["MQTT_PASSWD"], "OFF")
+ set_omada_poe("Firestick", 0)
print("Turned firestick off.")
zigbee_id = list(msg_j["ZbReceived"].keys())[0]
@@ -114,7 +118,7 @@ class MQTTClient:
del fields["Device"]
print("Zigbee device '%s' reported: %s" % (friendlyname, str(fields)))
- if zigbee_id == "0x7327" and friendlyname == "TVButton" and "Power" in fields.keys():
+ if zigbee_id == "0x0A05" and friendlyname == "TVButton2" and "Power" in fields.keys():
if fields["Power"] == 2:
print("TV Zigbee button pressed, toggling TasmotaTV Tasmota Plug")
status_before = self.get_http_power_status("192.168.5.6", os.environ["MQTT_PASSWD"])
@@ -171,6 +175,20 @@ class MQTTClient:
write_precision = WritePrecision.S
)
+def set_omada_poe(profile, status):
+ o = Omada(os.path.join(os.path.dirname(__file__), "omada.cfg"))
+ o.login()
+
+ profileId = o.getProfileId(profile)
+ settings = o.getProfileSettings(profileId)
+ settings['poe'] = status
+ o.setProfileSettings(profileId, settings)
+
+ settings = o.getProfileSettings(profileId)
+
+ print("Sent POE setting '%d' to profile '%s'" % (settings["poe"], settings["name"]))
+ o.logout()
+
if __name__ == "__main__":
env_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "config.env")
if os.path.exists(env_path):
diff --git a/mqtt-client/omada-api b/mqtt-client/omada-api
new file mode 160000
+Subproject b169929137ec8647bf520067aa2e75e61839a9a
diff --git a/mqtt-client/omada.cfg b/mqtt-client/omada.cfg
new file mode 100644
index 0000000..5679e8d
--- /dev/null
+++ b/mqtt-client/omada.cfg
@@ -0,0 +1,6 @@
+[omada]
+baseurl = https://192.168.69.2:30077
+site = Home
+verify = False
+username = admin
+password = {@dxG3Ii{hpR]enKC<76
diff --git a/switch-snmp/omada-switches.conf b/switch-snmp/omada-switches.conf
index a76ff82..e4a6888 100644
--- a/switch-snmp/omada-switches.conf
+++ b/switch-snmp/omada-switches.conf
@@ -5,9 +5,8 @@
6 = Routerbox
16 = Intel Compute Stick
24 = Frigate Pi
-23 = Modem & ES205G
+23 = SG2005P-PD
8 = PiKVM
-10 = TL-RP108GE & EAP110
11 = Type-C POE Charger
22 = Cluster Pi 9
19 = Cluster Pi 5
@@ -18,4 +17,8 @@
9 = Jetson Orin Nano
12 = Netgate SG-1100
+[192.168.69.27]
+1 = Fibre ONT
+2 = TL-RP108GE & EAP110
+3 = Firestick