laz- / bestintcp

Home Assistant code for Bestin IoT panel system (wallpad?)
BSD 2-Clause "Simplified" License
5 stars 1 forks source link

I have a trouble to apply this module #1

Open chongjae opened 4 years ago

chongjae commented 4 years ago

I setup this module for control bestin.

**Invalid config The following integrations and platforms could not be set up:

bestintcp Please check your config.**

But i have a exception. I just try to install and setup by guide line. Thnaks.

laz- commented 4 years ago

There is probably an exception earlier in the log that should point in the right direction.

Can you find other lines that mention bestintcp?

chongjae commented 4 years ago

bestintcp: host: 10.1.3.1 port: 10000 rooms: living 1 2 3 4 5

I just typing above on last line in configuration.yaml. pi@raspberrypi:~ $ ping 10.1.3.1 PING 10.1.3.1 (10.1.3.1) 56(84) bytes of data. 64 bytes from 10.1.3.1: icmp_seq=1 ttl=64 time=0.812 ms

ping test also successed. Is there other setup for this situation?

laz- commented 4 years ago

That setup looks OK, though your room config may be different than mine? The "living" room is a special case for a set of lights that you may not have.

Try "rooms: 1" and see if it works OK, and then add more rooms?

Since it's still early in development, I haven't spent time making the code catch errors or hardening it against responses it doesn't expect.

chongjae commented 4 years ago

Thank you for your quick response. How could you develop this module? Can I develop it together?

Also, https://github.com/laz-/bestintcp/blob/master/bestintcp.py#L193 It looks ip address is fixed..

Traceback (most recent call last):, File "/usr/src/homeassistant/homeassistant/setup.py", line 175, in _async_setup_component, component.setup, hass, processed_config # type: ignore, File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run, result = self.fn(*self.args, **self.kwargs), File "/config/custom_components/bestintcp/init.py", line 39, in setup, rooms.append(BestinRoom(name, btcp)), File "/config/custom_components/bestintcp/init.py", line 168, in init, self.fetchLightsStatus(), File "/config/custom_components/bestintcp/init.py", line 222, in fetchLightsStatus, response = self.tcp.XMLRequest(reqname, 'status', dev_num=dev_num), File "/config/custom_components/bestintcp/init.py", line 140, in XMLRequest, return self.request(request), File "/config/custom_components/bestintcp/init.py", line 109, in request, mysocket.connect((self.host, self.port)), ConnectionRefusedError: [Errno 111] Connection refused,

chongjae commented 4 years ago

I checked more, First of all, Is it correct fixed ip address? Second, sudo nmap -sU tablet's ip -p 10000 PORT STATE SERVICE 10000/udp closed ndmp MAC Address: 00:0A:01:03:01:00 (Sohoware)

port is closed. How could you know tablet's port number?

laz- commented 4 years ago

Do you have the IPark app on your phone?

If you "tcpdump -i br0 -v -s 0 host 10.1.3.1" you should see traffic on the bridge to that IP. Or instead of "host 10.1.3.1" try "port 10000" to look for the XMLoverTCP protocol to possibly another host. When the IPark app talks, it should forward requests into the tablet.

laz- commented 4 years ago

The IP address hardcoded in the module is only used if you call bestintcp.py on the commandline outside of home assistant (like "python3 bestintcp.py"). I'll probably expand this to dump info from a tablet.

chongjae commented 4 years ago

I Success to just remove error by checking by nmap. namp shows that 10002 port is opened on tablet. But... 2020-07-16 11:39:01 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform bestintcp.climate: Platform not found (cannot import name 'ClimateEntity' from 'homeassistant.components.climate' (/usr/src/homeassistant/homeassistant/components/climate/init.py))., 2020-07-16 11:39:01 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform bestintcp.switch: Platform not found (cannot import name 'SwitchEntity' from 'homeassistant.components.switch' (/usr/src/homeassistant/homeassistant/components/switch/init.py))., 2020-07-16 11:39:01 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform bestintcp.light: Platform not found (cannot import name 'LightEntity' from 'homeassistant.components.light' (/usr/src/homeassistant/homeassistant/components/light/init.py)).,

