TP-Link HS110

For issues with communication ports, protocols, etc.
Dinosaur
Posts: 1358
Joined: Jul 24, 2005 1:13
Location: Hervey Bay
Contact:

Re: TP-Link HS110

Postby Dinosaur » Oct 22, 2019 3:06

Hi All

The commands I use are as follows.

Code: Select all

pen pipe "nmcli dev wifi" For Input As #PF                         'prints out all wifi's found
    Do Until Eof(PF)
        Line Input #PF, Chrs
        s += Chrs
    Loop
    Close #PF
    NetDevice(Control.Device).RxData = s
    If Control.PrintFlag > 0 Then Print s
This produces the following response.

Code: Select all

*  SSID                         MODE   CHAN  RATE       SIGNAL  BARS  SECURITY
   ATTwTC86jA                   Infra  1     54 Mbit/s  100     ▂▄▆█  WPA2
   TP-LINK_Smart Plug_7989      Infra  1     54 Mbit/s  100     ▂▄▆█  --
   TP-Link_CE38_5G              Infra  157   54 Mbit/s  100     ▂▄▆█  WPA1 WPA2

Found one, Please Wait
It does not matter what the response looks like, as long as the word "TP-LINK_Smart Plug_???? is in there.
The software will then pick the detail.

Regards
andykmv
Posts: 52
Joined: Feb 12, 2015 9:50

Re: TP-Link HS110

Postby andykmv » Oct 24, 2019 7:22

ok, i could setup the #IFDEF __FB_LINUX__ around your code segment,

then use #IFDEF __FB_WIN64__ around new code including the "netsh wlan show networks" command &massage output into nmcli output format

then put the resulting data back into the relevant variable to continue processing with your code. should work.
MrSwiss
Posts: 3635
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: TP-Link HS110

Postby MrSwiss » Oct 24, 2019 12:58

Sorry, but it won't work because:
#IFDEF __FB_WIN64__ not existing! currently, in the compiler,

you'll have to use:
either: #IFDEF __FB_WIN32__ (testing for WIN, any bitness) or:
#IFDEF __FB_64BIT__ (testing for FBC 64)
to make your preprocessor code working correctly.
andykmv
Posts: 52
Joined: Feb 12, 2015 9:50

Re: TP-Link HS110

Postby andykmv » Oct 25, 2019 1:37

MrSwiss wrote:Sorry, but it won't work because:
#IFDEF __FB_WIN64__ not existing! currently, in the compiler,

you'll have to use:
either: #IFDEF __FB_WIN32__ (testing for WIN, any bitness) or:
#IFDEF __FB_64BIT__ (testing for FBC 64)
to make your preprocessor code working correctly.


thanks for the tip!
Dinosaur
Posts: 1358
Joined: Jul 24, 2005 1:13
Location: Hervey Bay
Contact:

Re: TP-Link HS110

Postby Dinosaur » Nov 01, 2019 19:31

Hi All

Have done a lot of work integrating the smart bulb in the same code.
Works very well, I can now turn my lounge room into a disco (well almost)
This is using a USA version, so probably have to add functionality once I get home.

The Smart Bulb has a lot more info available, and the json strings were becoming a real problem,
so I rewrote that in the only way I know how.(Simple Step by Step)

The commands to read the devices stay as json strings, but after that I call StripRxData which operates on .RxData

Code: Select all

Sub StripRxData
    '===================================================================
    'Called from last statement in DataTxRx.
    '===================================================================
    ErrControl.Routine = "PrintRxData;"
    If Control.PrintFlag = 3 Then Print ErrControl.Routine
    Dim as Integer Cnt,Cnt2,LFcount,Colon
    Dim as String Srch,Srch2,Srch3,Srch4
    Dim Char as String * 1
    '-----------------------------------------------------------
    'First strip all the undesirables and replace commas with LF
    '-----------------------------------------------------------
    Srch = NetDevice(Control.Device).RxData
    For Cnt = 1 to Len(Srch)
        Char = Mid(Srch,Cnt,1)
        If (Char <> "{") And (Char <> "}") And (Char <> Chr(34)) And (Char <> Chr(91)) And (Char <> Chr(93)) And (Char <> Chr(9)) Then
            If Char = "," Then Char = Chr(&H0A)
            Srch2 = Srch2 + Char
        EndIf
    Next
    '-----------------------------------------------------------
    'Next put each string (upto LF) into 1 of n Reply(n)
    '-----------------------------------------------------------
    Cnt = 0
    While Cnt < Len(Srch2)
        Cnt += 1
        Char = Mid(Srch2,Cnt,1)                                  'get next chr from string
        If (Char = Chr(&H0A)) Then                               'if it is a LF
            LFcount += 1                                         'inc counter for Reply(n)
            Srch3 = Left(Srch2,Cnt)                              'put all chr's to the left into Srch3
            Reply(LFcount) = Srch3                               'if it wasn't a sysinfo command, just save it.
            Srch2 = Right(Srch2,Len(Srch2) - Cnt)                'shorten the string for next round.
            Cnt = 0                                              'set cnt to beginning of that shortened string.
        EndIf
    Wend
    '-----------------------------------------------------------
    'But the last one fell through, so add it.
    '-----------------------------------------------------------
    LFcount += 1
    Reply(LFcount) = Srch2
