Announcement

Collapse
No announcement yet.

Event to send ssh command?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Here start ZWave on the old RPi2 via HS3 this way. The old RPi2 talks to the ZeeLite computer running Ubuntu 16.04 64 bit (ARM or Intel).

    Event reads

    /bin/sh /HomeSeer/scripts/startzwave.sh

    For root / users the ssh keys are located in the .ssh directory.

    startzwave.sh

    #!/bin/bash
    #: Description: Enables the required modules Homeseer ZWave

    ssh root@192.168.244.169 "/usr/bin/mono /HomeSeer/HSPI_ZWave.exe server=192.168.244.164 >> /dev/null 2>&1"


    169 is the RPi2 with the ZWave GPIO card and 164 is the computer running ZeeLite.

    If you want to utilize just a regular user use that instead of root. Same user on both computers.

    I just tested this switching the user from root to pete. Worked fine.

    Here running a script on the two boxes. One that copies Digitemp text over and one that starts Z-Wave.

    Look here:

    Using DigiTemp on RPi2
    Last edited by Pete; May 14, 2017, 03:27 PM.
    - Pete

    Auto mator
    Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb- Mono 6.12.X - HSTouch on Intel tabletop tablets
    Homeseer Zee2 (Lite) - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro - Mono 6.12.X
    HS4 Pro - V4.1.10.0 - Ubuntu 18.04/VB W7e 64 bit Intel Kaby Lake CPU - 32Gb - Mono 6.12.x
    HS4 Lite -

    X10, UPB, Zigbee, ZWave and Wifi MQTT automation-Tasmota-Espurna. OmniPro 2, Russound zoned audio, Smartthings hub, Hubitat Hub, and Home Assistant

    Comment


      #17
      Originally posted by zwolfpack View Post
      Cool - how did you get around the password prompt?
      My events would not work until I got the rsa token set in root. I had to add the rsa token as the root for Homseer to work. For following reference my remote PI is 192.168.10.18 and pi is my username. I followed these instructions as root, see below in step 2. I believe, guessing, homeseer issues events via root.
      https://www.raspberrypi.org/document...asswordless.md

      1. SSH into your homeseer. You should see homeseer@HomeTrollerZeeS2V2:~ $
      2. Switch to Root, Enter: sudo su
      (Now you should see root@HomeTrollerZeeS2V2:/home/homeseer#)
      3. Create rsa key as root, Enter: ssh-keygen -t rsa -C pi@pi
      (Enter through passphrase stuff)
      4. Add rsa token to remote PI, Enter: cat ~/.ssh/id_rsa.pub | ssh pi@192.168.10.18 'cat >> .ssh/authorized_keys'
      (enter remote pi password when prompted)
      5. Try ssh from root.
      You should see: root@HomeTrollerZeeS2V2:/home/homeseer#
      Then Enter: ssh pi@192.168.10.18

      When the above test worked then my PI_homeseer box could run the sh file.

      Comment


        #18
        Here have configured the Homeseer directory to be accessible and have full rights by pete and homeseer (and root) on the PC.
        - Pete

        Auto mator
        Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb- Mono 6.12.X - HSTouch on Intel tabletop tablets
        Homeseer Zee2 (Lite) - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro - Mono 6.12.X
        HS4 Pro - V4.1.10.0 - Ubuntu 18.04/VB W7e 64 bit Intel Kaby Lake CPU - 32Gb - Mono 6.12.x
        HS4 Lite -

        X10, UPB, Zigbee, ZWave and Wifi MQTT automation-Tasmota-Espurna. OmniPro 2, Russound zoned audio, Smartthings hub, Hubitat Hub, and Home Assistant

        Comment


          #19
          That was it, I am pretty sure I have my homeseer install running under a service account and had assumed that it would invoke the script as the same service account. So I performed the following:

          sudo su
          <myrootpwd>

          ssh-keygen

          /root/.ssh/id_rsa.pub
          <nopwd>
          <nopwd>

          ssh-copy-id -i ~/.ssh/id_rsa.pub <username>@<remoteserver>

          I can now run my script without issue while logged in as root. I, also, have found that the event is working when I manually fire it.

          Now on to my 60(ish) day event trigger and conditions. BLLAN seems to only show status of offline (0) and online (100), but does show offline and online duration in the status column of the device in the home menu. I will keep working on this to see if i can get access to the built in online duration data.
          In the meantime I created a timer, and a second event that restarts the timer when the BLLAN device changes states to 100 (online). I created a third event that stops the timer when the BLLAN device changes states to 0 (offline). my main 60 day reboot
          On my 60(ish) day event I set the event trigger to fire off at 5AM with conditions:
          day of the week is a monday,
          uptime timer as greater than 60 days.

          We will see how this works. thanks guys for all of your help.

          Comment


            #20
            After some trial and error, I figured out how to run these commands directly from an event without needing a script or any additional Linux packages. This command is for telnet but it should work for ssh as well. Pay close attention to the formatting, all spaces and quotes are necessary. This is tested and working on a Linux HS system running Ubuntu 16.04 Server x64.

            PS If anyone has a newer Netgear web managed switch (Mine is a GS724TPv2), these are the hidden commands to power cycle PoE port 23. You will need to go to Maintenance > Troubleshooting > and enable Remote Diagnostics to enable the hidden telnet server on port 60000.

            Here's the text:
            -c " { echo ""username""; echo ""password""; sleep 1; echo ""enable""; echo ""config""; echo ""interface gi1/23""; echo ""peth shutdown""; sleep 10; echo ""no peth shutdown""; sleep 5; echo ""exit""; echo ""exit""; } | telnet 192.168.8.9 60000 "
            Attached Files
            Last edited by mwolter; January 14, 2018, 01:06 AM.

            Comment


              #21
              I'm sure an update somewhere is to blame... the command arguments above stopped working. Had to replace echo with printf which should make it more robust. It also logs the session to a text file for review.

              Note: \r is a carriage return.

              Code:
              -c " { printf 'USERNAME\r'; printf 'PASSWORD\r'; sleep 1; printf 'enable\r'; printf 'config\r'; printf 'interface gi1/15\r'; printf 'peth shutdown\r'; sleep 10; printf 'no peth shutdown\r'; sleep 5; printf 'exit\r'; printf 'exit\r'; printf 'exit\r'; printf 'exit\r';} | telnet 192.168.8.9 60000 >> /usr/local/HomeSeer/telnet.txt "
              It can be shortened to the command below but the abovementioned is much more readable.

              Code:
              -c " { printf 'USERNAME\rPASSWORD\r'; sleep 1; printf 'enable\rconfig\rinterface gi1/15\rpeth shutdown\r'; sleep 10; printf 'no peth shutdown\r'; sleep 5; printf 'exit\rexit\rexit\rexit\r';} | telnet 192.168.8.9 60000 >> /usr/local/HomeSeer/telnet.txt "
              Hope this saves someone a couple hours 😀

              Comment

              Working...
              X