I still have problems. Thank you for your assist. I'll try more!

chongjae commented 4 years ago

Do you have the IPark app on your phone?

If you "tcpdump -i br0 -v -s 0 host 10.1.3.1" you should see traffic on the bridge to that IP. Or instead of "host 10.1.3.1" try "port 10000" to look for the XMLoverTCP protocol to possibly another host. When the IPark app talks, it should forward requests into the tablet.

Currently, I can not control light by app... I think i success to brigde eth0, eth1..But, All of H.N control is disable..

laz- commented 4 years ago

ahh weird. what version home assistant are you running?

I was developing against 0.112, which introduced ClimateEntity instead of Climate, and LightEntity instead of Light. They should be safe to just remove the Entity part of the name (and in 0.112 you'll get a warning).

chongjae commented 4 years ago

ahh weird. what version home assistant are you running?

I was developing against 0.112, which introduced ClimateEntity instead of Climate, and LightEntity instead of Light. They should be safe to just remove the Entity part of the name (and in 0.112 you'll get a warning).

I using HA on docker.

io.hass.arch armv7
io.hass.base.image homeassistant/{arch}-base-python
io.hass.base.name python
io.hass.base.version 15.1.1
io.hass.machine raspberrypi3
io.hass.type core
io.hass.version 0.109.0.dev20200412

I solved this problem by remove "Entity" Although 2020-07-16 12:25:16 INFO (MainThread) [custom_components.bestintcp.light] BestinRoom(name="living", lights={}, outlets={}, temperature=None), 2020-07-16 12:25:16 INFO (MainThread) [custom_components.bestintcp.light] BestinRoom(name="1", lights={}, outlets={}, temperature=None), No lights....

Also, I using (https://play.google.com/store/apps/details?id=com.mobiletalk.valley) App. After connect to bridge, I can not control light,climate and etc. Can you still using app?

laz- commented 4 years ago

If you can't control it with the app that's bad. That means the bridge isn't forwarding.

You may need to add "net.ipv4.ip_forward = 1" to /etc/sysctl.conf

laz- commented 4 years ago

That will apply at boot. If you run "sysctl -w net.ipv4.ip_forward = 1" then it'll apply while it's running :)

On Thu, Jul 16, 2020 at 12:55 adam lazur adam@lazur.org wrote:

If you can't control it with the app that's bad. That means the bridge isn't forwarding.

You may need to add "net.ipv4.ip_forward = 1" to /etc/sysctl.conf

chongjae commented 4 years ago

Thank you for your help. Forwarding also looks working.. 2020-07-16 12:25:16 INFO (MainThread) [custom_components.bestintcp.light] BestinRoom(name="living", lights={}, outlets={}, temperature=None), 2020-07-16 12:25:16 INFO (MainThread) [custom_components.bestintcp.light] BestinRoom(name="1", lights={}, outlets={}, temperature=None), Now, I try to read light!

laz- commented 4 years ago

Is this on port 10002?

I haven't looked at any network traffic there. If you capture some mobile app traffic with tcpdump we can try to figure out what the protocol is.

On Thu, Jul 16, 2020 at 14:31 chongjae notifications@github.com wrote:

Thank you for your help. Forwarding also looks working.. 2020-07-16 12:25:16 INFO (MainThread) [custom_components.bestintcp.light] BestinRoom(name="living", lights={}, outlets={}, temperature=None), 2020-07-16 12:25:16 INFO (MainThread) [custom_components.bestintcp.light] BestinRoom(name="1", lights={}, outlets={}, temperature=None), Now, I try to read light!

— You are receiving this because you were assigned.

Reply to this email directly, view it on GitHub https://github.com/laz-/bestintcp/issues/1#issuecomment-659168499, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAC36WTDKHFDNCJDFTMO54LR32GCBANCNFSM4O3JA3SA .

chongjae commented 4 years ago

Is this on port 10002? I haven't looked at any network traffic there. If you capture some mobile app traffic with tcpdump we can try to figure out what the protocol is. On Thu, Jul 16, 2020 at 14:31 chongjae @.***> wrote: Thank you for your help. Forwarding also looks working.. 2020-07-16 12:25:16 INFO (MainThread) [custom_components.bestintcp.light] BestinRoom(name="living", lights={}, outlets={}, temperature=None), 2020-07-16 12:25:16 INFO (MainThread) [custom_components.bestintcp.light] BestinRoom(name="1", lights={}, outlets={}, temperature=None), Now, I try to read light! — You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/laz-/bestintcp/issues/1#issuecomment-659168499, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAC36WTDKHFDNCJDFTMO54LR32GCBANCNFSM4O3JA3SA .

Sadly, My pi server is shut-down........T.T... When i return to home, i can re-boot my pi and try to catch more. The results I've done till the end, My port number is 10002 not 10000. Also, Only 10002 port is opened. But, When using tcpdump, other port is detected. So, I should more check the pattern. Thank you for quick response Glad to meet you.

laz- commented 4 years ago

I'm using this iphone app: https://apps.apple.com/kr/app/bestin-ipark/id837607895

Hopefully we can figure out the protocol on 10002 once you capture some traffic :)

chongjae commented 4 years ago

Is this on port 10002? I haven't looked at any network traffic there. If you capture some mobile app traffic with tcpdump we can try to figure out what the protocol is. On Thu, Jul 16, 2020 at 14:31 chongjae @.***> wrote: Thank you for your help. Forwarding also looks working.. 2020-07-16 12:25:16 INFO (MainThread) [custom_components.bestintcp.light] BestinRoom(name="living", lights={}, outlets={}, temperature=None), 2020-07-16 12:25:16 INFO (MainThread) [custom_components.bestintcp.light] BestinRoom(name="1", lights={}, outlets={}, temperature=None), Now, I try to read light! — You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/laz-/bestintcp/issues/1#issuecomment-659168499, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAC36WTDKHFDNCJDFTMO54LR32GCBANCNFSM4O3JA3SA .

I check ports... But..........There are so-------many port that using for control light. I have 5 rooms divided by smart phone app. and, When start list up all lights and status, total 213 packets are captured. 10.0.1.1 to 10.1.3.1:11000(Tablet) 40740 40748 40756 40770 40772 40780 40788 40804 40806 40814

And..There are specific ports like below

10.0.1.1.domain > 10.1.3.1.10148: 64814 NXDomain- 0/1/0 (89) 10.0.1.1.domain > 10.1.3.1.16104: 55478 NXDomain- 0/1/0 (89) 10.0.1.1.domain > 10.1.3.1.17094: 51722 NXDomain- 0/1/0 (89) 10.0.1.1.domain > 10.1.3.1.18950: 42478 NXDomain- 0/1/0 (89) 10.0.1.1.domain > 10.1.3.1.42377: 42760 NXDomain- 0/1/0 (89) 10.0.1.1.domain > 10.1.3.1.47916: 6346 NXDomain- 0/1/0 (89) 10.0.1.1.domain > 10.1.3.1.55005: 64629 NXDomain- 0/1/0 (89) 10.0.1.1.domain > 10.1.3.1.5614: 60478 NXDomain- 0/1/0 (89) 10.0.1.1.domain > 10.1.3.1.65165: 31595 NXDomain- 0/1/0 (89) 10.0.1.1.domain > 10.1.3.1.9879: 15458 NXDomain- 0/1/0 (89)

How can i test turn on/off lights by shell?

laz- commented 4 years ago

The source ports changing is normal. They're just new ephemeral ports as the gateway picks a free one to use.

To try out a request: 1) open the network capture in wireshark 2) add a filter "ip.addr == 10.1.3.1 and tcp" then find a tcp session 3) right click on a packet in a session, and click "follow > tcp stream" and it'll pull up an ascii buffer of both sides of the stream

