Saturday, December 16, 2017

Hack to fix bug in the BLAN Homeseer plugin

For some reason a couple versions back the BLAN plugin stopped updating the value with the status of a monitored device changed. At least as far as switching the value back to on when the device comes back online. The following script looks at all the devices with location2 set to BLAN and sets the value based on the status string. I have an event set up to run it every 10 minutes.

' Hack to make Blan devices have a status value
' call from a set or value changed event
Public Sub statusBlan(ByVal refID As Object)
    Dim status As String = hs.DeviceString(refID)
    Dim oldVal = hs.DeviceValue(refID)

    If (InStr(status, "Offline") > 0) Then
        hs.SetDeviceValueByRef(refID, 0, False)
    ElseIf (InStr(status, "Online") > 0) Then
        hs.SetDeviceValueByRef(refID, 100, False)
        hs.SetDeviceValueByRef(refID, 50, False)
    End If

    Dim newVal = hs.DeviceValue(refID)

    If Not oldVal = newVal Then
        hs.WriteLog("statusBlan", "Fixed value of BLAN device " & refID & " with status of " & status & " from " & oldVal & " to " & newVal)
    End If
End Sub

Public Sub fixBlan(Parms As Object)
    Dim label As String = "fixBlan"
        Dim lowBatVal As Double = 100  'start at 100% max for low battery value
        Dim dv, dvLowBat As Scheduler.Classes.DeviceClass
        Dim EN As Scheduler.Classes.clsDeviceEnumeration = hs.GetDeviceEnumerator  'Get all devices

        If EN Is Nothing Then
            hs.WriteLog(label, "Error getting Enumerator")
            Exit Sub
        End If

        Do  'check each device that was enumerated
            dv = EN.GetNext
            If dv Is Nothing Then  'No device, so quit
                hs.WriteLog(label, "No devices found")
                Exit Sub
            End If
            'hs.WriteLog(label, "location:" & dv.Location(Nothing) & ":location2:" & dv.Location2(Nothing) & ":InStr:" & InStr(UCase(dv.Location2(Nothing)), "BLAN"))
            If InStr(UCase(dv.Location2(Nothing)), "BLAN") > 0 Then  'Only work with devices in location BLAN
                'hs.WriteLog(label, "ref:" & dv.ref(Nothing) & ":Address:" & dv.Address(Nothing) & ":value:" & dv.devValue(Nothing) & ":location:" & dv.Location(Nothing) & ":location2:" & dv.Location2(Nothing) & ":device name:" & dv.Name(Nothing) & ":type:" & dv.Device_Type_String(Nothing))
            End If
        Loop Until EN.Finished

    Catch ex As Exception
        hs.WriteLog("Error", "Exception in script " & label & ":  " & ex.Message)
    End Try
End Sub

Wednesday, December 6, 2017

Multiple hubs or all in one?

I've been seeing this question posted a lot lately as people have been taken in by the Echo Plus ads. I ususally reply with something like
The starter kit with a bridge and 2 bulbs + Echo 2 is actually cheaper than the Echo Plus. You can do way more with it and it leaves you open to add an Automation hub later without having to relink all your Hue stuff.  And a link to the article The Amazon Echo Plus Is a Horrible Smarthome Hub
(Note it looks like the V1 starter kit is getting hard to find. The V2 kit is $20 more making the total cost $20 more than the Echo Plus though you get an extra bulb so the "hub" is costing only about $10 really.) 

Problem is hub, like "works with Alexa", is a vague term these days. I've heard it used for anything from a bridge from something like a Z-Wave network to WiFi, like Homeseer's Z-Net, up to a PC like I use running home automation software and connected to multiple networks of multiple protocols. BTW as someone pointed out Ethernet hubs are yet another thing. Pretty no one uses them anymore but in case some misguided person mentions them you can find a good over view of Ethernet hub vs switch vs router here.

As for what you need, it depends on what you want to do. Again what people call automation is anything from an Echo controlling a WiFi device (which is really just remote control) up to systems that learn on their own. Kind of like drones that way. It is all about interoperability now. I think the best way to look at it as like your entertainment setup. If a Smart TV does everything you need that is fine. You might have wasted some money but if you are OK with that then it is still fine. If you want surround sound then you are going to need a receiver / home theater system linked in some how. Same with if you want to stream stuff your TV does not have an app for or the app sucks or you just do not trust the TV apps to be maintained then you want a streaming box like Roku. Same with DVR, Blu-ray.... So if you want full control of your Hue stuff you want their hub/bridge. Plus once you have the Hue hub you can link it to multiple things. For instance you decide later you want some Z-wave stuff and add a SmartThings hub. You can link the SmartThings hub to the Hue "hub" as well and control your lights directly from SmartThings or Alexa. You could connect the bulbs directly to an Echo Plus but then you could not control them with SmartThings. Or connect them to SmartThings and still be able to control them from the Echo but in both cases you lose features you get with the Hue "hub". Same if you add a Harmony "hub" in as another control interface.

You might also want to read "Who’s Afraid of the Big Bad Hub?"