amimof / huego

An extensive Philips Hue client library for Go with an emphasis on simplicity
MIT License
250 stars 36 forks source link

Feat: New constructor with raw JSON as input (PR is WIP) #55

Open yunginnanet opened 2 years ago

yunginnanet commented 2 years ago

- What I did

- How I did it

- How to verify it

- Description for the CHANGELOG

codecov-commenter commented 2 years ago

Codecov Report

Merging #55 (8403d46) into master (5668ae6) will decrease coverage by 0.02%. The diff coverage is 71.42%.

:exclamation: Current head 8403d46 differs from pull request most recent head aae82f0. Consider uploading reports for the commit aae82f0 to get more accurate results

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master      #55      +/-   ##
==========================================
- Coverage   73.53%   73.52%   -0.02%     
==========================================
  Files           5        5              
  Lines        1436     1443       +7     
==========================================
+ Hits         1056     1061       +5     
- Misses        210      211       +1     
- Partials      170      171       +1     
Impacted Files Coverage Δ
huego.go 78.26% <71.42%> (-0.37%) :arrow_down:
yunginnanet commented 2 years ago

Haven't had time to write this out yet, but here's why I added it: https://github.com/yunginnanet/ziggs/blob/2705ff6140f9f18f805eaba297339a6f5d62a97c/ziggy/lights.go#L371-L401

Essentially my bridge is firewalled off from the internet - this means it can't call home to phillips to do its little discovery function. As an alternative (and very barbaric) discovery method my app offers to port scan the chosen LAN interface and then enumerate the addresses that respond for status callbacks.

When it gets a hit, it uses that JSON to construct a bridge type using the NewCustom function.

amimof commented 1 year ago

Hey @yunginnanet Thanks for contributing. Let me know once you are ready for review (no longer draft)