If it's the XML protocol it's pretty simple and there should be some abbreviated english words in it. If you put the request text into a file, you can replay it:

cat request.txt | nc 10.1.3.1 11000

chongjae commented 4 years ago

The source ports changing is normal. They're just new ephemeral ports as the gateway picks a free one to use. To try out a request: 1) open the network capture in wireshark 2) add a filter "ip.addr == 10.1.3.1 and tcp" then find a tcp session 3) right click on a packet in a session, and click "follow > tcp stream" and it'll pull up an ascii buffer of both sides of the stream If it's the XML protocol it's pretty simple and there should be some abbreviated english words in it. If you put the request text into a file, you can replay it: cat request.txt | nc 10.1.3.1 11000

For analyze packets, I try to capture tcpdump on pi and save data. And move to the data on my window pc. Then, Load the data on wireshark. Sadly, It shows below...

.............8f.....6...".................. ...^..ezy....\:.m..x......W..)8.&./.0.+.,....... ... ...../.5... .........{.......... . ................. ......................................+. ..........3.&.$... .-.h.....:>l-&cl.3QW.5}F.H.P...8....F...BA..R.$.x....I..b.....b..MrL.i .YVu....ES.u...2z!.!........H.3...?[..........@(5...b.y..{..o.l[Z....1.>m....}....#IcMLS..Bd. =J..N..t..Mr..I..........]Q.....W...3l1..6...T}`..B..}>.0....$...j.. ..*.Ka]..."..w}..M.di@..1..%8.N.-..~H..+...:^.R.I.k..#J.H.t..@.NP.2K.....T.X:[.....yc=....r..9.0.'.M...A%{.......T....[..J.........+.A....w...b../x..]T.((.<&..h..,..q.Y~.%.x3S.......E}.......l1:YD+'....Bw....<.t.E.A..Y....P..d.F....PtYO$....1...L..l........;..4.X..{......q. @{GEy...=..y.........VXW.........j.m....l...l>.?2.#.?q.....,..7kW.... .'B.].)......a?...8L....R.5#.?E ....4?.g..FJf...q.....vu..X5j..b..q.8/2.................rD.....O....f.

