Files
James Magahern 918818cd99 ServerMultiplex: Introduces a server mutiplexer
- Also moves all the existing Wemo* stuff over to support the multiplexer
- Moves MainViewController to be the owner of the multiplexer, and its delegate
2020-03-14 18:33:02 -07:00

68 lines
1.5 KiB
Swift

//
// WemoDevice.swift
// XIONControlPanel
//
// Created by Charles Magahern on 12/31/15.
// Copyright © 2015 XION. All rights reserved.
//
import Foundation
class WemoDevice : Device
{
var name: String = ""
var host: String = ""
var model: String = ""
var state: DeviceState = .off
var type: DeviceType = .switch
var serial: String = ""
init()
{}
init(_ dict: NSDictionary)
{
if let name = dict["name"] as? NSString {
self.name = String(name)
}
if let host = dict["host"] as? NSString {
self.host = String(host)
}
if let model = dict["model"] as? NSString {
self.model = String(model)
}
if let state = dict["state"] as? NSNumber {
switch (state.intValue) {
case 0:
self.state = .off
case 1:
self.state = .on
default:
self.state = .off
}
}
if let serial = dict["serialnumber"] as? NSString {
self.serial = String(serial)
}
}
func hash(into hasher: inout Hasher)
{
hasher.combine(self.name)
hasher.combine(self.host)
hasher.combine(self.model)
hasher.combine(self.state)
hasher.combine(self.type)
hasher.combine(self.serial)
}
}
func ==(lhs: WemoDevice, rhs: WemoDevice) -> Bool
{
return (lhs.serial == rhs.serial)
}