- Delete obsolete users
- Alter pairing credentials to allow panel pairing - Start working on panel workflow
This commit is contained in:
parent
23f4d4ced9
commit
c8d5b4a7f3
7 changed files with 89 additions and 16 deletions
36
mock-clients/mock-actor.py
Normal file
36
mock-clients/mock-actor.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
import paho.mqtt.client as mqtt
|
||||
import logging, coloredlogs
|
||||
|
||||
coloredlogs.install(level='INFO', fmt='%(asctime)s - [%(levelname)s] %(message)s')
|
||||
|
||||
ACTOR_ID = "101"
|
||||
ACTOR_PASSWORD = "MgUiSW1dloFt9TVKJM5E"
|
||||
|
||||
def on_connect(client, userdata, flags, rc):
|
||||
global ACTOR_ID
|
||||
|
||||
if rc != 0:
|
||||
logging.error(f"Error connecting to MQTT broker: {rc}")
|
||||
return
|
||||
|
||||
logging.info("Successfully connected to MQTT broker")
|
||||
|
||||
client.subscribe(f"mlmAccess/actor/{ACTOR_ID}/action")
|
||||
client.publish(f"mlmAccess/actor/{ACTOR_ID}/status", "0", retain=True)
|
||||
|
||||
def on_message(client, userdata, message):
|
||||
messageContent = str(message.payload.decode("utf-8"))
|
||||
logging.info(f"Got request to perform action: {messageContent}")
|
||||
# report back action to let the backend know that it was executed successfully
|
||||
client.publish(f"mlmAccess/actor/{ACTOR_ID}/status", messageContent, retain=True)
|
||||
|
||||
client = mqtt.Client(client_id=f"actor-{ACTOR_ID}")
|
||||
client.username_pw_set(f"actor-{ACTOR_ID}", ACTOR_PASSWORD)
|
||||
|
||||
client.on_connect = on_connect
|
||||
client.on_message = on_message
|
||||
|
||||
logging.info("Initializing MQTT")
|
||||
client.connect("localhost", 1883, 60)
|
||||
|
||||
client.loop_forever()
|
43
mock-clients/mock-client-pair.py
Normal file
43
mock-clients/mock-client-pair.py
Normal file
|
@ -0,0 +1,43 @@
|
|||
import paho.mqtt.client as mqtt
|
||||
import logging, coloredlogs
|
||||
|
||||
coloredlogs.install(level='INFO', fmt='%(asctime)s - [%(levelname)s] %(message)s')
|
||||
|
||||
PAIR_ID = "1"
|
||||
DEVICE_TYPE = "actor" # actor or panel
|
||||
PAIR_SECRET = "pair-secret"
|
||||
|
||||
def on_connect(client, userdata, flags, rc):
|
||||
global PAIR_ID
|
||||
|
||||
if rc != 0:
|
||||
logging.error(f"Error connecting to MQTT broker: {rc}")
|
||||
return
|
||||
|
||||
logging.info("Successfully connected to MQTT broker")
|
||||
|
||||
client.subscribe(f"mlmAccess/pair/response/{DEVICE_TYPE}")
|
||||
|
||||
logging.info("Requesting pairing")
|
||||
client.publish(f"mlmAccess/pair/request/{DEVICE_TYPE}", PAIR_ID)
|
||||
|
||||
def on_message(client, userdata, message):
|
||||
messageContent = str(message.payload.decode("utf-8"))
|
||||
|
||||
if len(messageContent) > 0:
|
||||
logging.info(f"Pairing was successfull! The password is: {messageContent}")
|
||||
exit(0)
|
||||
else:
|
||||
logging.error("Pairing was not successfull!")
|
||||
exit(1)
|
||||
|
||||
client = mqtt.Client(client_id=f"pair")
|
||||
client.username_pw_set(f"pair", f"pair-secret")
|
||||
|
||||
client.on_connect = on_connect
|
||||
client.on_message = on_message
|
||||
|
||||
logging.info("Initializing MQTT")
|
||||
client.connect("localhost", 1883, 60)
|
||||
|
||||
client.loop_forever()
|
Loading…
Add table
Add a link
Reference in a new issue