Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[things] Add Thing class & Get Thing(s) #132

Merged
merged 4 commits into from
Jun 4, 2022

Conversation

florian-h05
Copy link
Contributor

@florian-h05 florian-h05 commented Jun 3, 2022

Closes #89.

Improvements

  • a Thing class which represents an openHAB Thing, that e.g. holds the label, but also allows to set the enabled state
  • getThings to get an Array of all openHAB Things
  • getThing to get a single Thing

Testing

DO NOT USE ON PRODUCTION AS THIS MODIFIES A THING!!

const { things } = require('openhab');

const allThings = things.getThings();
console.info(allThings);
const astroThing = things.getThing('astro:moon:e66c230447', true);
console.info(astroThing);

const thing = allThings[0];

function analyzeThing (thing) {
  console.info('Bridge UID: ' + thing.bridgeUID);
  console.info('Thing label: ' + thing.label);
  console.info('Thing location: ' + thing.location);
  console.info('Thing sttaus: ' + thing.status);
  console.info('Thing detailed status: ' + thing.statusInfo);
  console.info('ThingTypeUID: ' + thing.thingTypeUID);
  console.info('Thing UID: ' + thing.uid);
  console.info('Thing is enabled: ' + thing.isEnabled);
}

analyzeThing(thing);

thing.setLabel('new label');
thing.setLocation('living room');
thing.setEnabled(false);

analyzeThing(thing);

@florian-h05 florian-h05 added the enhancement New feature or request label Jun 3, 2022
@florian-h05 florian-h05 force-pushed the retrieve-all-things branch from 9b4ebec to 0de3dfa Compare June 3, 2022 22:14
The Thing class represents an openHAB Thing.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
@florian-h05 florian-h05 force-pushed the retrieve-all-things branch from 0de3dfa to eb0d8c8 Compare June 3, 2022 22:17
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
@florian-h05 florian-h05 changed the title [WIP][things] Add Thing class & Get Thing(s) [things] Add Thing class & Get Thing(s) Jun 3, 2022
@florian-h05 florian-h05 requested a review from digitaldan June 3, 2022 22:48
@florian-h05 florian-h05 added this to the 1.2.4 milestone Jun 3, 2022
Copy link
Contributor

@digitaldan digitaldan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@digitaldan digitaldan merged commit f8594c6 into openhab:main Jun 4, 2022
@florian-h05 florian-h05 deleted the retrieve-all-things branch June 5, 2022 10:03
florian-h05 added a commit to florian-h05/openhab-js that referenced this pull request Jun 5, 2022
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
digitaldan pushed a commit that referenced this pull request Jun 5, 2022
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
florian-h05 added a commit to florian-h05/openhab-webui that referenced this pull request Jun 19, 2022
This adds the `things` namespace with the `Thing` class and the Thing
getter methods.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[things] Add ability to retrieve all things
2 participants