☰
Current Page
Main Menu
Home
Home
Editing MqttDasherService
Edit
Preview
H1
H2
H3
default
Set your preferred keybinding
default
vim
emacs
markdown
Set this page's format to
Markdown
Plain Text
Pod
RDoc
reStructuredText
Rendering unavailable for
AsciiDoc
BibTeX
Creole
MediaWiki
Org-mode
Textile
Help 1
Help 1
Help 1
Help 2
Help 3
Help 4
Help 5
Help 6
Help 7
Help 8
Autosaved text is available. Click the button to restore it.
Restore Text
--- title: MqttDasherService --- Create an mqtt-dasher service. (Debian/Ubuntu distros). mqtt-dasher : <https://github.com/stjohnjohnson/mqtt-dasher> Limits permissions for promiscuous net socket access via libpcap. This assumes `npm install` without the global flag so uses `/opt/node_modules` instead of `/usr/lib`. # Install # install nodejs from debsource curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash - sudo apt-get install -y nodejs # install mqtt-dasher and libpcap dependency sudo apt-get install libpcap-dev sudo npm install mqtt-dasher # add user to run the service, and group to limit access to setcap files sudo useradd mqtt-dasher -d /opt/node_modules/mqtt-dasher -U # make a copy of nodejs to set privileged net capabilities on sudo cp `which nodejs` /opt/node_modules/mqtt-dasher/nodejs.setcap # set user and group for mqtt-dasher first sudo chgrp mqtt-dasher /opt/node_modules/mqtt-dasher/nodejs.setcap sudo chmod 750 /opt/node_modules/mqtt-dasher/nodejs.setcap # allow raw sockets and net admin for promiscuous mode sudo setcap 'CAP\_NET\_RAW+eip CAP\_NET\_ADMIN+eip' /opt/node_modules/mqtt-dasher/nodejs.setcap ## Create the Service `/etc/systemd/system/mqtt-dasher.service` [Unit] Description=mqtt-dasher service [Service] ExecStart=/opt/node_modules/mqtt-dasher/nodejs.setcap /opt/node_modules/mqtt-dasher/server.js # WorkingDirectory=/opt/node_modules/mqtt-dasher # Required on some systems Restart=always RestartSec=10 # Restart service after 10 seconds if node service crashes StandardOutput=syslog # Output to syslog StandardError=syslog # Output to syslog SyslogIdentifier=mqtt-dasher User=mqtt-dasher Group=mqtt-dasher Environment=CONFIG_DIR=/etc/mqtt-dasher NODE_ENV=production [Install] WantedBy=multi-user.target # Configure and start sudo mkdir /etc/mqtt-dasher [[$[Get Code]]][2] `/etc/mqtt-dasher/config.yml` mqtt: host: localhost ## Preface for the topics $PREFACE/$TOPIC ## (not in mqtt-dasher 0.1.0) #preface: ha/dash buttons: ab:cd:ef:12:34:56: ha/dash/listerine sudo systemctl enable mqtt-dasher sudo systemctl start mqtt-dasher # Home Assistant Switch An mqtt switch which: * turns on when the dash button is activated * turns off when the dash button deactivates * can be activated and deactivated from HA switch: - name: Listerine platform: mqtt command_topic: ha/dash/listerine state_topic: ha/dash/listerine payload_on: 'active' payload_off: 'inactive' retain: false The switch isn't intended to be used in the HA UI, it should be mapped to a script instead. # To Do Compile mqtt-dasher with [nexe][5] so that `nodejs.setcap` can't be so easily abused. [1]: MqttDasherService?action=sourceblock&num=1 [2]: MqttDasherService?action=sourceblock&num=2 [3]: MqttDasherService?action=sourceblock&num=3 [4]: MqttDasherService?action=sourceblock&num=4 [5]: https://github.com/nexe/nexe <!-- vim: filetype=markdown -->
Uploading file...
Sidebar
# SideBar * [Home][1] * [Projects][2] * * * <!-- --> * [Code][3] * [Tech][4] * [Network][5] * [MediaCentre][6] * [UAV][7] * * * <!-- --> * [Travel][8] * [Music][9] * [Horse Riding][10] * [Study][11] * [Games][12] * [Other Activities][13] * * * <!-- --> * [Car][14] * [House][15] * [Watch][16] * [Clothing][17] * [Miscellany][18] * * * [1]: /Home [2]: /Projects [3]: /Code/Code [4]: /Tech/Tech [5]: /Network/Network [6]: /MediaCentre/MediaCentre [7]: /UAV/UAV [8]: /Travel/Travel [9]: /Music/Music [10]: /HorseRiding/HorseRiding [11]: /Study/Study [12]: /Games/Games [13]: /Do/Do [14]: /Car/Car [15]: /House/House [16]: /Watch/Watch [17]: /Clothing/Clothing [18]: /Miscellany/Miscellany <!-- vim: filetype=markdown -->
Edit message:
Cancel