Skip to content

Commit

Permalink
Add an insecure https option
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumezin committed Jan 7, 2024
1 parent dbe8a47 commit bf3d916
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
3 changes: 3 additions & 0 deletions HTML/EN/plugins/DomoticzControl/settings/player.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
[% WRAPPER setting title="PLUGIN_DOMOTICZCONTROL_SETTINGS_HTTPS" desc="" %]
<input type="checkbox" name="pref_https" id="https" value="1" [% IF prefs.pref_https %]checked="checked"[% END %]/>
[% END %]
[% WRAPPER setting title="PLUGIN_DOMOTICZCONTROL_SETTINGS_INSECURE_TITLE" desc="PLUGIN_DOMOTICZCONTROL_SETTINGS_DETAILS_INSECURE" %]
<input type="checkbox" name="pref_insecure" id="insecure" value="1" [% IF prefs.pref_insecure %]checked="checked"[% END %]/>
[% END %]
[% WRAPPER setting title="PLUGIN_DOMOTICZCONTROL_SETTINGS_USER" desc="" %]
<input type="text" name="pref_user" id="user" value="[% prefs.pref_user %]"/>
[% END %]
Expand Down
25 changes: 23 additions & 2 deletions Plugin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ my $prefs = preferences('plugin.DomoticzControl');

my $defaultPrefs = {
'address' => '127.0.0.1',
'port' => 8080,
'https' => 0,
'port' => 443,
'https' => 1,
'insecure' => 0,
'user' => '',
'password' => '',
'onlyFavorites' => 1,
Expand Down Expand Up @@ -153,6 +154,10 @@ sub _setToDomoticz {
my $trendsurl = 'type=command&param=' . $param . '&idx=' . $idx . '&' . $cmd . '=' . $level;
$log->debug('Send data to Domoticz: '. $trendsurl);
$trendsurl = initPref($client) . $trendsurl;
my $options;
if ($prefs->client($client)->get('insecure')) {
$options = { SSL_verify_mode => Net::SSLeay::VERIFY_NONE() };
}

if (exists $idxTimers{$idx}) {
delete $idxTimers{$idx};
Expand All @@ -163,6 +168,7 @@ sub _setToDomoticz {
\&_setToDomoticzErrorCallback,
{
cache => 0, # optional, cache result of HTTP request
options => $options
}
);

Expand Down Expand Up @@ -688,6 +694,10 @@ sub _getFromDomoticzCallback {
my $trendsurl = 'type=command&param=getscenes&used=true';
$log->debug('Ask scenes to Domoticz: '. $trendsurl);
$trendsurl = initPref($client) . $trendsurl;
my $options;
if ($prefs->client($client)->get('insecure')) {
$options = { SSL_verify_mode => Net::SSLeay::VERIFY_NONE() };
}

my $http = Slim::Networking::SimpleAsyncHTTP->new(
\&_getScenesFromDomoticzCallback,
Expand All @@ -696,6 +706,7 @@ sub _getFromDomoticzCallback {
slimrequest => $request,
devices => \@results,
cache => 0, # optional, cache result of HTTP request
options => $options
}
);

Expand Down Expand Up @@ -724,13 +735,18 @@ sub getFromDomoticz {
my $trendsurl = 'type=command&param=getdevices&used=true';
$log->debug('Ask devices to Domoticz: '. $trendsurl);
$trendsurl = initPref($client) . $trendsurl;
my $options;
if ($prefs->client($client)->get('insecure')) {
$options = { SSL_verify_mode => Net::SSLeay::VERIFY_NONE() };
}

my $http = Slim::Networking::SimpleAsyncHTTP->new(
\&_getFromDomoticzCallback,
\&_getFromDomoticzErrorCallback,
{
slimrequest => $request,
cache => 0, # optional, cache result of HTTP request
options => $options
},
{
slimrequest => $request,
Expand Down Expand Up @@ -858,13 +874,18 @@ sub _manageMacroStringQueue {
my $trendsurl = 'type=command&param=getdevices&used=true';
$log->debug('Ask devices to Domoticz: '. $trendsurl);
$trendsurl = initPref($client) . $trendsurl;
my $options;
if ($prefs->client($client)->get('insecure')) {
$options = { SSL_verify_mode => Net::SSLeay::VERIFY_NONE() };
}

my $http = Slim::Networking::SimpleAsyncHTTP->new(
\&_getDevicesOnlyFromDomoticzCallback,
\&_getDevicesOnlyFromDomoticzErrorCallback,
{
slimrequest => $request,
cache => 0, # optional, cache result of HTTP request
options => $options
}
);

Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ Usage

1. There you can configure URL access for Domoticz and filter for each player which control you want to get on the player screen.

1. If you connect using HTTPS and Domoticz uses a self-signed certificate, set "Insecure HTTPS" to "Switch off certificate verification on HTTPS connections." in settings / Advanced / Security.

1. You can also associate alarms and snoozes with Domoticz devices (On/Off commands only). This can be useful to activate Domoticz scripts through a virtual switch for instance.

1. You can associate a Domoticz device that will turn on and off at the same time as a player.
Expand Down
2 changes: 1 addition & 1 deletion install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
<minVersion>7.4.0</minVersion>
</targetApplication>
<type>2</type>
<version>1.2.3</version>
<version>1.2.4</version>
</extension>
8 changes: 8 additions & 0 deletions strings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ PLUGIN_DOMOTICZCONTROL_SETTINGS_HTTPS
EN Domoticz URL or IP address uses HTTPS
FR L'URL ou l'adresse IP de Domoticz utilise HTTPS

PLUGIN_DOMOTICZCONTROL_SETTINGS_INSECURE_TITLE
EN Insecure HTTPS connection allowed
FR Connexion HTTPS non sécurisée autorisée

PLUGIN_DOMOTICZCONTROL_SETTINGS_DETAILS_INSECURE
EN Do not verify Domoticz HTTPS certificate, if self-signed or if you have "Connect timed out" error messages
FR Ne pas vérifier le certificat HTTPS de Domoticz, s'il est auto-signé ou si vous avez des messages d'erreur "Connect timed out"

PLUGIN_DOMOTICZCONTROL_SETTINGS_PORT
EN Domoticz URL or IP address port
FR Port de l'URL ou de l'adresse IP de Domoticz
Expand Down

0 comments on commit bf3d916

Please sign in to comment.