binarybucks / homA

An extensible framework for the smart home
Eclipse Public License 1.0
137 stars 24 forks source link

name of a control in ui #144

Closed hmueller01 closed 7 years ago

hmueller01 commented 7 years ago

Are there any plans to set a (long) control name? Currently it is the controlId like /devices/<systemId>/controls/<controlId>

Android code (Control.java) shows

// Returns a friendly name shown in the user interface. For now this is the  id
    public String getName() {
        return id;
    }

I would suggest a setting like /devices/<systemId>/controls/<controlId>/meta/name

stylpen commented 7 years ago

I prefer the existing convention because I like expressing as much information as possible implicitly in the topic tree itself rather than sending it as a value on another topic. Maybe the term is a bit misleading. It was not intended as numeric ID or anything like that but as a unique string that can be directly shown to the user. You can have it as long as you like unless you violate the MQTT spec.

hmueller01 commented 7 years ago

stylpen, thank you very much for your comment.

Ok, I understand. With my suggestion I was just following the logic of the "Canonical device name /devices/$SystemId/meta/name". So I thought (with the comment in the Android app) this is/might be the long term target for a "friendly" name.

My new implementation of rcplugs (which is more or less a RaspberryPi Python version of sockets) a "readable" name of the controlId is currently not available at the time the plug is published and send (the same for sockets where it is always called "Power" and every single plug has its own systemId).

Also using the topics controlId for a user friendly name makes it more complicated renaming the thing behind the topic. Lets take the rcplugs example again. Currently the controlId is the <systemCode>-<unitCode> of the rc plug. One might call it just "Plug A", or call is "Kitchen" for a plug in the kitchen, which might change in the future if this device is placed in the "Living room".

And again, /devices/<systemId>/controls/<controlId>/meta/name should/must be optional. Use it if available, otherwise use <controlId>.

stylpen commented 7 years ago

The basic idea back in the days was that what a device does would not change over time and hence the controls it offers (and their names) could remain static and do not need to be altered by the user. We introduced the meta/name concept where no viable constant value was possible. For example, the room where the device would be used in or what payload it switches on or off (in case of sockets).

I have some 433MHz switches controlled by my RasPi, too (my ones use a different protocol than your rcplugs, though) and because they switch the power (no matter what device is plugged into them) their only control is conveniently named "power". When I want to change the room and/or device a switch is controlling I can simply change the /devices/$SystemId/meta/room and/or /devices/$SystemId/meta/name value.

hmueller01 commented 7 years ago

Thanks again. Now I understand why you added the <systemCode>-<unitCode> on the $SystemId and not used this as <controlId>. So every socket (device) is a single list item (spoken in Android code) and controls only one plug (in that room).

I have to change the rcplugs code a lot and make it possible to put the devices (<systemCode>-<unitCode>) into different rooms.

Sorry for that misunderstanding.

Holger

hmueller01 commented 7 years ago

commited code updates and created a pull request #146