Code Monkey home page Code Monkey logo

homeassistant-config's Issues

Motion Sensor Turn Off Automation

- alias: Turn on office lights when there is movement
  trigger:
    platform: state
    entity_id: binary_sensor.ecolink_pir_motion_sensor_sensor_2_0
    to: 'on'
  action:
    service: homeassistant.turn_on
    entity_id: light.officebot

- alias: Turn off lights when there is no motion
  trigger:
    platform: state
    entity_id: sensor.motion_sensor
    state: 'off'
    for:
    minutes: 10
  action:
    service: homeassistant.turn_off
    entity_id: light.officebot

ha-mgmt.sh

https://github.com/geekofweek/homeassistant/blob/master/tools/ha-mgmt.sh

#!/bin/bash

#################################################################
## Home Assistant Managment Tool
#################################################################

##########################################################
## Variables
##########################################################

hauser="USER_ACCOUNT"
habin="/usr/local/bin/hass"
haconfigdir="/home/USER/.homeassistant"
hahost="HOSTNAME/IP"
localuser="USER_ACCOUNT"
localhost="HOSTNAME/IP"
localpath="PATH_TO_LOCAL_HA_CONFIGS"


##########################################################
## Execute
##########################################################

answer=1
while [ "$answer" = 1 ]
do

 clear
 echo "This Script Will Modify Home Assistant"
 echo "Proceed with Caution!"
 echo ""
 echo "What would you like to do?"
 echo " "
 echo "1) Deploy Home Assistant Configs"
 echo "2) Restart Home Assistant - (sudo Required)"
 echo "3) Stop Home Assistant - (sudo Required)"
 echo "4) Start Home Assistant - (sudo Required)"
 echo "5) Upgrade Home Assistant - (sudo Required)"
 echo "6) Check Database Size - (sudo Required)"
 echo "7) Validate Home Assistant Config"
 echo "8) Backup Home Assistant"
 echo "9) Exit"
 echo " "
 read action

 if [ "$action" != "1" -a "$action" != "2" -a "$action" != "3" -a "$action" != "4" -a "$action" != "5" -a "$action" != "6" -a "$action" != "7" -a "$action" != "8" -a "$action" != "9"  ];then
 		echo ":-("
 		echo "Error!"
 		echo "Invalid Option Stupid"
    exit
 fi

 if [ "$action" == "1" ];then
   clear
   echo "Backing Up Home Assistant..."
   echo "Creating Tar File..."
   echo " "
   ssh -t $hauser@$hahost "mkdir /home/$hauser/temp; cd $haconfigdir; tar -czf /home/$hauser/temp/ha-backup-`date +"%m-%d-%Y-%H-%M"`.tar.gz *"
   echo " "
   echo "Moving Backup to Local Host"
   echo " "
   ssh -t $hauser@$hahost "scp /home/$hauser/temp/*.tar.gz $localuser@$localhost:$localpath/Backups"
   echo " "
   echo "Deploying Home Assistant Configs..."
   echo " "
   rsync -au --exclude=".*" --exclude ".*/" $localpath/Config/ $hauser@$hahost:/$haconfigdir
   echo " "
   echo "Validating Home Assistant Configs..."
   echo " "
   ssh -t $hauser@$hahost "$habin --script check_config"
   echo " "
   echo "Home Assistant Config Validation Complete"
   echo " "
   echo "Cleaning Up..."
   echo " "
   ssh -t $hauser@$hahost "rm -rf /home/$hauser/temp;"
   echo " "
   echo "Home Assistant Config Deployment Complete"
 fi

 if [ "$action" == "2" ];then
   clear
   echo "Restarting Home Assistant..."
   echo " "
   ssh -t $hauser@$hahost "sudo systemctl restart home-assistant@ha"
   echo " "
   echo "Home Assistant Restart Complete"
   echo " "
 fi

 if [ "$action" == "3" ];then
   clear
   echo "Stopping Home Assistant..."
   echo " "
   ssh -t $hauser@$hahost "sudo systemctl stop home-assistant@ha"
   echo " "
   echo "Home Assistant Stop Complete"
   echo " "
 fi

 if [ "$action" == "4" ];then
   clear
   echo "Starting Home Assistant..."
   echo " "
   ssh -t $hauser@$hahost "sudo systemctl start home-assistant@ha"
   echo " "
   echo "Home Assistant Start Complete"
   echo " "
 fi

 if [ "$action" == "5" ];then
   clear
   echo "Upgrading Home Assistant..."
   echo " "
   ssh -t $hauser@$hahost "sudo pip3 install --upgrade homeassistant"
   echo " "
   echo "Upgrade Complete"
   echo " "
 fi

 if [ "$action" == "6" ];then
   clear
   echo "Checkign Size of Home Assistant Databae..."
   echo " "
   ssh -t $hauser@$hahost "sudo du -sh /var/lib/mysql | cut -c -5"
   echo " "
   echo "Home Assistant Size Check Complete"
   echo " "
 fi

 if [ "$action" == "7" ];then
   clear
   echo "Validating Home Assistant Configs..."
   echo " "
   ssh -t $hauser@$hahost "$habin --script check_config"
   echo " "
   echo "Home Assistant Config Validation Complete"
   echo " "
 fi

 if [ "$action" == "8" ];then
   clear
   echo "Backing Up Home Assistant..."
   echo "Creating Tar File..."
   echo " "
   ssh -t $hauser@$hahost "mkdir /home/$hauser/temp; cd $haconfigdir; tar -czf /home/$hauser/temp/ha-backup-`date +"%m-%d-%Y-%H-%M"`.tar.gz *"
   echo " "
   echo "Moving Backup to Local Host"
   echo " "
   ssh -t $hauser@$hahost "scp /home/$hauser/temp/*.tar.gz $localuser@$localhost:$localpath/Backups"
   echo " "
   echo "Cleaning Up..."
   echo " "
   ssh -t $hauser@$hahost "rm -rf /home/$hauser/temp;"
   echo " "
   echo "Backup Complete"
   echo " "
 fi

 if [ "$action" == "9" ];then
   clear
   echo " "
   echo ":-("
   echo "Exiting"
   echo " "
   exit
 fi


echo " "
echo "Do You Want to Perform Another Task?"
echo " "
echo "1) Yes"
echo "2) No"
echo " "
read answer

if [ "$answer" = 1 ]
then "run script again"
fi

done

clear
echo " "
echo ":-("
echo "Exiting"
echo " "

z-wave

automation:
  - alias: Turn on office lights when there is movement
    trigger:
      - platform: state
        entity_id: sensor.motion_sensor
        to: 'on'
    action:
      service: homeassistant.turn_on
      entity_id: group.office_lights 

  - alias: Turn off lights when there is no motion
    trigger:
      - platform: state
        entity_id: sensor.motion_sensor
        state: 'off'
        for:
          minutes: 10
    action:
      service: homeassistant.turn_off
      entity_id: group.office_lights

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.