forked from henrik242/OnAir
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed MQTT and py2app. Added KM actions.
- Loading branch information
Showing
3 changed files
with
19 additions
and
71 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,9 @@ | |
dist | ||
build | ||
.DS_Store | ||
drafts | ||
# Mac app compilation | ||
Makefile | ||
onair.icns | ||
setup.py | ||
.onair.ini |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,36 @@ | ||
![](onair.png) | ||
|
||
OnAir status indicator for macOS camera usage | ||
OnAir status indicator for macOS camera usage with a Keyboard Maestro trigger. | ||
== | ||
|
||
Using a menubar indicator, and a MQTT message for Futurehome to turn on/off a light bulb | ||
This is based off of the work of henrik242 at https://github.com/henrik242/OnAir | ||
|
||
``` | ||
usage: OnAir.py [-h] [--host HOST] [--port PORT] [--topic TOPIC] [--user USER] [--password PASSWORD] [--debug] | ||
optional arguments: | ||
-h, --help show this help message and exit | ||
--host HOST (default: futurehome-smarthub.local) | ||
--port PORT (default: 1884) | ||
--topic TOPIC (default: pt:j1/mt:cmd/rt:dev/rn:zw/ad:1/sv:out_bin_switch/ad:19_0) | ||
--user USER | ||
--password PASSWORD | ||
--debug (default: False) | ||
``` | ||
|
||
Configuration | ||
-- | ||
`~/.onair.ini` is used for MQTT configuration. It will be created automatically on the first run. Here's an example: | ||
``` | ||
[DEFAULT] | ||
user=myuser | ||
password=mypass | ||
host=futurehome-smarthub.local | ||
port=1884 | ||
topic=pt:j1/mt:cmd/rt:dev/rn:zw/ad:1/sv:out_bin_switch/ad:19_0 | ||
debug=False | ||
``` | ||
See | ||
<https://support.futurehome.no/hc/en-no/articles/360033256491-Local-API-access-over-MQTT-Beta-> for MQTT user/password setup. | ||
Using a menubar indicator and Keyboard Maestro triggers to turn on/off a light bulb | ||
|
||
Releases | ||
-- | ||
Fetch the latest app build from <https://nightly.link/henrik242/OnAir/workflows/build/main/OnAir.app.tgz.zip> | ||
**Please make sure you add the correct KM UUIDs to change the light status.** | ||
|
||
To get the UUID, find the macro for "Off" and "On" and right-click Copy as > Copy as UUID | ||
|
||
Futurehome and MQTT testing | ||
-- | ||
Go to <http://futurehome-smarthub.local:8081/fimp/timeline> and set the Service filter to `out_bin_switch`. | ||
Turn off/on your desired light to discover the topic for it, e.g. `pt:j1/mt:cmd/rt:dev/rn:zw/ad:1/sv:out_bin_switch/ad:19_0`, | ||
and the actual message, e.g. | ||
``` | ||
{ | ||
"serv": "out_bin_switch", | ||
"type": "cmd.binary.set", | ||
"val_t": "bool", | ||
"val": true, | ||
"props": null, | ||
"tags": null | ||
} | ||
``` | ||
|
||
Use a MQTT client such as [mqtt-cli](https://github.com/hivemq/mqtt-cli) or [MQTT Explorer](http://mqtt-explorer.com/) | ||
to send a message to turn the light on or off (`val` set to `true` or `false`). | ||
Note that the MQTT version 5 doesn't work, it needs to be v3. | ||
|
||
Here's an example from mqtt-cli: | ||
``` | ||
$ mqtt pub -v -V 3 -h futurehome-smarthub.local -p 1884 \ | ||
-u my_username -pw my_password \ | ||
-t pt:j1/mt:cmd/rt:dev/rn:zw/ad:1/sv:out_bin_switch/ad:19_0 \ | ||
-m '{ | ||
"serv": "out_bin_switch", | ||
"type": "cmd.binary.set", | ||
"val_t": "bool", | ||
"val": true, | ||
"props": null, | ||
"tags": null | ||
}' | ||
usage: OnAirKM.py & | ||
``` | ||
|
||
Building the app | ||
-- | ||
|
||
``` | ||
pip3 install -r requirements.txt | ||
./setup.py py2app | ||
``` | ||
|
||
This creates OnAir.app in `dist/` | ||
This installs the appropriate Python module requirements. | ||
|
||
Planned improvements: | ||
- Settings file so you don't have to hard-code the KM UUIDs | ||
- Compile as Mac app per henrik242 repo | ||
|
||
Thanks to | ||
-- | ||
|
||
- <https://github.com/henrik242/OnAir> | ||
- <https://github.com/jaredks/rumps> | ||
- <https://github.com/ronaldoussoren/py2app> | ||
- <https://camillovisini.com/article/create-macos-menu-bar-app-pomodoro/> | ||
- <https://www.hivemq.com/blog/mqtt-client-library-paho-python/> | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
rumps | ||
paho-mqtt | ||
py2app | ||
# py2app |