ice discovery via Yeeling specific SSDP
protocol and sending commands via control protocol in the JSON format.
Device::Yeelight module provides base class for detecting Yeelight devices.
use Dev
package Device::Yeelight::Light;
use 5.026;
use utf8;
use strict;
use warnings;
use Carp;
use JSON;
use IO::Socket;
=encoding utf8
=head1 NAME
Device::Yeelight::Light - WiFi Smart LED Light
=head
my $json = encode_json(
{
id => $id,
method => $cmd =~ s/^${package}:://r,
params => \@params,
}
);
$self->connection->send("$json\r\
uffer;
while ( not $self->connection->recv( $buffer, 4096 ) ) {
my $response = decode_json($buffer);
# Ignore notification messages
next if not defined $response->{id};