Connecting to Hubitat's Webservice via perl

This is specifically in response to a 3 year old posting by @idallen regarding querying the hubitat webservice for logs. However, any help would be appreciated. The following code was posted:

So I tried it and got a weird error:

/Volumes/homes/jgobble/websocket-hubitat.pl: Opening blocking INET socket to ws://hubitat.local:80
/Volumes/homes/jgobble/websocket-hubitat.pl: Creating Protocol::WebSocket::Client handler
/Volumes/homes/jgobble/websocket-hubitat.pl: Connecting to client
/Volumes/homes/jgobble/websocket-hubitat.pl: Error on websocket: Wrong response line. Got [[HTTP/1.1 302 Found]], expected [[HTTP/1.1 101 ]]

Now, I know what HTTP 302 is. It's "moved temporarily" but A: Why isn't the script "following" the link to the new location. And does anyone know how to make it work correctly? I am on a C7 w/v2.4.1.177 and all I want to do is be able to export logs of all temperature and humidity levels on all devices as they occur. I want the solution in perl from a "remote" system so it looks like Hubitat's webservice is the answer. I have no other knowledge how to get logs of all the temp and humidity sensors.

Any help?

Which eventstream are you trying to connect to? Are you trying something like ws://hubitat.local/logsocket (which should work) or just ws://hubitat.local as it appears you might be doing (which won't unless the script you're using chooses some path for you that isn't apparent from your logs)?

I literally just solved it when you posted this.

The command I WAS using was:

perl /Volumes/homes/jgobble/websocket-hubitat.pl ws://hubitat.local/eventsocket

What I found when I did a Data::Dumper on $client was this:

$VAR1 = bless( {
                 'on_error' => sub { "DUMMY" },
                 'url' => bless( {
                                   'secure' => 0,
                                   'port' => 80,
                                   'resource_name' => '/eventsocket',
                                   'host' => 'hubitat.local'
                                 }, 'Protocol::WebSocket::URL' ),
                 'on_connect' => sub { "DUMMY" },
                 'version' => undef,
                 'on_frame' => undef,
                 'on_read' => sub { "DUMMY" },
                 'on_write' => sub { "DUMMY" },
                 'frame_buffer' => bless( {
                                            'max_payload_size' => 65536,
                                            'fragments' => [],
                                            'max_fragments_amount' => undef,
                                            'buffer' => '',
                                            'version' => 'draft-ietf-hybi-17'
                                          }, 'Protocol::WebSocket::Frame' ),
                 'on_eof' => undef,
                 'hs' => bless( {
                                  'error' => 'Wrong response line. Got [[HTTP/1.1 302 Found]], expected [[HTTP/1.1 101 ]]',
                                  'req' => bless( {
                                                    'state' => 'first_line',
                                                    'cookies' => [],
                                                    'max_message_size' => 20480,
                                                    'version' => '',
                                                    'fields' => {},
                                                    'resource_name' => '/eventsocket',
                                                    'buffer' => '',
                                                    'host' => 'hubitat.local',
                                                    'headers' => []
                                                  }, 'Protocol::WebSocket::Request' ),
                                  'url' => $VAR1->{'url'},
                                  'res' => bless( {
                                                    'state' => 'error',
                                                    'cookies' => [],
                                                    'error' => 'Wrong response line. Got [[HTTP/1.1 302 Found]], expected [[HTTP/1.1 101 ]]',
                                                    'version' => '',
                                                    'max_message_size' => 20480,
                                                    'fields' => {},
                                                    'buffer' => 'Date: Sun, 22 Jun 2025 18:51:43 GMT
Location: http://10.0.1.198:80/eventsocket
Content-Length: 0

'
                                                  }, 'Protocol::WebSocket::Response' )
                                }, 'Protocol::WebSocket::Handshake::Client' )
               }, 'Protocol::WebSocket::Client' );

SO, looking at 'res' in the Dumper variable, I learned that if I use:

perl /Volumes/homes/jgobble/websocket-hubitat.pl ws://10.0.1.198:80/eventsocket

Then it works!

So the error code in the perl script didn't dump the entire REASON for the error...but the Dumper($client) did let me know!

For some reason the hubitat webservice does NOT like answering to hubitat.local ... it needed the port number (and maybe the IP). It's working now ... not questioning it! Thanks for responding tho!