It looks not XML protocol. image

laz- commented 4 years ago

Hmm. That's definitely not XML.

Is this port 10002 traffic?

chongjae commented 4 years ago

Hmm. That's definitely not XML. Is this port 10002 traffic?

sudo tcpdump -i eth0 -w test.pcap

I captured all of eth0 port's packet.

sudo tcpdump -i br0 -v -s 0 host 10.1.3.1 -w test2.pcap Above result also same.

chongjae commented 4 years ago

I study more about... My bestin network using TLS handshake for security...T.T Maybe...I can't control bestin home network.. Thanks..

laz- commented 4 years ago

Ahhhh. Perhaps there's an option in the developer menu to enable the plain text protocol?

chongjae commented 4 years ago

Ahhhh. Perhaps there's an option in the developer menu to enable the plain text protocol?

Oh? You mean tablet has the option? I try to check that.. But...packets are show that TCL protocol. I think TCL protocol has strong security.

chongjae commented 4 years ago

Ahhhh. Perhaps there's an option in the developer menu to enable the plain text protocol?

Long time no see, I try to find plain text protocol option. Sadly, I have no option for disable encryption. :( Is there any update for bestintcp?

chongjae commented 3 years ago

Ahhhh. Perhaps there's an option in the developer menu to enable the plain text protocol?

Hello, Is there any update on Bestin 2.0 protocol? Also, I share useful documents for tcp hacking. https://cafe.naver.com/stsmarthome/26797