actarusprinced'euphor a écrit :
Pour ceux que ça intéresse, j'ai récupéré et modifié un script pour le contrôle des clim MITSUBISHI via MelCloud (module WIFI)
Source : https://www.domoticz.com/forum/view [...] =34&t=7496
Code :
- #!/usr/bin/perl
- #Dependency: libwww-perl, libjson-perl
- # Original script : gysmo38
- # Modifications : bagnico
- ###################################################
- # Release notes
- ###################################################
- # Version 0.4:
- # - add vane option horizontal
- # - Change report to domoticz for informations (MODE | T°C | TIME_NEXT_UPDATE)
- # - Change split time (remove .xxx)
- # Version 0.3:
- # - setDomDeviceMode OK
- # - Script works with no Areas
- # - add 1 hours for uptime (for french)
- # Version 0.2:
- # - add 2 hours for uptime time (for french)
- # - add mode option
- # - add fan option
- # - add vane option (only vertical)
- # - add settemp option
- # Version 0.1: First release (with very dirty code...)
- # - switch on / off unit
- # - report room temperature
- # - report unit temperature set
- # - report next unit update
- use HTTP::Request::Common qw(POST GET);
- use HTTP::Headers;
- use LWP::UserAgent;
- use JSON;
- use Data::Dumper;
- #####################################################
- # Configuration
- #####################################################
- my $Email = "mail\@mail.com"; # Email used to login to MELcloud
- my $Password = "password"; # Password used lo login to MELcloud
- my $debug = 1; # 0 = no debug, 1 = debug
- my $domIP = "192.168.0.251"; # Domoticz IP
- my $domPORT = "8080"; # Domoticz PORT
- my @devicesInfos; # List of all devices. Add block for new devices
- #Device 1
- $devicesInfos{"SALON"}{"idx_status"} = "657"; # IDX of status device (type switch)
- $devicesInfos{"SALON"}{"idx_temp"} = "658"; # IDX of temperature device (type temp)
- $devicesInfos{"SALON"}{"idx_info"} = "666"; # IDX of mode (type text)
- #Device n
- # $devicesInfos{"CHAMBRE"}{"idx_status"} = "657"; # IDX of status device (type switch)
- # $devicesInfos{"CHAMBRE"}{"idx_temp"} = "658"; # IDX of temperature device (type temp)
- # $devicesInfos{"CHAMBRE"}{"idx_info"} = "666"; # IDX of mode (type text)
- ##########################################################
- # Functions
- ##########################################################
- sub debug {
- my ($msg) = @_;
- if ($debug) {
- print $msg."\n";
- }
- }
- sub time_offset {
- my ($time,$offset) = @_;
- @split_time = split(/:/,$time);
- # debug("Time: ".$split_time[0]);
- if ($split_time[0] <= 22) {
- $split_time[0] = $split_time[0] + 1;
- }
- elsif ($split_time[0] == 23) {
- $split_time[0] = 00;
- }
- $result = join(":",$split_time[0],$split_time[1],$split_time[2]);
- @timeok = split(/\./,$result);
- return $timeok[0];
- }
- sub getDOMDeviceStatus {
- my ($idx) = @_;
- my $url = "http://$domIP:$domPORT/json.htm?type=devices&rid=".$idx;
- my $ua = LWP::UserAgent->new();
- # Set our own user-agent string!
- $ua->agent("Domoticz Gysmo" );
- require HTTP::Request;
- $req = HTTP::Request->new(GET => $url);
- # Fire the cannon now !
- my $res = $ua->request($req);
- # Get the error back from the server if any
- my $err = $res->status_line;
- # Get server body text, $_ used in regexp on next line
- $_ = $res->decoded_content;
- if (/Illegal Operation/ig || $err != 200) {
- return "Server returned error: $err\n";
- }
- else {
- $result = $1 if /(?:Status\"\ :)+(.*?),/s;
- debug("receive from domoticz: ".$result);
- return $result;
- }
- }
- sub login {
- #Parameters
- my ($Email,$Password) = @_;
- #Variables
- my $AppVersion = "1.9.3.0";
- my $Language = "7";
- my $CaptchaChallenge = "";
- my $CaptchaResponse = "";
- my $Persist = "true";
- my $url = "https://app.melcloud.com/Mitsubishi.Wifi.Client/Login/ClientLogin";
-
- # set up the stuff
- my $ua = LWP::UserAgent->new();
- # Set our own user-agent string!
- $ua->agent("Domoticz Gysmo" );
- # file.cgi should just return the data sent for this test
- # These seem to be like <input type=text name=A value=$A > off a form...
- my $req = POST $url, [
- AppVersion => "$AppVersion",
- CaptchaChallenge => "$CaptchaChallenge",
- CaptchaResponse => "$CaptchaResponse",
- Email => "$Email",
- Language => "$Language",
- Password => "$Password",
- Persist => "$Persist"
- ];
- # Fire the cannon now !
- my $res = $ua->request($req);
- # Get the error back from the server if any
- my $err = $res->status_line;
- # Get server body text, $_ used in regexp on next line
- $_ = $res->decoded_content;
- if (/Illegal Operation/ig || $err != 200) {
- return "Server returned error: $err\n";
- }
- elsif(/\"ErrorId\":1/ig) {
- return "Bad password\n";
- }
- elsif(/\"ErrorId\":null/ig) {
- $result = $1 if /(?:ContextKey\":\" )+(.*?)\"/s;
- debug ("context ID: ".$result);
- return $result;
- }
- else {
- return "Unknow error";
- }
- }
- sub getMELBuildingID {
- #Parameters
- my ($ContextKey,$devicename) = @_;
- #Variables
- my $url = "https://app.melcloud.com/Mitsubishi.Wifi.Client/User/ListDevices";
- # set up the stuff
- my $ua = LWP::UserAgent->new();
- # Set our own user-agent string!
- $ua->agent("Domoticz Gysmo" );
- require HTTP::Request;
- $req = HTTP::Request->new(GET => $url);
- $req->header("X-MitsContextKey" => $ContextKey);
- # Fire the cannon now !
- my $res = $ua->request($req);
- # Get the error back from the server if any
- my $err = $res->status_line;
- # Get server body text, $_ used in regexp on next line
- $_ = $res->decoded_content;
- my $decoded = JSON->new->utf8(0)->decode($_);
- my $result = "0";
- foreach my $building (@$decoded) {
- @devices = @{$building->{'Structure'}{'Devices'}};
- foreach my $device (@devices) {
- if ( $device->{'DeviceName'} =~ $devicename) {
-
- $result = $device->{'BuildingID'};
- }
- }
- # debug("BuildingID: ".Dumper($result));
- }
- if (/Illegal Operation/ig || $err != 200) {
- return "Server returned error: $err\n";
- }
- else {
- # debug("Building ID: ".Dumper($decoded));
- return "$result";
- }
- }
- sub getMELDeviceID {
- #Parameters
- my ($ContextKey,$devicename) = @_;
- #Variables
- my $url = "https://app.melcloud.com/Mitsubishi.Wifi.Client/User/ListDevices";
- # set up the stuff
- my $ua = LWP::UserAgent->new();
- # Set our own user-agent string!
- $ua->agent("Domoticz Gysmo" );
-
- require HTTP::Request;
- $req = HTTP::Request->new(GET => $url);
- $req->header("X-MitsContextKey" => $ContextKey);
- # Fire the cannon now !
- my $res = $ua->request($req);
- # Get the error back from the server if any
- my $err = $res->status_line;
- # Get server body text, $_ used in regexp on next line
- $_ = $res->decoded_content;
- my $decoded = JSON->new->utf8(0)->decode($_);
- my $result = "0";
- foreach my $building (@$decoded) {
- @devices = @{$building->{'Structure'}{'Devices'}};
- foreach my $device (@devices) {
- if ( $device->{'DeviceName'} =~ $devicename) {
-
- $result = $device->{'DeviceID'};
- }
- }
- # debug("DeviceID: ".Dumper($result));
- }
- if (/Illegal Operation/ig || $err != 200) {
- return "Server returned error: $err\n";
- }
- else {
- # debug("Device ID: ".Dumper($decoded));
- return "$result";
- }
- }
- sub listDevices {
- #Parameters
- my ($ContextKey) = @_;
- #Variables
- my $url = "https://app.melcloud.com/Mitsubishi.Wifi.Client/User/ListDevices";
- # set up the stuff
- my $ua = LWP::UserAgent->new();
- # Set our own user-agent string!
- $ua->agent("Domoticz Gysmo" );
-
- require HTTP::Request;
- $req = HTTP::Request->new(GET => $url);
- $req->header("X-MitsContextKey" => $ContextKey);
- # Fire the cannon now !
- my $res = $ua->request($req);
- # Get the error back from the server if any
- my $err = $res->status_line;
- # Get server body text, $_ used in regexp on next line
- $_ = $res->decoded_content;
- if (/Illegal Operation/ig || $err != 200) {
- return "Server returned error: $err\n";
- }
- else {
- $result = $_;
- debug("list devices: ".$result);
- return "$result";
- }
- }
- sub getAirConInfos {
- #Parameters
- my ($contextKey,$deviceID,$buildingID) = @_;
- debug("getairconinfos : ".$contextKey,$deviceID,$buildingID);
- #Variables
- my $url = 'https://app.melcloud.com/Mitsubishi.Wifi.Client/Device/Get?id=' . $deviceID . '&buildingID=' . $buildingID;
- # debug("device status : ". $url);
- #return $url;
- # set up the stuff
- my $ua = LWP::UserAgent->new();
- # Set our own user-agent string!
- $ua->agent("Domoticz Gysmo" );
-
- require HTTP::Request;
-
- $req = HTTP::Request->new(GET => $url);
- $req->header("X-MitsContextKey" => $contextKey);
- # Fire the cannon now !
- my $res = $ua->request($req);
- # Get the error back from the server if any
- my $err = $res->status_line;
- # Get server body text, $_ used in regexp on next line
- $json = $res->decoded_content;
- my $decoded = JSON->new->utf8(0)->decode($json);
- if (/Illegal Operation/ig || $err != 200) {
- return "Server returned error: $err\n";
- }
- else {
- # debug("device status : ". $decoded);
- return $decoded;
- }
- }
- sub setDomDeviceStatus {
- #Parameters
- my ($idDomDevice,$deviceInfos) = @_;
- #Variables
- $domStatus = getDOMDeviceStatus($idDomDevice);
- if ($deviceInfos->{'Power'} =~ /true/ && $domStatus =~ /"Off"/) {
- $switchcmd = "On";
- my $url = "http://$domIP:$domPORT/json.htm?type=command¶m=switchlight&idx=".$idDomDevice."&switchcmd=".$switchcmd;
- debug("send to domoticz: ".$url);
- my $ua = LWP::UserAgent->new();
- # Set our own user-agent string!
- $ua->agent("Domoticz Gysmo" );
-
- require HTTP::Request;
-
- $req = HTTP::Request->new(GET => $url);
- # Fire the cannon now !
- my $res = $ua->request($req);
- # Get the error back from the server if any
- my $err = $res->status_line;
- # Get server body text, $_ used in regexp on next line
- $_ = $res->decoded_content;
- if (/Illegal Operation/ig || $err != 200) {
- return "Server returned error: $err\n";
- }
- else {
- $result = $1 if /(?:status\"\ :)+(.*?),/s;
- debug("receive from domoticz: ".$result);
- return $result;
- }
- }
- elsif ($deviceInfos->{'Power'} =~ /false/ && $domStatus =~ /"On"/) {
- $switchcmd = "Off";
- my $url = "http://$domIP:$domPORT/json.htm?type=command¶m=switchlight&idx=".$idDomDevice."&switchcmd=".$switchcmd;
- debug("send to domoticz: ".$url);
- my $ua = LWP::UserAgent->new();
- # Set our own user-agent string!
- $ua->agent("Domoticz Gysmo" );
-
- require HTTP::Request;
-
- $req = HTTP::Request->new(GET => $url);
- # Fire the cannon now !
- my $res = $ua->request($req);
- # Get the error back from the server if any
- my $err = $res->status_line;
- # Get server body text, $_ used in regexp on next line
- $_ = $res->decoded_content;
- if (/Illegal Operation/ig || $err != 200) {
- return "Server returned error: $err\n";
- }
- else {
- $result = $1 if /(?:status\"\ :)+(.*?),/s;
- debug("receive from domoticz: ".$result);
- return $result;
- }
- }
- else {
- debug("send to domoticz: nothing to send" );
- }
-
- }
- sub setDomDeviceTempRoom {
- #Parameters
- my ($idDomDevice,$deviceInfos) = @_;
- my $url = "http://$domIP:$domPORT/json.htm?type=command¶m=udevice&idx=".$idDomDevice."&nvalue=0&svalue=".$deviceInfos->{'RoomTemperature'};
- debug("send to domoticz: ".$url);
- my $ua = LWP::UserAgent->new();
- # Set our own user-agent string!
- $ua->agent("Domoticz Gysmo" );
- require HTTP::Request;
- $req = HTTP::Request->new(GET => $url);
- # Fire the cannon now !
- my $res = $ua->request($req);
- # Get the error back from the server if any
- my $err = $res->status_line;
- # Get server body text, $_ used in regexp on next line
- $_ = $res->decoded_content;
- if (/Illegal Operation/ig || $err != 200) {
- return "Server returned error: $err\n";
- }
- else {
- $result = $1 if /(?:status\"\ :)+(.*?),/s;
- debug("receive from domoticz: ".$result);
- return $result;
- }
- }
- sub setDomDeviceInfo {
- #Parameters
- my ($idDomDevice,$deviceInfos) = @_;
- my $mode = $deviceInfos->{'OperationMode'};
- @timenextupdate = split(/T/,$deviceInfos->{'NextCommunication'});
- if ( $mode == 1) {
- $modeclim = 'MODE CHAUD';
- }
- elsif ( $mode == 2) {
- $modeclim = 'MODE SECHAGE';
- }
- elsif ( $mode == 3) {
- $modeclim = 'MODE FROID';
- }
- elsif ( $mode == 7) {
- $modeclim = 'MODE VENTILATION';
- }
- elsif ( $mode == 8) {
- $modeclim = 'MODE AUTO';
- }
- my $url = "http://$domIP:$domPORT/json.htm?type=command¶m=udevice&idx=".$idDomDevice."&nvalue=0&svalue=".$modeclim."%20|%20 ".$deviceInfos->{'SetTemperature'}."%20°C%20|%20".time_offset($timenextupdate[1],2);
- debug("send to domoticz: ".$url);
- my $ua = LWP::UserAgent->new();
- # Set our own user-agent string!
- $ua->agent("Domoticz Gysmo" );
- require HTTP::Request;
- $req = HTTP::Request->new(GET => $url);
- # Fire the cannon now !
- my $res = $ua->request($req);
- # Get the error back from the server if any
- my $err = $res->status_line;
- # Get server body text, $_ used in regexp on next line
- $_ = $res->decoded_content;
- if (/Illegal Operation/ig || $err != 200) {
- return "Server returned error: $err\n";
- }
- else {
- $result = $1 if /(?:status\"\ :)+(.*?),/s;
- debug("receive from domoticz: ".$result);
- return $result;
- }
- }
- sub setMELDevicePower {
- #Parameters
- my ($contextKey,$status,$deviceInfos,$idx) = @_;
- if($status =~ /on/ ) {
- $deviceInfos->{'Power'} = "true";
- }
- elsif($status =~ /off/ ) {
- $deviceInfos->{'Power'} = "false";
- }
- $deviceInfos->{'EffectiveFlags'} = "1";
- $deviceInfos->{'HasPendingCommand'} = "true";
- $json_device = JSON->new->utf8->encode($deviceInfos);
- #Variables
- my $url = 'https://app.melcloud.com/Mitsubishi.Wifi.Client/Device/SetAta';
- #return $url;
- # set up the stuff
- my $ua = LWP::UserAgent->new();
- # Set our own user-agent string!
- $ua->agent("Domoticz Gysmo" );
-
- require HTTP::Request;
- $req = HTTP::Request->new(POST => $url);
- $req->header("X-MitsContextKey" => $contextKey);
- $req->header('content-type' => 'application/json');
- $req->content($json_device);
- # Fire the cannon now !
- my $res = $ua->request($req);
- # Get the error back from the server if any
- my $err = $res->status_line;
- # Get server body text, $_ used in regexp on next line
- $_ = $res->decoded_content;
- debug($_);
- if (/Illegal Operation/ig || $err != 200) {
- print "Server returned error: $err\n";
- }
- else {
- debug("Update setMELDevicePower : OK" );
- }
- }
- sub setMELDeviceFan {
- #Parameters
- my ($contextKey,$temp,$deviceInfos,$idx) = @_;
- $deviceInfos->{'SetFanSpeed'} = $temp;
- $deviceInfos->{'EffectiveFlags'} = "8";
- $deviceInfos->{'HasPendingCommand'} = "true";
- $json_device = JSON->new->utf8->encode($deviceInfos);
- #Variables
- my $url = 'https://app.melcloud.com/Mitsubishi.Wifi.Client/Device/SetAta';
- # set up the stuff
- my $ua = LWP::UserAgent->new();
- # Set our own user-agent string!
- $ua->agent("Domoticz Gysmo" );
- require HTTP::Request;
- $req = HTTP::Request->new(POST => $url);
- $req->header("X-MitsContextKey" => $contextKey);
- $req->header('content-type' => 'application/json');
- $req->content($json_device);
- # Fire the cannon now !
- my $res = $ua->request($req);
- # Get the error back from the server if any
- my $err = $res->status_line;
- # Get server body text, $_ used in regexp on next line
- $_ = $res->decoded_content;
- if (/Illegal Operation/ig || $err != 200) {
- print "Server returned error: $err\n";
- }
- else {
- debug("Update setMELDeviceFan : OK" );
- }
- }
- sub setMELDeviceMode {
- #Parameters
- my ($contextKey,$mode,$deviceInfos,$idx) = @_;
- # Mode value : 1 warm, 2 dry, 3 cool, 7 vent, 8 auto
- if ($mode =~ warm) {
- $deviceInfos->{'OperationMode'} = 1;
- }
- elsif ($mode =~ dry) {
- $deviceInfos->{'OperationMode'} = 2;
- }
- elsif ($mode =~ cool) {
- $deviceInfos->{'OperationMode'} = 3;
- }
- elsif ($mode =~ vent) {
- $deviceInfos->{'OperationMode'} = 7;
- }
- elsif ($mode =~ auto) {
- $deviceInfos->{'OperationMode'} = 8;
- }
- $deviceInfos->{'EffectiveFlags'} = "6";
- $deviceInfos->{'HasPendingCommand'} = "true";
- $json_device = JSON->new->utf8->encode($deviceInfos);
- #Variables
- my $url = 'https://app.melcloud.com/Mitsubishi.Wifi.Client/Device/SetAta';
- # set up the stuff
- my $ua = LWP::UserAgent->new();
- # Set our own user-agent string!
- $ua->agent("Domoticz Gysmo" );
- require HTTP::Request;
- $req = HTTP::Request->new(POST => $url);
- $req->header("X-MitsContextKey" => $contextKey);
- $req->header('content-type' => 'application/json');
- $req->content($json_device);
- # Fire the cannon now !
- my $res = $ua->request($req);
- # Get the error back from the server if any
- my $err = $res->status_line;
- # Get server body text, $_ used in regexp on next line
- $_ = $res->decoded_content;
- if (/Illegal Operation/ig || $err != 200) {
- print "Server returned error: $err\n";
- }
- else {
- debug("Update setMELDeviceMode : OK" );
- }
- }
- sub setMELDeviceVaneVertical {
- #Parameters
- my ($contextKey,$vane,$deviceInfos,$idx) = @_;
- $deviceInfos->{'VaneVertical'} = $vane;
- $deviceInfos->{'EffectiveFlags'} = "16";
- $deviceInfos->{'HasPendingCommand'} = "true";
- $json_device = JSON->new->utf8->encode($deviceInfos);
- #Variables
- my $url = 'https://app.melcloud.com/Mitsubishi.Wifi.Client/Device/SetAta';
- # set up the stuff
- my $ua = LWP::UserAgent->new();
- # Set our own user-agent string!
- $ua->agent("Domoticz Gysmo" );
- require HTTP::Request;
- $req = HTTP::Request->new(POST => $url);
- $req->header("X-MitsContextKey" => $contextKey);
- $req->header('content-type' => 'application/json');
- $req->content($json_device);
- # Fire the cannon now !
- my $res = $ua->request($req);
- # Get the error back from the server if any
- my $err = $res->status_line;
- # Get server body text, $_ used in regexp on next line
- $_ = $res->decoded_content;
- if (/Illegal Operation/ig || $err != 200) {
- print "Server returned error: $err\n";
- }
- else {
- debug("Update setMELDeviceVaneVertical : OK" );
- }
- }
- sub setMELDeviceVaneHorizontal {
- #Parameters
- my ($contextKey,$vane,$deviceInfos,$idx) = @_;
- $deviceInfos->{'VaneHorizontal'} = $vane;
- $deviceInfos->{'EffectiveFlags'} = "16";
- $deviceInfos->{'HasPendingCommand'} = "true";
- $json_device = JSON->new->utf8->encode($deviceInfos);
- #Variables
- my $url = 'https://app.melcloud.com/Mitsubishi.Wifi.Client/Device/SetAta';
- # set up the stuff
- my $ua = LWP::UserAgent->new();
- # Set our own user-agent string!
- $ua->agent("Domoticz Gysmo" );
- require HTTP::Request;
- $req = HTTP::Request->new(POST => $url);
- $req->header("X-MitsContextKey" => $contextKey);
- $req->header('content-type' => 'application/json');
- $req->content($json_device);
- # Fire the cannon now !
- my $res = $ua->request($req);
- # Get the error back from the server if any
- my $err = $res->status_line;
- # Get server body text, $_ used in regexp on next line
- $_ = $res->decoded_content;
- if (/Illegal Operation/ig || $err != 200) {
- print "Server returned error: $err\n";
- }
- else {
- debug("Update setMELDeviceVaneHorizontal : OK" );
- }
- }
- sub setMELDeviceTemp {
- #Parameters
- my ($contextKey,$temp,$deviceInfos,$idx) = @_;
- $deviceInfos->{'SetTemperature'} = $temp;
- $deviceInfos->{'EffectiveFlags'} = "4";
- $deviceInfos->{'HasPendingCommand'} = "true";
- $json_device = JSON->new->utf8->encode($deviceInfos);
- #Variables
- my $url = 'https://app.melcloud.com/Mitsubishi.Wifi.Client/Device/SetAta';
- # set up the stuff
- my $ua = LWP::UserAgent->new();
- # Set our own user-agent string!
- $ua->agent("Domoticz Gysmo" );
- require HTTP::Request;
- $req = HTTP::Request->new(POST => $url);
- $req->header("X-MitsContextKey" => $contextKey);
- $req->header('content-type' => 'application/json');
- $req->content($json_device);
- # Fire the cannon now !
- my $res = $ua->request($req);
- # Get the error back from the server if any
- my $err = $res->status_line;
- # Get server body text, $_ used in regexp on next line
- $_ = $res->decoded_content;
- if (/Illegal Operation/ig || $err != 200) {
- print "Server returned error: $err\n";
- }
- else {
- debug("Update setMELDeviceTemp : OK" );
- }
- }
- sub init_mel {
- #Parameters
- my ($search_name) = @_;
- $contextID = login($Email,$Password);
- foreach my $name (keys %devicesInfos) {
- if ( $name =~ $search_name ) {
- $buildingID = getMELBuildingID($contextID,$name);
- $deviceID = getMELDeviceID($contextID,$name);
- }
- }
- }
- #####################################################
- # Main program
- #####################################################
- #####################################################
- # Arguments
- #####################################################
- if ($ARGV[0] =~ /report/) {
- $contextID = login($Email,$Password);
- foreach my $name (keys %devicesInfos) {
- $buildingID = getMELBuildingID($contextID,$name);
- $deviceID = getMELDeviceID($contextID,$name);
- debug("############################" );
- debug("# Reporting device: " . $name ." #" );
- debug("############################" );
- $infosAirCon = getAirConInfos($contextID,$deviceID,$buildingID);
- setDomDeviceTempRoom($devicesInfos{$name}{"idx_temp"},$infosAirCon);
- setDomDeviceStatus($devicesInfos{$name}{"idx_status"},$infosAirCon);
- setDomDeviceInfo($devicesInfos{$name}{"idx_info"},$infosAirCon);
- }
- }
- elsif ($ARGV[0] =~ /test/) {
- init_mel($ARGV[1]);
- debug("Send command to building:" . $buildingID);
- debug("Send command to device:" . $deviceID);
-
- }
- elsif ($ARGV[0] =~ /temp/ && exists $devicesInfos{$ARGV[2]}{'idx_status'}) {
- init_mel($ARGV[2]);
- @temp = split(/:/,$ARGV[1]);
- $infosAirCon = getAirConInfos($contextID,$deviceID,$buildingID);
- setMELDeviceTemp($contextID,$temp[0],$infosAirCon,$devicesInfos{$ARGV[2]}{'idx_update'});
- }
- elsif ($ARGV[0] =~ /fan/ && exists $devicesInfos{$ARGV[2]}{'idx_status'}) {
- init_mel($ARGV[2]);
- debug("Send commande to device:" . $buildingID);
- $infosAirCon = getAirConInfos($contextID,$deviceID,$buildingID);
- setMELDeviceFan($contextID,$ARGV[1],$infosAirCon,$devicesInfos{$ARGV[2]}{'idx_update'});
- }
- elsif ($ARGV[0] =~ /power/ && exists $devicesInfos{$ARGV[2]}{'idx_status'}) {
- init_mel($ARGV[2]);
- $infosAirCon = getAirConInfos($contextID,$deviceID,$buildingID);
- setMELDevicePower($contextID,$ARGV[1],$infosAirCon,$devicesInfos{$ARGV[2]}{'idx_update'});
- }
- elsif ($ARGV[0] =~ /mode/ && exists $devicesInfos{$ARGV[2]}{'idx_status'}) {
- init_mel($ARGV[2]);
- $infosAirCon = getAirConInfos($contextID,$deviceID,$buildingID);
- setMELDeviceMode($contextID,$ARGV[1],$infosAirCon,$devicesInfos{$ARGV[2]}{'idx_update'});
- }
- elsif ($ARGV[0] =~ /vanevertical/ && exists $devicesInfos{$ARGV[2]}{'idx_status'}) {
- init_mel($ARGV[2]);
- $infosAirCon = getAirConInfos($contextID,$deviceID,$buildingID);
- setMELDeviceVaneVertical($contextID,$ARGV[1],$infosAirCon,$devicesInfos{$ARGV[2]}{'idx_update'});
- }
- elsif ($ARGV[0] =~ /vanehorizontal/ && exists $devicesInfos{$ARGV[2]}{'idx_status'}) {
- init_mel($ARGV[2]);
- $infosAirCon = getAirConInfos($contextID,$deviceID,$buildingID);
- setMELDeviceVaneHorizontal($contextID,$ARGV[1],$infosAirCon,$devicesInfos{$ARGV[2]}{'idx_update'});
- }
- elsif ($ARGV[0] =~ /help/) {
- print "-------------------------- MELCLOUD PERL FOR DOMOTICZ v0.4 --------------------------\n";
- print "report: send status of devices to domoticz. Use it for crontab\n";
- print "power on/off DEVICENAME: power on or off a device.\n";
- print "mode modename DEVICENAME: choose mode warm,dry,cool,vent or auto\n";
- print "temp T° DEVICENAME: set temperature device. \n";
- print "fan FAN_SPEED DEVICENAME: set fan speed of the device. \n";
- print "vanevertical VANE_POS DEVICENAME: set van position to 1 - 5, 0 to auto and 7 to move . \n";
- print "vanehorizontal VANE_POS DEVICENAME: set van position to 1 - 5, 0 to auto and 12 to move . \n";
- print "more to come...\n";
- }
- else {
- print "Nothing to do. Type help for help ;)\n";
- }
|
http://reho.st/preview/self/70ada6 [...] ae5cce.png
http://reho.st/preview/self/2d300f [...] 683cbb.png
Il suffit ensuite de créer des scripts bash pour les différents programmes :
Code :
- #!/bin/bash
- perl /home/pi/domoticz/scripts/perso/melcloud.pl temp 22 SALON
- perl /home/pi/domoticz/scripts/perso/melcloud.pl fan 0 SALON
- perl /home/pi/domoticz/scripts/perso/melcloud.pl vanevertical 0 SALON
- perl /home/pi/domoticz/scripts/perso/melcloud.pl vanehorizontal 0 SALON
|
|