NAME

Protocol::IR::Format::WIG - HAIR WIG (wireless infrared group) JSON import and export

VERSION

version 0.08

SYNOPSIS

use Protocol::IR::Converter;

my $converter = Protocol::IR::Converter->new();
my @codes = @{ $converter->import_format('CSV', 'remote.csv') };

# Export Protocol::IR::Code objects to a HAIR hair-wig/3 JSON document
my $wig = $converter->export_codes('WIG', \@codes,
    name  => 'Tigersecu DVR',
    brand => 'Tigersecu',
    model => 'TS-1080',
    kind  => 'dvr',
    notes => 'Converted from the IRDB sample set',
);

# Import a WIG (file path or JSON string) back into Protocol::IR::Code objects
my $imported = $converter->import_format('WIG', 'remote.wig.json');
for my $code (@$imported) {
    print $code->alias . " (" . $code->protocol . ")\n";
}

DESCRIPTION

WIG ("wireless infrared group") is the portable IR code set format used by the HAIR Home Assistant integration (https://github.com/DAB-LABS/HAIR): one JSON file, one remote, raw Pronto hex as the payload.

Protocol::IR::Format::WIG emits hair-wig/3, the current recipe major: every signal carries an explicit ditto_count and bypass_protocol. On import, signals are decoded fresh through the registered protocols (the file never carries decoded fields), and each signal's transmit recipe is kept on the resulting Protocol::IR::Code. Formats hair-wig/1 through hair-wig/3 are accepted on import.

METHODS

export

my $json = $class->export($codes, $registry, %opts);

Serializes one Protocol::IR::Code or an arrayref of them into a hair-wig/3 JSON document. Options:

  • name -- remote name (required by the format; default 'Untitled')

  • brand, model, kind, notes -- optional remote metadata

  • origin -- provenance string; defaults to 'converted by Protocol::IR::Converter'

  • wig_id -- identity UUID (default: a freshly minted v4 UUID)

  • format -- format major to emit (default: hair-wig/3)

decode

my $codes = $class->decode($input, $registry);

Parses a WIG file path or JSON string and returns an arrayref of Protocol::IR::Code objects. alias, ditto_count, and bypass_protocol are preserved on each code. Dies if the JSON is invalid, the format is unsupported, or a signal's Pronto payload cannot be decoded.

SUPPORT

Source code: https://github.com/bwarden/perl-protocol-ir

Bug reports and feature requests: https://github.com/bwarden/perl-protocol-ir/issues

AUTHOR

Brett T. Warden <bwarden@cpan.org>

COPYRIGHT AND LICENSE

Copyright (c) 2026 Brett T. Warden

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.