End Sub
Then I call Getvalue with a Srch String from within SavePlugSpec or SaveBulbSpec.(example below)

Code: Select all

    With PlugStat(Control.Device)
        .SwVer           = GetValue("system:get_sysinfo:sw_ver:")
        .HwVer           = GetValue("hw_ver:")
        .Types           = GetValue("type:")
        .Model           = GetValue("model:")
        .MAC             = GetValue("mac:")
        .DevName         = GetValue("dev_name:")
And finally the GetValue Function.

Code: Select all

Function GetValue(byref Srch as String) as string
    Dim as short Xq,Cnt
    Dim as String Repl
    For Xq = 1 to 70
        If Instr(Reply(Xq),Srch) > 0 Then                               'if Srch was found inside Reply(Xq)
            Cnt = InStr(Reply(Xq),Srch)                                 'record the location
            Repl = Mid(Reply(Xq),Cnt + Len(Srch),Len(Reply(Xq))-Cnt)    'then save starting @ Cnt + len of Srch, till the end of String
            Return Repl                                                 'Return that as the result.
        EndIf
    Next Xq
    Return "Fail"
End Function
The GUI code is all written and functional except for the implementation of schedules.

@badidea, I have been trying to get this info to you so as to avoid you spending to much time on the getJsonValue Function, but
the site being down so frequently made that difficult.

Regards
badidea
Posts: 2152
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: TP-Link HS110

Postby badidea » Nov 01, 2019 19:45

Dinosaur wrote:@badidea, I have been trying to get this info to you so as to avoid you spending to much time on the getJsonValue Function, but
the site being down so frequently made that difficult.

Don't worry; I spent exactly zero seconds on JSON since my lost post in this topic on October the 15th :-)
The only think I did (on this project) in the last 2 weeks was cleaning up my HS110 project folder. It was getting messy.
badidea
Posts: 2152
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: TP-Link HS110

Postby badidea » Nov 03, 2019 23:35

I continued with my power logger code: https://nr100.home.xs4all.nl/badidea/HS ... logger.zip
More stuff to do:
- Line plots instead of dots
- Rolling plots
- Auto-scale plots
- Test with Windows
Dinosaur
Posts: 1358
Joined: Jul 24, 2005 1:13
Location: Hervey Bay
Contact:

Re: TP-Link HS110

Postby Dinosaur » Nov 04, 2019 15:25

Hi All

I thought I would list the features of the gui so anyone interested can suggest other features.
In the next week or so I will post pictures.
It is interesting that the Plugs have about 23 fields of Info and the Bulbs 50.
Many of these are not relevant to the operation, so other then recording them and displaying
nothing more is done with them.

At startup the router is pinged and if it can't be reached a warning is shown and the program shuts down.
When the program opens it Reads setting files and Initialises any devices with a IP address
and marks all the others as 'Ignore'. These can be upto 16 Smart Plugs & 8 Smart Bulbs.
The main screen has large buttons to make it easy for a 7" screen to use your finger most of the time (150x75 pixels)
other times a stylus has to be used. The lcd I am using is 1024x600 capacative touch.
24 Led's are along the bottom that indicate the state of each device.(20 pixel diameter)

E-Stop button:
This will switch all devices off that have been set to repond to it. For example bulbs
could be left off that list.

Manual control button:
will open a screen with 24 buttons where each can be manually
switched on/off. It updates the Led's on the manual screen and the Main screen.
That screen won't open when we are in Auto run mode.

Run / Stopped Button:
Simply starts looking at the schedule and acts on it.

ToolBox button:
Opens secondary screen with:
Name Editing Button.
Restore / Backup buttons.
Setting Button to assign Device numbers to the Named areas.
Setting Button that displays 24 device buttons, each of which has extra layers.
Schedules, Feature flags,Display device info,Bulb settings with Slider adjustments
Keyboard button, Keypad etc.
Setting button to allow display and editing of all MAC & IP settings for router & devices.

Help Button:
Opens secondary screen with:
Tab window with:
About,Running,Debug,Flags,Credits
Backup, Restore, Settings, Snapshot, Errors List.

Not all the help Text has been written yet.

Login Button:
Allows a password to be entered which will gain access to settings otherwise excluded.

All ON/All OFF Button is yet to be included.

