Skip to content
This repository has been archived by the owner on Aug 22, 2021. It is now read-only.

Add support for openHAB colorwheel #76

Merged
merged 2 commits into from
Jun 27, 2020
Merged

Conversation

aHcVolle
Copy link
Contributor

OpenHAB does send the colors in a format like:
{"color_array":[250,12,16]} for (almost) red
{"color_array":[10,250,10]} for (almost) green
{"color_array":[17,29,250]} for (almost) blue

Added key color_array to src/main.h
Added parsing of color_array in processJson() to src/light.ino
This was only copied and might be not really nice...
Added array state to JSON object created in createStateJSON() in src/light.ino
This might also be not too elegant...
Changed JSON_OBJECT_SIZE to 13 to make enough space for the replied state message in src/main.h

OpenHAB does send the colors in a format like:
{"color_array":[250,12,16]} for (almost) red
{"color_array":[10,250,10]} for (almost) green
{"color_array":[17,29,250]} for (almost) blue

Added key color_array to src/main.h
Added parsing of color_array in processJson() to src/light.ino
This was only copied and might be not really nice...
Added array state to JSON object created in createStateJSON() in src/light.ino
This might also be not too elegant...
Changed JSON_OBJECT_SIZE to 13 to make enough space for the replied state message in src/main.h
@stelgenhof
Copy link
Owner

Thanks for this PR! I'll have a look in the next coming days. I don't have an openHAB installation here, so can only do limited checking :)

Cheers! Sacha

@aHcVolle
Copy link
Contributor Author

Sure, take your time 😉
It took me months to finally create the PR so there is no need to hurry 😁
I added the json output of openhab's mqtt output so i think you can take that as a base.
maybe there is another way to do this with openHAB but I couldn't find one.

Copy link
Owner

@stelgenhof stelgenhof left a comment

Choose a reason for hiding this comment

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

Already had a look and think it looks fine to me. Only thing I would add is a compiler directive to allow people to either include or exclude this piece of code. This will keep the firmware size small for those who don't use openHAB.

To enable support for openHAB uncomment MQTT_OPENHAB_SUPPORT in config.h
@aHcVolle
Copy link
Contributor Author

Sure, this is a good idea.

@github-actions
Copy link

Stale pull request message

@stelgenhof stelgenhof added this to the 0.7 milestone Jun 27, 2020
@stelgenhof stelgenhof merged commit 3f918c6 into stelgenhof:develop Jun 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants