Code:
C:\Users\john> bashjohn@john-pc:/mnt/c/Users/john$
Code:
sudo apt-get install duplicity
Code:
duplicity /mnt/c/Users/john/data/ file:///mnt/d/backup_john_data/
Code:
Local and Remote metadata are synchronized, no sync needed.Last full backup date: noneGnuPG passphrase:Retype passphrase to confirm:No signatures found, switching to full backup.--------------[ Backup Statistics ]--------------StartTime 1625233987.10 (Fri Jul 2 15:53:07 2021)EndTime 1625233987.45 (Fri Jul 2 15:53:07 2021)ElapsedTime 0.35 (0.35 seconds)SourceFiles 4SourceFileSize 8566184 (8.17 MB)NewFiles 4NewFileSize 8566184 (8.17 MB)DeletedFiles 0ChangedFiles 0ChangedFileSize 0 (0 bytes)ChangedDeltaSize 0 (0 bytes)DeltaEntries 4RawDeltaSize 8565672 (8.17 MB)TotalDestinationSizeChange 8587856 (8.19 MB)Errors 0-------------------------------------------------
Code:
duplicity restore file:///mnt/d/backup_john_data/ /mnt/c/Users/john/data_restored/
Code:
Local and Remote metadata are synchronized, no sync needed.Last full backup date: Fri Jul 2 15:53:00 2021GnuPG passphrase:
Code:
duplicity --volsize 700 /mnt/c/Users/john/data/ file:///mnt/d/backup_john_data/
Statistics: Posted by fips — Fri Jul 02, 2021 3:16 pm
Statistics: Posted by ganxtr — Sun Nov 10, 2019 7:25 am
Statistics: Posted by fips — Sun Sep 29, 2019 9:10 pm
Statistics: Posted by AlieLeite — Fri Oct 12, 2018 5:07 pm
Code:
import base64baseURL = 'http://127.0.0.1:8080/json.htm?type=command¶m=udevice&nvalue=0'username='<username>'password='<password>'def domoticzrequest (url): base64string = base64.encodestring('%s:%s' % (username, password)).replace('\n', '') request = urllib2.Request(url) request.add_header("Authorization", "Basic %s" % base64string) response = urllib2.urlopen(request) print response.read() return None;
Statistics: Posted by viriathus — Mon May 28, 2018 9:28 pm
Statistics: Posted by fips — Mon May 28, 2018 8:06 pm
Statistics: Posted by viriathus — Mon May 28, 2018 2:35 am
Code:
<img src="image.jpg" srcset="image@150.jpg 1.5x, image@200.jpg 2x">
Statistics: Posted by fips — Sun May 27, 2018 11:49 am
Code:
$ pip install esptool
Code:
Collecting esptool Downloading https://files.pythonhosted.org/packages/cd/68/c28961d88cf50ca6d5de5e4b354dc47f77b9e74d4cd4d5bee4feaa7963b3/esptool-2.3.1.tar.gz (72kB) 100% |################################| 81kB 744kB/sRequirement already satisfied: pyserial>=2.5 in c:\dev_tools\python27\lib\site-packages (from esptool)Collecting pyaes (from esptool) Downloading https://files.pythonhosted.org/packages/44/66/2c17bae31c906613795711fc78045c285048168919ace2220daa372c7d72/pyaes-1.6.1.tar.gzCollecting ecdsa (from esptool) Downloading https://files.pythonhosted.org/packages/63/f4/73669d51825516ce8c43b816c0a6b64cd6eb71d08b99820c00792cb42222/ecdsa-0.13-py2.py3-none-any.whl (86kB) 100% |################################| 92kB 1.4MB/sInstalling collected packages: pyaes, ecdsa, esptool Running setup.py install for pyaes ... done Running setup.py install for esptool ... doneSuccessfully installed ecdsa-0.13 esptool-2.3.1 pyaes-1.6.1
Code:
$ esptool.py --chip esp32 --port COM3 write_flash -z 0x1000 esp32-20180414-v1.9.3-548-gd12483d9.bin
Code:
esptool.py v2.3.1Connecting........___Chip is ESP32D0WDQ6 (revision 1)Features: WiFi, BT, Dual CoreUploading stub...Running stub...Stub running...Configuring flash size...Auto-detected Flash size: 4MBCompressed 973584 bytes to 604211...Wrote 973584 bytes (604211 compressed) at 0x00001000 in 54.0 seconds (effective 144.2 kbit/s)...Hash of data verified.Leaving...Hard resetting via RTS pin...
Code:
>>> help('modules')
Code:
__main__ flashbdev random uos_boot framebuf re upip_onewire gc select upip_utarfile_thread hashlib socket upyshapa106 heapq ssl urandomarray inisetup struct urebinascii io sys urequestsbtree json time uselectbuiltins machine ubinascii usocketcmath math ucollections usslcollections micropython uctypes ustructdht neopixel uerrno utimeds18x20 network uhashlib utimeqerrno ntptime uheapq uzlibesp onewire uio websocketesp32 os ujson zlibPlus any modules on the filesystem
Code:
>>> import machine>>> i2c = machine.I2C(scl=machine.Pin(4), sda=machine.Pin(5))>>> i2c.scan()[60]
Code:
$ pip install adafruit-ampy
Code:
Collecting adafruit-ampy Using cached adafruit-ampy-1.0.3.tar.gzRequirement already up-to-date: click in c:\dev_tools\python27\lib\site-packages (from adafruit-ampy)Collecting pyserial (from adafruit-ampy) Using cached pyserial-3.4-py2.py3-none-any.whlInstalling collected packages: pyserial, adafruit-ampy Found existing installation: pyserial 3.2.1 Uninstalling pyserial-3.2.1: Successfully uninstalled pyserial-3.2.1 Running setup.py install for adafruit-ampy ... doneSuccessfully installed adafruit-ampy-1.0.3 pyserial-3.4
Code:
$ ampy --port COM3 put ssd1306.py
Code:
>>> import os>>> os.listdir()['boot.py', 'ssd1306.py']
Code:
>>> import machine, ssd1306>>> i2c = machine.I2C(scl=machine.Pin(4), sda=machine.Pin(5))>>> oled = ssd1306.SSD1306_I2C(128, 64, i2c, 60)>>> oled.fill(0)>>> oled.text("Hello World!", 0, 0)>>> oled.show()
Statistics: Posted by fips — Tue Apr 17, 2018 8:50 pm
Code:
{ "status" : "OK", "title" : "Update Device"}
Statistics: Posted by Flo00719 — Wed Apr 11, 2018 8:24 pm
Code:
http://192.168.1.24:8080/json.htm?type=command¶m=udevice&nvalue=0&idx=28&svalue=123;456
Code:
{ "status" : "OK", "title" : "Update Device"}
Statistics: Posted by fips — Tue Apr 10, 2018 9:21 pm
Code:
for (uint8_t i = 255; i-- > 0;) { OCR0A = i; _delay_ms(4);}
Statistics: Posted by fips — Tue Apr 10, 2018 9:02 pm
Code:
#ifndef F_CPU#define F_CPU 8000000UL // 8 MHz clock speed#endif#include <avr/io.h>//#include <avr/interrupt.h>#include <util/delay.h>int main(void){ DDRB |= 1 << PB2; TCCR0A |= (1<<WGM00)|(1<<COM0A1); TCCR0B |= (1<<WGM02)|(1<<CS00); while(1){ for (uint8_t i = 0; i < 255; i++) { OCR0A = i; _delay_ms(4); } for (uint8_t i = 255; i >= 0; i--) { OCR0A = i; _delay_ms(4); } }}
Statistics: Posted by Fankun — Tue Apr 10, 2018 3:00 am
Code:
python /home/pi/domoticz/scripts/python/test.py
I have an error 401. I am short of idea but thanks for the helpStatistics: Posted by Flo00719 — Mon Apr 09, 2018 3:17 pm
Code:
Sent: {"emeter":{"get_realtime":{}}}Received:{ "emeter": { "get_realtime": { "current": 0.050626, "err_code": 0, "power": 5.156992, "total": 47.638, "voltage": 239.229237 } }}5.156992 47638.0
Statistics: Posted by fips — Fri Apr 06, 2018 8:34 pm
Code:
(error(110, 'connection timed out') ,)
Statistics: Posted by Flo00719 — Fri Apr 06, 2018 5:08 pm
Code:
except urllib2.URLError, e: print e.code
With this:Code:
except urllib2.HTTPError, e: print e.codeexcept urllib2.URLError, e: print e.args
Statistics: Posted by fips — Fri Apr 06, 2018 3:02 pm
Code:
Traceback (most recent call last): File "/home/pi/domoticz/scripts/python/test.py", line 74, in <module> print e.codeAttributeError: 'URLError' object has no attribute 'code'
And here I admit that I'm blocking.Statistics: Posted by Flo00719 — Fri Apr 06, 2018 2:13 pm
Code:
python /home/pi/domoticz/scripts/python/test.py
If there are no errors it means Domoticz has received the HTTP request and it should show current consumption info or print an error to the log.Statistics: Posted by fips — Thu Apr 05, 2018 10:43 pm
Code:
#!/usr/bin/env python# # TP-Link Wi-Fi Smart Plug Protocol Client# For use with TP-Link HS110: energy monitor# # Gets current power (W) and cumulative energy (kWh)# and sends to Domoticzimport socketimport argparseimport jsonimport urllibimport urllib2# ip, port, and command for HS110ip = '192.168.1.29'port = 9999cmd = '{"emeter":{"get_realtime":{}}}'# Domoticz command stub and IDx of HS110baseURL = 'http://192.168.1.24:8080/json.htm?type=command¶m=udevice&nvalue=0'HSIdx = 28# Encryption and Decryption of TP-Link Smart Home Protocol# XOR Autokey Cipher with starting key = 171def encrypt(string):key = 171result = "\0\0\0\0"for i in string: a = key ^ ord(i)key = aresult += chr(a)return resultdef decrypt(string):key = 171 result = ""for i in string: a = key ^ ord(i)key = ord(i) result += chr(a)return resultdef domoticzrequest (url): request = urllib2.Request(url)# request.add_header("Authorization", "Basic %s" % base64string) response = urllib2.urlopen(request) return None;# Send command and receive reply try:sock_tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)sock_tcp.connect((ip, port))sock_tcp.send(encrypt(cmd))data = sock_tcp.recv(2048)sock_tcp.close()#print "Sent: ", cmdresult = decrypt(data[4:])jsonData = json.loads(result)#print "Received: "#print json.dumps(jsonData, indent=4, sort_keys=True)power = jsonData['emeter']['get_realtime']['power']total = jsonData['emeter']['get_realtime']['total'] * 1000#print power, totalexcept socket.error:quit("Cound not connect to host " + ip + ":" + str(port))# Send data to Domoticztry: url = baseURL + "&idx=%s&svalue=%s;%s" % (HSIdx, power, total) domoticzrequest(url)except urllib2.URLError, e:print e.code
Code:
crontab -e*/5**** sudo python /home/pi/domoticz/scripts/python/test.py >/dev/null 2>&1
Statistics: Posted by Flo00719 — Thu Apr 05, 2018 3:59 pm
Statistics: Posted by fips — Wed Apr 04, 2018 9:59 pm
Statistics: Posted by Flo00719 — Wed Apr 04, 2018 8:44 pm
Code:
// [CODE BY FIPS @ 4FIPS.COM, (c) 2018 FILIP STOKLAS, MIT-LICENSED]typedef struct my_buf_c_s { const uint8_t *data; size_t size;} my_buf_c;typedef struct my_buf_s { union { struct { uint8_t *data; size_t size; }; my_buf_c const_view; };} my_buf;#define MY_CONST_CAST(ptr) (&(ptr)->const_view)void my_buf___mutable_func(my_buf *buf) { buf->data[0] = 5; // OK: read-write location 'uint8_t *data' buf->data = NULL; // OK: read-write object 'uint8_t *data' buf->size = 0; // OK: read-write object 'size_t size'}void my_buf___constant_func(const my_buf_c *buf) { buf->data[0] = 5; // error: read-only location 'const uint8_t *const data' buf->data = NULL; // error: read-only object 'const uint8_t *const data' buf->size = 3; // error: read-only object 'const size_t size'}int main() { uint8_t tmp[] = { 0, 1, 2 }; my_buf buf = { .data = tmp, .size=3 }; my_buf___constant_func(&buf); // error: expected 'const my_buf_c *' my_buf___constant_func(MY_CONST_CAST(&buf)); // OK my_buf___mutable_func(&buf); // OK return 0;}
Statistics: Posted by fips — Fri Mar 09, 2018 9:47 pm
Code:
$ sudo nano /etc/modules
Code:
# /etc/modules: kernel modules to load at boot time.## This file contains the names of kernel modules that should be loaded# at boot time, one per line. Lines beginning with "#" are ignored.i2c-devuinput
Code:
$ sudo pip install python-uinput
Code:
#!/usr/bin/env python#[ROTKEY BY FIPS @ 4FIPS.COM, (c) 2018 FILIP STOKLAS, MIT-LICENSED]import RPi.GPIO as GPIOimport uinputfrom time import sleeppin_a = 11 # GPIO 17pin_b = 13 # GPIO 27GPIO.setmode(GPIO.BOARD)GPIO.setup(pin_a, GPIO.IN)GPIO.setup(pin_b, GPIO.IN)device = uinput.Device([uinput.KEY_UP, uinput.KEY_DOWN])seq_a = seq_b = 0def on_edge(pin): global seq_a, seq_b a = GPIO.input(pin_a) b = GPIO.input(pin_b) seq_a = ((seq_a << 1) | a) & 0b1111 seq_b = ((seq_b << 1) | b) & 0b1111 if seq_a == 0b0011 and seq_b == 0b1001: device.emit_click(uinput.KEY_UP) elif seq_a == 0b1001 and seq_b == 0b0011: device.emit_click(uinput.KEY_DOWN)GPIO.add_event_detect(pin_a, GPIO.BOTH, callback=on_edge)GPIO.add_event_detect(pin_b, GPIO.BOTH, callback=on_edge)try: while True: sleep(3600)except KeyboardInterrupt: print("...DONE") GPIO.cleanup()
Statistics: Posted by fips — Sat Feb 03, 2018 4:44 pm