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

Implement "group 0" as a regular zigbee group #1555

Merged
merged 2 commits into from
Jun 10, 2019

Conversation

KodeCR
Copy link
Contributor

@KodeCR KodeCR commented May 29, 2019

This is mostly the first commit from #1471 so it can be reviewed and merged in stages. This:

  • creates a (regular Zigbee) group with all the lights in it and translates api "group 0" to this Zigbee group
    -- just using Zigbee group id 0 did not work for all lights nor 65535, so it finds a free group from 65520 going downwards
    -- removes all "group0" special cases

This should cause not change in behavior. On the Zigbee side each light will now have an extra group, and turning off or on all lights via group 0 on the api side is now achieved on the Zigbee side with a groupcast to this zigbee group instead of a broadcast.

…t and use that for group 0/All.

- a group address of 0 actually works for Ikea and Osram lights, but not for Philips
- finds a free group-address from 65520 downwards, 65535 does not work for Osram
- add all lights when found after database load or after light search
- remove all special cases and use "regular" groupcast
group.setAddress(0);
group.setName("All");
groups.push_back(group);
if (gwGroup0 == 0) { // get new id and replace old group0 and get new id
Copy link
Member

Choose a reason for hiding this comment

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

Please always use braces on the next line for if, for. So that the code base just has one code style.

if (gwGroup0)
{
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, missed this one, it's no my usual code style.

if (!val.isEmpty())
{
uint group0 = val.toUInt(&ok);
if (ok && (group0 <= 65535))
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't 65535 be 0xFFF0 to align with the later code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, good catch,

@manup
Copy link
Member

manup commented Jun 10, 2019

Thanks, I think this should work. For a later refactor we should consider to switch to a SQL table to map an REST-API group id and unqiueid to a Zigbee group id.

id      | uinqueid                    | Zigbee GID
--------+-----------------------------+-----------
0       |                             |  0x7432
1       | d8:5d:ef:11:a1:00:01:76-01  |  0x0001    // did exist prior to api change
2       |                             |  0x0002    // did exist prior to api change
3       |                             |  0xF040    // new random mapping

@KodeCR
Copy link
Contributor Author

KodeCR commented Jun 10, 2019

Thanks @manup for reviewing. I'll update the PR tomorrow or the day after, or feel free to make those changes yourself.

@manup manup merged commit e40b1eb into dresden-elektronik:master Jun 10, 2019
manup added a commit that referenced this pull request Jun 10, 2019
0 and larger than 0xfff7 is not valid for Osram Lightify.

Related PR #1555
@manup
Copy link
Member

manup commented Jun 10, 2019

Thanks @manup for reviewing. I'll update the PR tomorrow or the day after, or feel free to make those changes yourself.

Done :)

@KodeCR KodeCR deleted the group0 branch June 21, 2019 08:19
@KodeCR KodeCR restored the group0 branch June 21, 2019 14:42
@KodeCR KodeCR deleted the group0 branch June 21, 2019 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants