Discrete Control in the Internet of things and Smart Environments