# Globale werking Een Python programma opent een YAML-bestand met daarin alle beschikbare comando's die naar een APRS LoRa node gestuurd kunnen worden. Er wordt een MQTT client gestart, die luistert naar commando's vanuit Home Assistant. Wordt er een commando ontvangen dat voorkomt in het YAML-bestand dan wordt dit verstuurd naar de APRS LoRa node. ## Voorbeeld YAML-bestand ``` # Global settings apply to all other entries global: broker: pe1rxf.ampr.org # The broker we are going to use port: 1883 # The tcp port of the broker topic: hamnet_aprs_nodes # MQTT topic root transmit_rate: 30 # Number of seconds between each transmision retry: 3 # Try this often before giving up # MQTT topic: 5GHz dish at workshop (must be unique name) ubiquity_dish_ptmp_workshop: ON: # MQTT payload call: PE1RXF-6 # Call of node to which commands below are send port: ax2 # Name of AX.25 port to use command: 31{31 # This command is send to the node response: ack31 # This command is send to the node OFF: call: PE1RXF-6 port: ax2 command: 30{30 response: ack30 # MQTT topic: 5GHz dish at tiny house ubiquity_dish_ptp_tiny_house: ON: call: PE1RXF-5 port: ax2 command: 35{35 response: ack35 OFF: call: PE1RXF-5 port: ax2 command: 34{34 response: ack34 ``` Home Assistant stuurt payload 'ON' naar 'ubiquity_dish_ptmp_workshop/cmd' (via de broker). Het Python programma zoekt 'ubiquity_dish_workshop.ON.command' op. Als dit bestaat dan wordt dit commando verstuurd naar de APRS LoRa node (via het externe beacon-programma). Als 'ubiquity_dish_workshop.ON.response' bestaat wordt er gewacht totdat deze verwachte response binnenkomt in bestand ./aprs_utils/aprs-log/aprs_received_messages.log. Eventueel wordt er een retry verstuurd. Het Python programma houdt intern bij of een schakelaar aan of uit staat. Periodiek kan dit gecontroleerd worden door de status van de LoRa nodes op te vragen. De status van de schakelaar wordt gepubliceerd op op hetzelfde topic, maar dan eindigend op '/state' ``` import config_with_yaml as config cfg = config.load("demo.yml") print (cfg.getProperty("Demo.Motors.Server")) print (cfg.getPropertyWithDefault("Demo.Motors.Server2", "Server2")) print (cfg) ```