Monday, August 7, 2017

(#27) - Home Automation, Lights and Normal People


Normal

Here's how normal people turn on the lights in the kitchen:

Not Normal

And here's how people enamored with Home Automation turn on the lights in the kitchen:

  1. Fumble around in the dark, pull smartphone from pocket
  2. Swipe around until Home Automation App found, launch app
  3. Wait while Home Automation app starts
  4. Swipe around and find the Lighting Tab on the Home Automation app
  5. Swipe around and find the room labeled Kitchen
  6. Press the On button



And the industry wonders why adoption just won't take...

Still, that's far too simple and straight-forward for me, so continuing our TCP Connected Lighting Gateway programming from the last post, lets cover two of the four commands we use.

DeviceSendCommand


DeviceSendCommandLevel


To control individual bulbs, you use one of these two commands. The first turns a bulb on and off. The second command will set the dimming level.

#------------------------------------------------------------
def set_light_value(self, did, value=1, update=True):
    rc = self.my_gateway.send_device_command(did, value)
    if update:
        self.load_rooms_and_devices()
    return rc

#-----------------------------------------------------------
def set_light_level(self, did, level=100, update=True):
    rc = self.my_gateway.send_device_command_level(did,level)
    if update:
        self.load_rooms_and_devices()
    return rc



And then the HTTPS calls to the gateway are:

















The two strings, DeviceSendCommand and DeviceSendLevelCommand were shown back here.


The last two commands of the four affect an entire room and they're used in the same manner:

RoomSendCommand

RoomSendCommandLevel

#------------------------------------------------------------
def set_room_value(self, rid, value=1, update=True):
    rc = self.my_gateway.send_room_command(rid,value)
    if update:
        self.load_rooms_and_devices()
    return rc

#------------------------------------------------------------
def set_room_level(self, rid, level=50,update=True):
    rc = self.my_gateway.send_room_command_level(rid,level)
    if update:
        self.load_rooms_and_devices()
    return rc

No surprise here, the HTTPS calls to the gateway are:

















The "update" variable is used to potentially postpone a call to reload the room and bulb status values. That call, the RoomGetCarousel call is a bit 'thick' and I wanted to avoid calling it if I'm doing multiple bulb updates,

No comments :

Post a Comment