Open jlpatte2 opened 9 years ago
I'm glad your interested and checking it out! I do use Android Studio and would recommend it for this project. If you import the project it should know it's an Android project and you can do all the build configuring through the UI. From the command line the two useful build commands are assembleDebug, which generates a debug build, and assembleRelease for a release build. The release build by default doesn't have any signing keys configured for it, which is why it won't install. You can either configure the build through app/build.gradle or somewhere in the UI, or you can do it from the AS menu Build > Generate Signed APK, that will take you through generating a key. Debug builds work fine, though.
There is also a smaller project for GreenDao, which is used to generate the ORM model files, that is set up as a java project and has a separate build, ./gradlew run
.
I found the lint error you're running into, it has something to do with the http library the project uses, Retrofit, and doesn't cause any errors, I'll look into fixing the lint warning. For now, just don't run lint :).
Adding Z-Wave would be awesome, and also probably a fair amount of work. Here's a list of general things that would have to be done.
1) Right now some of the code assumes that all devices are dimmable lights and have two attributes, one On/Off and one Level. There needs to be a way for a device to know what attributes are available for it's device type; a device already knows what device type it is, it's loaded from the hub.
2) UI would need to be created to handle different sets of attributes for a device, like if a device has two On/Off attributes and a color attribute.
3) Only zigbee devices are loaded from the hub. The server scripts would need to be updated to handle loading data for different device types. The hub stores them all in different tables, so I'm not sure how much their properties differ from each other. Maybe a single model on the client side can handle it, might need to create more complicated models.
Let me know if you get stuck somewhere, maybe you can post the data from the hub's db for the device you have and I can help support it.
Ok sounds pretty good this is about what I imagined was needed with zwave support. One question I had, why do you check the wifi network ssid? I'd think an ip address would be sufficient?
I check the ssid for two reasons:
1) The ip of the hub is most likely on a private network, at least mine is. When connected to different networks you may end up sending requests to the same ip address belonging to a different machine, what you'll get is undefined.
2) Blink gets notified when you connect to a wifi network. Blink uses a sqlite db to store settings on the device, and then syncs them to the hub. So you can, for example, set lights on when walking home, and as soon as you connect to your wifi, Blink syncs up settings and your lights come on.
So here is the set of zwave* Tables from my wink with 1 zwave appliance controller installed. Note that the device has a single TRUE/FALSE attribute at attribute number 2. The main entries of interest I suspect are these two: INSERT INTO "zwaveDevice" VALUES(2,2,0,0,0,0,0,4,16,1,134,3,6,3,2,78,1,43); and INSERT INTO "zwaveDeviceState" VALUES(2,0,2,'FALSE','FALSE');
sqlite> .dump zwave%
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE zwaveCmdClass(
cmdClass INTEGER PRIMARY KEY, -- Corresponds to z-wave class ID
className VARCHAR(256) -- Name of the command class (ex. COMMAND_CLASS_BASIC, COMMAND_CLASS_ALARM )
);
INSERT INTO "zwaveCmdClass" VALUES(32,'COMMAND_CLASS_BASIC');
INSERT INTO "zwaveCmdClass" VALUES(37,'COMMAND_CLASS_SWITCH_BINARY');
INSERT INTO "zwaveCmdClass" VALUES(38,'COMMAND_CLASS_SWITCH_MULTILEVEL');
INSERT INTO "zwaveCmdClass" VALUES(48,'COMMAND_CLASS_SENSOR_BINARY');
INSERT INTO "zwaveCmdClass" VALUES(49,'COMMAND_CLASS_SENSOR_MULTILEVEL');
INSERT INTO "zwaveCmdClass" VALUES(64,'COMMAND_CLASS_THERMOSTAT_MODE');
INSERT INTO "zwaveCmdClass" VALUES(66,'COMMAND_CLASS_THERMOSTAT_OPERATING_STATE');
INSERT INTO "zwaveCmdClass" VALUES(67,'COMMAND_CLASS_THERMOSTAT_SETPOINT');
INSERT INTO "zwaveCmdClass" VALUES(98,'COMMAND_CLASS_DOOR_LOCK');
INSERT INTO "zwaveCmdClass" VALUES(152,'COMMAND_CLASS_SECURITY');
CREATE TABLE zwaveDevice(
masterId INTEGER,
nodeId INTEGER,
endpoint INTEGER, -- Multichannel devices will have a positive endpoint, otherwise 0.
multiParent INTEGER, -- 0 == normal node; 1 == multichannel parent with no masterId
secure INTEGER, -- 0 == non-secure device; 1 == support COMMAND_CLASS_SECURITY
crc16 INTEGER, -- Boolean (0 or 1): Support CRC16 encap?
sleeper INTEGER, -- Boolean (0 or 1): Supports COMMAND_CLASS_WAKE_UP?
basicType INTEGER, -- Zwave basic device type.
genericType INTEGER, -- Zwave generic type.
specType INTEGER, -- Zwave Specific type.
manufacturerNum INTEGER, -- Zwave MSR Manufacturer ID
productType INTEGER, -- Zwave MSR Product Type
productNum INTEGER, -- Zwave MSR Product ID
versionLibraryType INTEGER, -- Zwave Version: Zwave Library Type (see ZW_basis_api.h; ZW_LIB__)
versionProtoMajor INTEGER, -- Zwave Version: Zwave Protocol Major
versionProtoMinor INTEGER, -- Zwave Version: Zwave Protocol Minor
versionAppMajor INTEGER, -- Zwave Version: Application Major
versionAppMinor INTEGER, -- Zwave Version: Application Minor
PRIMARY KEY (nodeId, endpoint),
FOREIGN KEY (masterId) REFERENCES masterDevice (deviceId )
);
INSERT INTO "zwaveDevice" VALUES(2,2,0,0,0,0,0,4,16,1,134,3,6,3,2,78,1,43);
CREATE TABLE zwaveAttribute(
cmdClass INTEGER,
attributeId INTEGER PRIMARY KEY,
attrcmd VARCHAR(10) NOT NULL, -- Denotes this entry as either an "ATTRIBUTE" or "COMMAND"
description VARCHAR(256), -- Attribute Descriptor
dataType VARCHAR(32), / Zwave Data type. In zwave this is usually overly broad,
* such as "BYTE", or "CONST". We may be able to get away
* with inserting our own meaningful values like "bool"
* or "int", but this will need to be implemented and
* maintained manually. _/
read_write VARCHAR(3), -- Either "R", "W", or "R/W" to denote read/write capabilities.
commandKey INTEGER NOT NULL, -- This is the identifier that zwave uses to identify a specific command within a command class.
FOREIGN KEY (cmdClass) REFERENCES zwaveCmdClass( cmdClass )
);
INSERT INTO "zwaveAttribute" VALUES(32,1,'ATTRIBUTE','GenericValue','UINT8','R/W',1);
INSERT INTO "zwaveAttribute" VALUES(37,2,'ATTRIBUTE','On_Off','BOOL','R/W',1);
INSERT INTO "zwaveAttribute" VALUES(38,3,'ATTRIBUTE','Level','UINT8','R/W',1);
INSERT INTO "zwaveAttribute" VALUES(38,4,'COMMAND','Up_Down','BOOL','W',4);
INSERT INTO "zwaveAttribute" VALUES(38,5,'COMMAND','StopMovement','BOOL','W',5);
INSERT INTO "zwaveAttribute" VALUES(48,7,'ATTRIBUTE','On_Off','BOOL','R',2);
INSERT INTO "zwaveAttribute" VALUES(49,8,'ATTRIBUTE','Level','FLOAT','R',4);
INSERT INTO "zwaveAttribute" VALUES(49,9,'ATTRIBUTE','Unit','STRING','R',1);
INSERT INTO "zwaveAttribute" VALUES(98,10,'ATTRIBUTE','Lock_Unlock','BOOL','R/W',1);
INSERT INTO "zwaveAttribute" VALUES(64,11,'ATTRIBUTE','ThermostatMode','STRING','R/W',1);
INSERT INTO "zwaveAttribute" VALUES(67,12,'ATTRIBUTE','ThermostatHeatSetpoint','FLOAT','R/W',1);
INSERT INTO "zwaveAttribute" VALUES(67,13,'ATTRIBUTE','ThermostatCoolSetpoint','FLOAT','R/W',1);
INSERT INTO "zwaveAttribute" VALUES(66,14,'ATTRIBUTE','ThermostatOperatingState','STRING','R',2);
CREATE TABLE zwaveDeviceState(
nodeId INTEGER,
endpoint INTEGER,
attributeId INTEGER,
value_get VARCHAR(256), -- value_get and value_set will need to be a string value that can be converted to
value_set VARCHAR(256), -- integers and whatnot as needed.
FOREIGN KEY (nodeId,endpoint) REFERENCES zwaveDevice( nodeId, endpoint ),
FOREIGN KEY (attributeId) REFERENCES zwaveAttribute(attributeId)
);
INSERT INTO "zwaveDeviceState" VALUES(2,0,2,'FALSE','FALSE');
CREATE TABLE zwaveCCSupport(
cmdClass INTEGER,
genericType INTEGER,
specType INTEGER,
profileId INTEGER,
description VARCHAR(128),
FOREIGN KEY (cmdClass) REFERENCES zwaveCmdClass (cmdClass)
);
INSERT INTO "zwaveCCSupport" VALUES(32,2,0,1,'STATIC_CONTROLLER');
INSERT INTO "zwaveCCSupport" VALUES(32,2,1,1,'PC_CONTROLLER');
INSERT INTO "zwaveCCSupport" VALUES(32,2,2,1,'SCENE_CONTROLLER');
INSERT INTO "zwaveCCSupport" VALUES(37,16,0,2,'SWITCH_BINARY');
INSERT INTO "zwaveCCSupport" VALUES(37,16,1,2,'POWER_SWITCH_BINARY');
INSERT INTO "zwaveCCSupport" VALUES(37,16,3,2,'SCENE_SWITCH_BINARY');
INSERT INTO "zwaveCCSupport" VALUES(38,17,0,3,'SWITCH_MULTILEVEL');
INSERT INTO "zwaveCCSupport" VALUES(38,17,1,3,'POWER_SWITCH_MULTILEVEL');
INSERT INTO "zwaveCCSupport" VALUES(38,17,3,3,'MOTOR_SWITCH_MULTIPOSITION');
INSERT INTO "zwaveCCSupport" VALUES(38,17,4,3,'SCENE_SWITCH_MULTILEVEL');
INSERT INTO "zwaveCCSupport" VALUES(38,17,5,4,'CLASS_A_MOTOR_CONTROL');
INSERT INTO "zwaveCCSupport" VALUES(38,17,6,4,'CLASS_B_MOTOR_CONTROL');
INSERT INTO "zwaveCCSupport" VALUES(38,17,7,4,'CLASS_C_MOTOR_CONTROL');
INSERT INTO "zwaveCCSupport" VALUES(49,33,1,6,'ROUTING_SENSOR_MULTILEVEL');
INSERT INTO "zwaveCCSupport" VALUES(49,33,2,6,'CHIMNEY_FAN_SENSOR_MULTILEVEL');
INSERT INTO "zwaveCCSupport" VALUES(152,64,0,7,'ENTRY_CONTROL');
INSERT INTO "zwaveCCSupport" VALUES(152,64,1,7,'DOOR_LOCK');
INSERT INTO "zwaveCCSupport" VALUES(152,64,2,7,'ADVANCED_DOOR_LOCK');
INSERT INTO "zwaveCCSupport" VALUES(152,64,3,7,'SECURE_KEYPAD_DOOR_LOCK');
INSERT INTO "zwaveCCSupport" VALUES(152,64,4,7,'SECURE_KEYPAD_DOOR_LOCK_DEADBOLT');
INSERT INTO "zwaveCCSupport" VALUES(64,8,0,8,'THERMOSTAT');
INSERT INTO "zwaveCCSupport" VALUES(64,8,1,8,'THERMOSTAT_HEATING');
INSERT INTO "zwaveCCSupport" VALUES(64,8,2,8,'THERMOSTAT_GENERAL');
INSERT INTO "zwaveCCSupport" VALUES(64,8,3,8,'SETBACK_SCHEDULE_THERMOSTAT');
INSERT INTO "zwaveCCSupport" VALUES(64,8,4,8,'SETPOINT_THERMOSTAT');
INSERT INTO "zwaveCCSupport" VALUES(64,8,5,8,'SETBACK_THERMOSTAT');
INSERT INTO "zwaveCCSupport" VALUES(64,8,6,8,'THERMOSTAT_GENERALV2');
CREATE TABLE zwaveProfiles(
cmdClass INTEGER,
profileId INTEGER,
attributeId INTEGER,
FOREIGN KEY (attributeId) REFERENCES zwaveAttribute (attributeId)
);
INSERT INTO "zwaveProfiles" VALUES(32,1,1);
INSERT INTO "zwaveProfiles" VALUES(37,2,2);
INSERT INTO "zwaveProfiles" VALUES(38,3,3);
INSERT INTO "zwaveProfiles" VALUES(38,4,4);
INSERT INTO "zwaveProfiles" VALUES(38,4,5);
INSERT INTO "zwaveProfiles" VALUES(48,5,7);
INSERT INTO "zwaveProfiles" VALUES(49,6,8);
INSERT INTO "zwaveProfiles" VALUES(49,6,9);
INSERT INTO "zwaveProfiles" VALUES(98,7,10);
INSERT INTO "zwaveProfiles" VALUES(49,8,8);
INSERT INTO "zwaveProfiles" VALUES(49,8,9);
INSERT INTO "zwaveProfiles" VALUES(64,8,11);
INSERT INTO "zwaveProfiles" VALUES(66,8,14);
INSERT INTO "zwaveProfiles" VALUES(67,8,12);
INSERT INTO "zwaveProfiles" VALUES(67,8,13);
CREATE TABLE zwaveGroups(
GroupId INTEGER PRIMARY KEY,
GroupName VARCHAR(64)
);
INSERT INTO "zwaveGroups" VALUES(1,'Lifeline');
CREATE TABLE zwaveGroupMembers(
GroupId INTEGER,
NodeId INTEGER,
PRIMARY KEY ( GroupId, NodeId ), / Enforces only one DB entry per GroupId/NodeId pair */
FOREIGN KEY (GroupID) REFERENCES zwaveGroups (GroupId)
);
COMMIT;
I'm sure this is a proble with my understanding, and setup, not the actual project, but I couldn't figure out any other way to contact you!
so really two questions, looking at the project in android studio (is this what you use?) the graddle lists a LOT of possible targets, and its not at all clear which is the "main" compile, and generate an apk. I basically just fumbled through it, and finally got it to kick out some apks though I'm still not entirely sure how! A quick intro on how to compile would be awesome; or if this is "std" and I'm just not familiar enough with the tool set just tell me to google it :)
the second that ?may? be related is that I get an error in lint when building: Error:Execution failed for task ':app:lint'.
And lastly, the debug .apk works, but the release one fails to install when I try and install it on my phone, so any thoughts there would be appreciated.
Once I get my legs under me I intend to try and add support for my zwave on off appliance module.