SmartCrypto icon indicating copy to clipboard operation
SmartCrypto copied to clipboard

Install this on Raspbian. what do I need?

Open Mannshoch opened this issue 5 years ago • 1 comments

Goal I would like to install this on a Raspbian. Goal is to use it with node-red and over SSH.

Problem:

  1. Clone this repository seems not enough. What additional Software do I need? [Edit] Solved - It works if I use python3 smartcrypto.py
  2. According to the README.md I have to use the last line in smartcrypto.py but I do not understand how a command line should look like

Mannshoch avatar Mar 06 '20 09:03 Mannshoch

I played around with the smartcrypto.py script. At moment I use this script to be able to send Keys to the TV:

python3 .\tv.py KEY_VOLDOWN

#!/usr/bin/env python3

from __future__ import print_function
import crypto
import sys
import re
from command_encryption import AESCipher
import requests
import time
import websocket
import argparse

parser = argparse.ArgumentParser(description='Gib dem TV Befehle')
parser.add_argument("key", help='befehle an den TV')
args = parser.parse_args()


UserId = "xxxxxx"
AppId = "xxxxxx"
deviceId =  "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
tvIP = "xxx.xxx.xxx.xxx"
tvPort = "xxxx"
ctx = "xxxxxx"
session_id = "1xxxxxxx"
key_command = args.key

def send_command(session_id, ctx, key_command):
    ctx = ctx.upper()

    millis = int(round(time.time() * 1000))
    step4_url = 'http://' + tvIP + ':8000/socket.io/1/?t=' + str(millis)
    websocket_response = requests.get(step4_url)
    websocket_url = 'ws://' + tvIP + ':8000/socket.io/1/websocket/' + websocket_response.text.split(':')[0]
    print(websocket_url)

    aesLib = AESCipher(ctx, session_id)
    connection = websocket.create_connection(websocket_url)
    time.sleep(0.35)
    # need sleeps cuz if you send commands to quick it fails
    connection.send('1::/com.samsung.companion')
    # pairs to this app with this command.
    time.sleep(0.35)

    connection.send(aesLib.generate_command(key_command))
    time.sleep(0.35)

    connection.close()

print('Attempting to send command ' + args.key + ' to tv')
send_command(session_id, ctx, args.key)

Mannshoch avatar Aug 06 '20 12:08 Mannshoch