Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
computer:raspberry_pi_mcp-relay [2016/04/03 11:08]
tdobes [Part 3: Relay Control]
computer:raspberry_pi_mcp-relay [2018/11/10 11:38]
tdobes
Line 6: Line 6:
 passwd passwd
 > /etc/motd > /etc/motd
-echo rpi-statusmonitor ​> /​etc/​hostname +echo rpi-relaycontrol ​> /​etc/​hostname 
-sed -i s/pi/rpi-statusmonitor/g /etc/hosts+sed -i s/pi/rpi-relaycontrol/g /etc/hosts
 echo "​America/​Chicago"​ > /​etc/​timezone echo "​America/​Chicago"​ > /​etc/​timezone
 dpkg-reconfigure -f noninteractive tzdata dpkg-reconfigure -f noninteractive tzdata
Line 103: Line 103:
 aptitude install mosquitto-clients python-mosquitto aptitude install mosquitto-clients python-mosquitto
  
-TODO: FINISH ME+** put files in /​opt/​mqtt_relay_control 
 + 
 +echo '​[Unit]'​ > /​etc/​systemd/​system/​mqtt_relay_control.service 
 +echo '​Description=Monitor and control relays through MQTT' >> /​etc/​systemd/​system/​mqtt_relay_control.service 
 +echo '​After=network.target'​ >> /​etc/​systemd/​system/​mqtt_relay_control.service 
 +echo >> /​etc/​systemd/​system/​mqtt_relay_control.service 
 +echo '​[Service]'​ >> /​etc/​systemd/​system/​mqtt_relay_control.service 
 +echo '​ExecStart=/​opt/​mqtt_relay_control/​relay_power_app.py'​ >> /​etc/​systemd/​system/​mqtt_relay_control.service 
 +echo '​WorkingDirectory=/​opt/​mqtt_relay_control'​ >> /​etc/​systemd/​system/​mqtt_relay_control.service 
 +echo '​User=root'​ >> /​etc/​systemd/​system/​mqtt_relay_control.service # TODO: figure out how to run do smbus communication as non-root 
 +echo '​Environment=PYTHONUNBUFFERED=1'​ >> /​etc/​systemd/​system/​mqtt_relay_control.service 
 +#echo '​RuntimeDirectory=mqtt_relay_control'​ >> /​etc/​systemd/​system/​mqtt_relay_control.service 
 +#echo '​RuntimeDirectoryMode=0755'​ >> /​etc/​systemd/​system/​mqtt_relay_control.service 
 +echo >> /​etc/​systemd/​system/​mqtt_relay_control.service 
 +echo '​Restart=always'​ >> /​etc/​systemd/​system/​mqtt_relay_control.service 
 +echo '​RestartSec=1'​ >> /​etc/​systemd/​system/​mqtt_relay_control.service 
 +echo '​StartLimitInterval=10s'​ >> /​etc/​systemd/​system/​mqtt_relay_control.service 
 +echo '​StartLimitBurst=10'​ >> /​etc/​systemd/​system/​mqtt_relay_control.service 
 +echo >> /​etc/​systemd/​system/​mqtt_relay_control.service 
 +echo '​[Install]'​ >> /​etc/​systemd/​system/​mqtt_relay_control.service 
 +echo '​WantedBy=multi-user.target'​ >> /​etc/​systemd/​system/​mqtt_relay_control.service 
 + 
 +systemctl enable mqtt_relay_control 
 +systemctl start mqtt_relay_control 
 + 
 +# only exists while program is running; /run/ subdirectory created by systemd through RuntimeDirectory directive 
 +#ln -sf /​run/​mqtt_relay_control/​relay_status.txt /​var/​www/​relay_status.txt 
 + 
 +# TODO: After upgrading systemd, uncomment RuntimeDirectory lines and symlink from /run/... remove symlink from /tmp/ below and update python source code to use new location 
 + 
 +ln -sf /​tmp/​relay_status.txt /​var/​www/​relay_status.txt
  
  
computer/raspberry_pi_mcp-relay.txt · Last modified: 2018/11/10 11:38 by tdobes
Recent changes RSS feed Driven by DokuWiki Valid XHTML 1.0 Valid CSS