4
0

duplicates.py 836 B

1234567891011121314151617181920212223242526272829
  1. """Check for duplicates of the supplied file."""
  2. import sys
  3. from common_funcs import load_config, make_sample_dps
  4. from custom_components.tuya_local.helpers.device_config import possible_matches
  5. def main():
  6. for filename in sys.argv[1:]:
  7. config = load_config(filename)
  8. if config is None:
  9. print(f"No config could be loaded for {filename}")
  10. continue
  11. sample_dps = make_sample_dps(config)
  12. # device = FakeDevice(sample_dps)
  13. for m in possible_matches(sample_dps):
  14. if m.config_type == config.config_type:
  15. continue
  16. if m.match_quality(sample_dps) > 50:
  17. print(
  18. f"{m.config_type} matched {filename} {m.match_quality(sample_dps)}%"
  19. )
  20. if __name__ == "__main__":
  21. sys.exit(main())