Each device (I call them Smarty's) can have 2 schedules (On/Off) per day.
The days can be selected to be excluded from the schedule.

Maybe I need to allow each day to have it's own schedule.?

You can start a schedule before or in the middle of the time frame.
Once a schedule is completed it is marked as "Done" and when the second
schedule for the day is completed, it can escape the Runmode (or Shut down).
The Led on the plugs can be left On for Night schedule, or for power saving
and the problem of attracting bugs can be turned off with the schedule.

Whilst writing this, thought that different light colors for different days may
be an option, but perhaps that is a bit over the top. However each light can
be individually tuned for it's environment.(important in some cases)

If a Smarty was marked as "Ignore" and it is powered up later, it can be enabled
by updating the Smarty state.

I have done nothing on: Power recording or Windows compatability.
@badidea , hopefully your work can be intergrated into this.
I will set up another machine with your power monitoring program
and let it run for a few days to test it.

Any constructive suggestions welcome.

Regards.
badidea
Posts: 2152
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: TP-Link HS110

Postby badidea » Nov 04, 2019 18:08

Dinosaur wrote:E-Stop button:
This will switch all devices off that have been set to repond to it. For example bulbs
could be left off that list.

E-STOP is often used for 'Emergency Stop' (normally big red buttons). Also in your case?
'Ergengy stop' over WiFi does not sound very safe, but if you only control lights then probably fine.

Dinosaur wrote: Allows a password to be entered which will gain access to settings otherwise excluded.

Consider using a hash instead of a plain text password storage (if you did not already).

Dinosaur wrote:Maybe I need to allow each day to have it's own schedule.?

Depends on opening times of the museum?
I have not yet tried the time schedule functionality of the device yet.

Dinosaur wrote:... and the problem of attracting bugs ...

No need to attract additional bugs :-)

Dinosaur wrote:Whilst writing this, thought that different light colors for different days may
be an option, but perhaps that is a bit over the top. However each light can
be individually tuned for it's environment.(important in some cases)

Depends on the type of museum? Some art gallery? Maybe not. Something for kids? Go crazy :-)
Dinosaur
Posts: 1358
Joined: Jul 24, 2005 1:13
Location: Hervey Bay
Contact:

Re: TP-Link HS110

Postby Dinosaur » Nov 04, 2019 19:08

Hi All

E-STOP is often used for 'Emergency Stop' (normally big red buttons). Also in your case?
'Ergengy stop' over WiFi does not sound very safe, but if you only control lights then probably fine.
Yes, button is Green untill pressed, then goes Red and also displays Error message in Red.
Green for GO and RED for STOP.

If a program error happens than the Error message appears in Red until it is cleared.
I guess in case of emergency it is safer to do it remote, then to have to go in there to switch things off.
Just as unsafe as switching things on in your house whilst you are on the other side of the globe.
Note that when you clear the E-Stop nothing is turned back on automatically until the Auto-Run button is pressed.

Consider using a hash instead of a plain text password storage (if you did not already).

What is a hash password ?
I have not yet tried the time schedule functionality of the device yet.
I think that may need an Internet connection. But why use a complicated protocol, when you can
simply allow the program to do the scheduling.

Regards
EDIT: I know it is already 11-05-2019 in Australia , but at the time of writing the US & Europe are still on the 4th ???
badidea
Posts: 2152
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: TP-Link HS110

Postby badidea » Nov 04, 2019 19:22

Dinosaur wrote:EDIT: I know it is already 11-05-2019 in Australia , but at the time of writing the US & Europe are still on the 4th ???

Yes, here, now: Mon 4 Nov 20:21:46 CET 2019
The earth still needs to rotate a few hours before we can call it the 5th here. We should reject all scientific evidence and go back to a flat earth (with Australia and the US almost falling off). Then we don't have these date and time differences.

BTW: "11-05-2019" would be 'May the 11th' in most of Europe. And that is certainly not the case.

Dinosaur wrote:What is a hash password ?

https://en.wikipedia.org/wiki/Cryptogra ... rification
Dinosaur
Posts: 1358
Joined: Jul 24, 2005 1:13
Location: Hervey Bay
Contact:

Re: TP-Link HS110

Postby Dinosaur » Nov 04, 2019 19:37

Hi All

BTW: "11-05-2019" would be 'May the 11th' in most of Europe.

And in Australia as well. I still have to think when I get asked for my Birthday at the Pharmacy.
I just wondered why your replies were coming in as the 5th.

Regards
MrSwiss
Posts: 3635
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: TP-Link HS110

Postby MrSwiss » Nov 05, 2019 13:53

Dinosaur wrote:And in Australia as well. I still have to think when I get asked for my Birthday at the Pharmacy.
I just wondered why your replies were coming in as the 5th.

Depends on your setup of the forum preferences (time locale/zone).
NOTE: only valid (and different) when 'logged in', as opposed to 'logged out'.
Forum time seems to be: UTC (universal time constant).
Dinosaur
Posts: 1358
Joined: Jul 24, 2005 1:13
Location: Hervey Bay
Contact:

Re: TP-Link HS110

Postby Dinosaur » Nov 05, 2019 22:54

Hi All

Depends on your setup of the forum preferences (time locale/zone).
That explains it, as mine was set up in "a land down under"

Regards
Dinosaur
Posts: 1358
Joined: Jul 24, 2005 1:13
Location: Hervey Bay
Contact:

Re: TP-Link HS110

Postby Dinosaur » Nov 06, 2019 13:34

Hi All

@badidea, dowloaded the zip and it compiles ok, but when I run it:
"Waiting for connection" and then quits with Error 141.

I could not find anywhere in the code where your IP detail is stored.
Without thoroughly reading all the code can you explain this please, so I can test it for a long duration.

Regards

Return to “Hardware Interfaces / Communication”

Who is online

Users browsing this forum: No registered users and 1 guest