Code Monkey home page Code Monkey logo

Comments (6)

AlCalzone avatar AlCalzone commented on June 19, 2024 1

You can. The virtual group object looks like this:

{
  "_id": "tradfri.0.VG-00001",
  "type": "channel",
  "common": {
    "name": "Test"
  },
  "native": {
    "instanceId": 1,
    "type": "virtual group",
    "deviceIDs": [
      65537,
      65538
    ]
  },
  // ...
}

So once you read the object with getObject, obj.native.deviceIDs contains the instance ids of the members. Those are always lightbulbs, so their IDs have the form "tradfri.X.L-YYYYY"

from iobroker.tradfri.

NemoN avatar NemoN commented on June 19, 2024

Some background of my question: I have a virtual group with 10 GU-10 bulbs. Sometimes 1-3 bulbs of the group don't react. If i retrigger the switch on/off command it works. My plan was now:

For example turning off all lamps:

  • Turn off virtual group
  • Check each lamp in group for state still on
  • Turn this lamp(s) off again

This works now. Maybe this could be handled from backend/Tradfri adapter too?

from iobroker.tradfri.

AlCalzone avatar AlCalzone commented on June 19, 2024

This works now. Maybe this could be handled from backend/Tradfri adapter too?

Sounds reasonable, I'll need some additional input though. When that happens:

  • Do the lamps which did not react update their state in ioBroker? I imagine they don't.
  • Do the virtual group's states get updated?

from iobroker.tradfri.

NemoN avatar NemoN commented on June 19, 2024

Do the lamps which did not react update their state in ioBroker? I imagine they don't.

No the status is still tradfri.0.L-65549.lightbulb.state = 'true'
(if i trigger a "off" command)

Do the virtual group's states get updated?

If some bulbs of the VG can't switched, then the VG group state is empty tradfri.0.VG-00001.state = ''

my working workaround is now after turning off the VG group before

var newState = true;
var obj = getObject('tradfri.0.VG-00001');
var members = obj.native.deviceIDs;

members.forEach(function(m) {
    var stateId = 'tradfri.0.L-' + m + '.lightbulb.state';
    // console.log(stateId);

    getState(stateId, function (error, state) {
        // console.log(state.val);
        if (error) {
           console.log(error);
        } else {
            if (state.val != newState) { // Lampe hat den falschen State, nochmal schalten!
                setState(stateId, newState, false, function() { 
                    if (newState) {
                        log(stateId + ' turned ON again!');
                    } else {
                        log(stateId + ' turned OFF again!');
                    }
                });
            }
        }
    });
});

from iobroker.tradfri.

AlCalzone avatar AlCalzone commented on June 19, 2024

Ok thanks. One more thing:
Does the log show any errors when this happens? Something along the lines of unhandled promise rejection?

from iobroker.tradfri.

NemoN avatar NemoN commented on June 19, 2024

no errors

from iobroker.tradfri.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.