ni-c / heimcontrol.js

Home-Automation with node.js and Raspberry PI
MIT License
1.41k stars 297 forks source link

Modifying the database entries #70

Open schneiderr opened 10 years ago

schneiderr commented 10 years ago

I will be using heimcontrol to control outdoor lights that are on a touchplate system. I thought it would be nice to add light groupings into my program. Right now i am using jquery to trigger specific buttons that ive hardcoded.

image

Now i am trying to give the user the choice between no light group, group 1 or group 2.

image

The trouble i am having is with the database. I want to to store the group id as part of the "item" ( item.groupid ). However, when i do this, the database does not like it and i cannot figure out where the initial representation is stored and how i can add item.groupid to the item.

HeLiBloks commented 10 years ago

Hi nice idea,

schneiderr commented 10 years ago

I will fork it tonight, but basically, touchplate is a low voltage lighting solution. The system uses mechanical latch relay's. I will be using an 8 channel 5V relay to switch the state of the touchplate relay. Since the touchplate relays are mechanical. I only need to trigger my relay for .75 seconds in order for the mechanical latch to switch. Hence the toggle switch and not the on - off buttons.

I am not sure , that's what i need to figure out. I am pretty new to node, socket, mongo and all of the other projects heimcontrol use's so i am still trying to figure that out.

I have not had to do much if anything with the db when adding my other features, i used javascript and duino. but now im trying to add a column in the database to store the groupid. that i can then get from item

HeLiBloks commented 10 years ago

ok MongoDB is Object oriented to there's no column in the DB but keys of the object your working on all JSON style. The way I think it could work is simply adding a groupid property to the items object on the client. Heimcontrol should take care of the rest as it iterates through all property's and updates the DB as settings are saved. Item.groupid = "No Light Group" //?? might work

schneiderr commented 10 years ago

Here is my forked repo. i will be adding the group lighting code to it tonight or tomorrow.on a sperate branch.

schneiderr commented 10 years ago

I have figured out how to get the id into the database, it was the same thing i was trying before but i must have been making a mistake somewhere.

div.touchplateah(class=(item.method != 'touchplateah' ? 'hidden' : '')) label(for="groupid") Group Id: select(name="data[#{i}][groupid]") option(disabled="disabled",selected=(item.groupid == '')) Choose Group option(value="1",selected=(item.groupid == '1')) No Group option(value="2",selected=(item.groupid == '2')) Group 1 option(value="3",selected=(item.groupid == '3')) Group 2 option(value="4",selected=(item.groupid == '4')) Group 3