Gernerally ThingClasses are the definitions of how things look like, what states/events/actions they have. Think of it as a template. From this template, things are created. For performance reasons things won’t carry all the information again about state names, default values and whatnot. They only hold the actual state values etc. Whenever you work with a thing, you want to keep its thingclass at hand to look up all those details.
What nymea:app does is to call indeed GetThingClasses once and store the entire reply in a cache. You can use the cache hashes in the JSONRPC.Hello reply to know whether is has changed on the core and needs to be updated or whether the thing class cache is still valid. GetThingClasses will contain all the (thing) info you’ll ever need, no need to call GetStateType and similar unless you only need a minimal interaction with just one or two particular states. That’s mostly meant for smaller scripts that won’t have the capability to cache the entire thing class definitions.
GetThings is called every time on the connection establishment. Then, it stores a pointer to the thingClass in every thing and has some convenience methods to do stuff like “thing.stateByName()” and “thing.stateById()” which will then just walk through thing,thingClass.stateTypes and return the appropriate one.
Once you have ThingClasses and Things loaded, subscribe for notifications (JSONRPC.SetNotificationStatus) for the Integrations namespace which would then update your client every time something changes.
To sum it up:
- Call GetThingClasses when you connect to a host for the first time or the cache hash changed.
- Call GetThings once on every connection establishment
- Watch thing changes by subscribing to notifications (no need to call GetThings any more until the connection drops)
For the groups/rooms:
nymea:app uses tags for groups, yes. You can either re-use those tags to be in sync with nymea:app or create your own ones. Use “nymea:app” as appId for the tags if you want to re-use them or your own app id if you want a separate room/group system.
Since version 0.27 nymea also supports the AppData namespace which allows to store arbitrary data on the core (i.e. the new Dashboard is stored there). You can also store such stuff there…