AutoHAN is a networking and software architecture that enables user-programmable specification of the interaction between appliances in a domestic house. This concept represents an immense challenge for End-User Programming. The characteristics of the potential user population are far broader than any other population of end-user programmers. It is therefore essential to approach the design of the programming environment from a well-founded perspective of cognitive ergonomics and user modelling. We have created a novel programming language, Media Cubes, which is aimed at the same user population as existing domestic remote controls. Moreover, we have applied a cognitive model of programming behaviour in order to specify a language that gives the advantages of direct manipulation as well as the power of more conventional languages.