Merge branch 'master' of ssh://git.fudo.org:2222/fudo-public/WallFly
This commit is contained in:
commit
f7bde8592f
30
flake.lock
30
flake.lock
|
@ -9,11 +9,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1655801580,
|
||||
"narHash": "sha256-4XUFDP1ES1KNWwDukQEixCe4uV7Z951kgaVAFhXI2ew=",
|
||||
"lastModified": 1663870497,
|
||||
"narHash": "sha256-gnoyYWvZl64WBqR3tf9bKHAznEtBCHmwx7taHghH9Lw=",
|
||||
"owner": "jlesquembre",
|
||||
"repo": "clj-nix",
|
||||
"rev": "579141e009200fcd28d251731e9ac5ba46a1ec2a",
|
||||
"rev": "23d9daacc80e634df078c4c6e34d592e1593d84c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -31,11 +31,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1644227066,
|
||||
"narHash": "sha256-FHcFZtpZEWnUh62xlyY3jfXAXHzJNEDLDzLsJxn+ve0=",
|
||||
"lastModified": 1658746384,
|
||||
"narHash": "sha256-CCJcoMOcXyZFrV1ag4XMTpAPjLWb4Anbv+ktXFI1ry0=",
|
||||
"owner": "numtide",
|
||||
"repo": "devshell",
|
||||
"rev": "7033f64dd9ef8d9d8644c5030c73913351d2b660",
|
||||
"rev": "0ffc7937bb5e8141af03d462b468bd071eb18e1b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -61,11 +61,11 @@
|
|||
},
|
||||
"flake-utils_2": {
|
||||
"locked": {
|
||||
"lastModified": 1644229661,
|
||||
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
|
||||
"lastModified": 1656928814,
|
||||
"narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
|
||||
"rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -76,11 +76,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1656265786,
|
||||
"narHash": "sha256-A9RkoGrxzsmMm0vily18p92Rasb+MbdDMaSnzmywXKw=",
|
||||
"lastModified": 1672580127,
|
||||
"narHash": "sha256-3lW3xZslREhJogoOkjeZtlBtvFMyxHku7I/9IVehhT8=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "cd90e773eae83ba7733d2377b6cdf84d45558780",
|
||||
"rev": "0874168639713f547c05947c76124f78441ea46c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -98,11 +98,11 @@
|
|||
},
|
||||
"utils": {
|
||||
"locked": {
|
||||
"lastModified": 1656065134,
|
||||
"narHash": "sha256-oc6E6ByIw3oJaIyc67maaFcnjYOz1mMcOtHxbEf9NwQ=",
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "bee6a7250dd1b01844a2de7e02e4df7d8a0a206c",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -14,14 +14,21 @@
|
|||
org.eclipse.paho.client.mqttv3.persist.MemoryPersistence)
|
||||
(:gen-class))
|
||||
|
||||
(defn- exit! [status msg]
|
||||
(println msg)
|
||||
(System/exit status))
|
||||
|
||||
(defn- create-mqtt-client [broker-uri client-id mqtt-username passwd]
|
||||
(let [opts (doto (MqttConnectOptions.)
|
||||
(.setCleanSession true)
|
||||
(.setAutomaticReconnect true)
|
||||
(.setPassword (char-array passwd))
|
||||
(.setUserName mqtt-username))]
|
||||
(doto (MqttClient. broker-uri client-id (MemoryPersistence.))
|
||||
(.connect opts))))
|
||||
(try
|
||||
(doto (MqttClient. broker-uri client-id (MemoryPersistence.))
|
||||
(.connect opts))
|
||||
(catch Exception e
|
||||
(exit! 1 (.getMessage e))))))
|
||||
|
||||
(defn- shell-exec [& args]
|
||||
(let [{:keys [exit out err]} (apply shell/sh args)]
|
||||
|
@ -45,7 +52,10 @@
|
|||
(.setRetained retained)))
|
||||
|
||||
(defn- send-message [client topic msg & {:keys [retained] :or {retained false}}]
|
||||
(.publish client topic (create-message msg retained)))
|
||||
(try
|
||||
(.publish client topic (create-message msg retained))
|
||||
(catch Exception e
|
||||
(exit! 1 (.getMessage e)))))
|
||||
|
||||
(defn- create-reporter [client time-to-idle location user host host-device]
|
||||
(let [base-topic (format "homeassistant/binary_sensor/wallfly_%s_%s"
|
||||
|
@ -93,10 +103,6 @@
|
|||
["-t" "--time-to-idle SECONDS" "Number of seconds before considering this host idle."]
|
||||
["-d" "--delay-time SECONDS" "Time to wait before polling for idle time."]])
|
||||
|
||||
(defn- exit! [status msg]
|
||||
(println msg)
|
||||
(System/exit status))
|
||||
|
||||
(defn- get-key [opts k]
|
||||
(if-let [opt (get opts k)]
|
||||
[k opt]
|
||||
|
|
Loading…
Reference in New Issue