Wednesday, 7 March 2018

How to install Home Assistant on Synology DS216j


This week, I have spent quite some time to setup Home Assistant on my Synology DS216j. 

I have several smart home devices, however, they don't talk to each other... Nest thermostat, Almond+ router, GE smart LED, Google home mini, iPhone, envisalinks 3 (the security system), logitech harmony control, nexus player, Nvidia Shield TV, TP-Link smart plugs... Always try to find a way to control them in a central place. 

Among all the devices, envisalinks 3 is hard to work with the rest of the system. It is said Samsung smartthings can work with envisalinks. However, I don't want to spend $120+tax for another smart hub.

Home Assistant, which is developed in Python, open source, seems to be a good candidate to aggregate all my devices. And here is my guide:


How to install on Synology NAS

need to pip3 install home-assistant-frontend, pyenvisalink, pyfttt, python-nest
install modules in

 

Install Netdisco and other packages with dependency issue on Synology NAS

Install Debian Chroot from SynoCommunity

SSH into Synology DiskStation. Use this command to go into chroot: /var/packages/debian-chroot/scripts/start-stop-status chroot

cd /usr/bin/

I prefer nano which was thankfully available but vi should do the job (vim was not available).
nano /etc/apt/sources.list
Change all “jessie” sources to “stretch”. Thats it, no messing around with preferences.

Installing python and pip:
  1. apt-get update
  2. apt-get install libpython3.5-dev
  3. apt-get install python3.5
  4. apt-get install python3-pip (note: no 3.5)

Install netdisco: python3.5 -m pip install netdisco
install warrant: python3.5 -m pip install warrant
install warrant: python3.5 -m pip install HAP-pythonexit

Get back to the DS SSH with: exit

Copy all packages:
cd /volume2/@appstore/py3k/usr/local/lib/python3.5/site-packages/
cp /usr/local/debian-chroot/var/chroottarget//usr/local/lib/python3.5/dist-packages/* . -R

Restart home assistant /volume1/homeassistant/hass-daemon restart (assuming that’s where you put it).


Setup IFTTT Envisalinks

setup on nas https reverse proxy on synology using web UI, so that all communications are in SSL. So port 8443 will be used as my SSL port. I used 8443 as 443 port has been used on my synology. Any valid port number should be fine.
https 8443 -> http local host 8123

To arm the security system, in IFTTT, setup gadget using webhooks to post to Home assistant server. So I can use voice command from Google home to control my security system:
Arm stay
https://xiezhensheng.synology.me:8443/api/services/alarm_control_panel/alarm_arm_home?api_password=xxxxxxxx
Arm away
http://192.168.0.8:8123/api/services/alarm_control_panel/alarm_arm_home?api_password=xxxxxxxx post
entity_id:alarm_control_panel.home_alarm

I haven't setup disarm yet. When I am going to use it?

Setup Auto Start

Q&A

How to find services of Home Assistant?
use ARC chrome extension, GET /api/services

How to find entity_id to fill the webhook post section?
in developer tool <> section

Friday, 7 March 2014

Avoid Samsung's Fingerprint Payment system


Paypal says Samsung fingerprint payments 'very secure' : "The important thing about this announcement is that none of your biometric data is stored on that phone.
"It's not storing your fingerprints locally. It takes your fingerprint, encrypts it, sends it to PayPal, they decrypt it, checks it's the same, and then you're authenticated. It's very, very secure."
Well, I think this is a very dangerous method!! Samsung's implementation is fundamentally flawed. i) 3rd party keeps your un-encrypted biometric info ii) encryption key leakage from 3rd party or Samsung iii) local hardware hack, if there is no specifical chip handle the scan and encryption directly (I don't see it right now) iv) android system's security...

Further research shows: 
The inside story is that Samsung is the first smartphone maker to deploy a fingerprint sensor that uses the new FIDO Alliance authentication standard (FIDO stands for Fast IDentity Online).
The FIDO Alliance is based on the simple idea that a user can authenticate to their own device and then use public key encryption to authenticate to the network. PKE is very strong encryption (though NSA shenanigans have raised concern about back doors) and, like Apple’s scheme, does not involve biometric data itself residing in the cloud.


Ok, sounds better now. It seems the security flaw in theory could only happen locally, on Samsung's phone. Point ii, iii & iv are still valid.

Sunday, 23 February 2014

“吸血鬼” 余额宝?

有感于余额宝在国内火爆非常,但被银行的喉舌成为吸血鬼,提高了融资成本:
真搞笑,很明显国内没有合理的投资途径,利率也很低,银行一直是储蓄的吸血鬼。
余额宝就是让大家有个低成本接触一个收益还可以的基金而已,吸血鬼们就跳出来了。

Thursday, 30 January 2014

Soft pouch for PS VITA with Hand Grip attached

So, finally a soft pouch for my PS VITA with Hand Grip attached.

Perfect size. Looks great. Low price.



Yeah, it is just a pencil case. Got it for $2 at local Dollarama. If you feel not enough protection with this pencil case, just keep the foam inside the case.












Friday, 2 August 2013

为啥开博

本来对于写博客什么的完全没兴趣。

不过有的时间发现自己的一些经验和观点无法分享,也是一个遗憾,由此发现博客还是有些用处的。