NEWS
[Vorlage] Sony Bravia TV ab 2013
-
Hallo,
ich habe begonnen ein Skript für die Steuerung von Sony Bravia TVs ab 2013 zu erstellen
vielleicht ist es ja für den einen oder anderen interessant
Getestet haben ich es an einem KDL-55W805A, es läuft soweit, ist aber noch nicht fehlerfrei !
Das Aktualisieren der States geht momentan nur über den Button System.Update d.h. das Skript bekommt noch nicht automatisch mit wenn am TV durch die Fernbedienung was geändert wird !
Beschreibung zum Vorgehen:
1. TV Einschalten
2. IP des TV unter System.IP eintragen
3. Benutzername unter Authorization.User eintragen
4. PIN_Anfordern drücken
5. PIN auf TV Bildschirm ablesen und unter Authorization.PIN eintragen
! ```
`createState('javascript.0.Sony_Bravia_VAR.Authorization.PIN_Anfordern', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Authorization.Cookie', 'init',{type: "string", role: "Cookie",write:false});
createState('javascript.0.Sony_Bravia_VAR.Authorization.PIN', 0,{type: "number", role: "PIN"});
createState('javascript.0.Sony_Bravia_VAR.Authorization.Status', false,{type: "boolean", role: "Erfolgreich",write:false});
createState('javascript.0.Sony_Bravia_VAR.Authorization.User','',{type: "string", role: "User"});
//System
createState('javascript.0.Sony_Bravia_VAR.System.IP_Adresse',{type: "string", role: "IP Adresse"});
createState('javascript.0.Sony_Bravia_VAR.System.MAC_Adresse',{type: "string", role: "MAC Adresse",write:false});
createState('javascript.0.Sony_Bravia_VAR.System.Generation',{type: "string", role: "Generation",write:false});
createState('javascript.0.Sony_Bravia_VAR.System.Language',{type: "string", role: "Language",write:false});
createState('javascript.0.Sony_Bravia_VAR.System.Model',{type: "string", role: "Model",write:false});
createState('javascript.0.Sony_Bravia_VAR.System.Name',{type: "string", role: "Name",write:false});
createState('javascript.0.Sony_Bravia_VAR.System.Product',{type: "string", role: "Product",write:false});
createState('javascript.0.Sony_Bravia_VAR.System.Serial',{type: "string", role: "Serial",write:false});
createState('javascript.0.Sony_Bravia_VAR.System.Update', 0,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Power', false,{type: "boolean", role: "Power"});
//Control
createState('javascript.0.Sony_Bravia_VAR.Control.Play', false,{type:"boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Control.Stop', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Control.Pause', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Control.Skip_Plus', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Control.Skip_Minus', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Control.Page_Next', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Control.Page_Previous', false,{type: "boolean", role: "button"});
//Input
createState('javascript.0.Sony_Bravia_VAR.Input.InputsStatus', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Input.ActivInput', false,{type: "string", role: "ActivInput"});
createState('javascript.0.Sony_Bravia_VAR.Input.HDMI1', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Input.HDMI2', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Input.HDMI3', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Input.HDMI4', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Input.SetTV', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Input.AV1', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Input.AV2', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Input.BildschirmSpiegeln', false,{type: "boolean", role: "button"});
//TV
createState('javascript.0.Sony_Bravia_VAR.TV.Channel', 0,{type: "number", role: "Channel"});
createState('javascript.0.Sony_Bravia_VAR.TV.ProgrammTitel',{type: "string", role: "ProgrammTitel",write:false});
createState('javascript.0.Sony_Bravia_VAR.TV.Länge',{type: "number", role: "Länge (Minuten)",write:false});
createState('javascript.0.Sony_Bravia_VAR.TV.Startzeit',{type: "string", role: "Startzeit",write:false});
createState('javascript.0.Sony_Bravia_VAR.TV.SenderLesen', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.TV.ChannelList',0,{type: "number", role: "Channel List",states:"0:none"});
//Audio
createState('javascript.0.Sony_Bravia_VAR.Audio.SpeakerVolume', 0,{type: "number", role: " SpeakerVolume"});
createState('javascript.0.Sony_Bravia_VAR.Audio.SpeakerVolume_UP', 0,{type: "number", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Audio.SpeakerVolume_DOWN', 0,{type: "number", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Audio.HeadphoneVolume', 0,{type: "number", role: " HeadphoneVolume",write:false});
createState('javascript.0.Sony_Bravia_VAR.Audio.SpeakerMute', false,{type: "boolean", role: "SpeakerMute"});
! var MySonyTV = {
ip:'',
mac:'',
pin:0,
auth:'',
body:{},
channel:{},
sony:{id:1,method:'',params:[],version:'1.0'},system: { getColorKeysLayout:function (val) {return MySonyTV.Send(1,'system','getColorKeysLayout',val)}, getCurrentTime:function (val) {return MySonyTV.Send(2,'system','getCurrentTime',val)}, getDateTimeFormat:function (val) {return MySonyTV.Send(3,'system','getDateTimeFormat',val)}, getInterfaceInformation:function (val) {return MySonyTV.Send(4,'system','getInterfaceInformation',val)}, getMethodTypes:function (val) {return MySonyTV.Send(5,'system','getMethodTypes',val)}, getPostalCode:function (val) {return MySonyTV.Send(6,'system','getPostalCode',val)}, getPowerSavingMode:function (val) {return MySonyTV.Send(7,'system','getPowerSavingMode',val)}, getPowerStatus:function (val) {return MySonyTV.Send(8,'system','getPowerStatus',val)}, getRemoteControllerInfo:function (val) {return MySonyTV.Send(9,'system','getRemoteControllerInfo',val)}, getSystemInformation:function (val) {return MySonyTV.Send(10,'system','getSystemInformation',val)}, getSystemSupportedFunction:function (val) {return MySonyTV.Send(11,'system','getSystemSupportedFunction',val)}, getVersions:function (val) {return MySonyTV.Send(12,'system','getVersions',val)}, getWolMode:function (val) {return MySonyTV.Send(13,'system','getWolMode',val)}, requestToNotifyDeviceStatus:function (val) {return MySonyTV.Send(14,'system','requestToNotifyDeviceStatus',val)}, setCurrentTime:function (val) {return MySonyTV.Send(15,'system','setCurrentTime',val)}, setLEDIndicatorStatus:function (val) {return MySonyTV.Send(16,'system','setLEDIndicatorStatus',val)}, setLanguage:function (val) {return MySonyTV.Send(17,'system','setLanguage',val)}, setPostalCode:function (val) {return MySonyTV.Send(18,'system','setPostalCode',val)}, setPowerSavingMode:function (val) {return MySonyTV.Send(19,'system','setPowerSavingMode',val)}, setPowerStatus:function (val) {return MySonyTV.Send(20,'system','setPowerStatus',val)}, setWolMode:function (val) {return MySonyTV.Send(21,'system','setWolMode',val)}, }, avContent:{ deleteContent:function (val) {return MySonyTV.Send(22,'avContent','deleteContent',val)}, getContentCount:function (val) {return MySonyTV.Send(23,'avContent','getContentCount',val)}, getContentList:function (val) {return MySonyTV.Send(24,'avContent','getContentList',val)}, getCurrentExternalInputsStatus:function (val) {return MySonyTV.Send(25,'avContent','getCurrentExternalInputsStatus',val)}, getMethodTypes:function (val) {return MySonyTV.Send(26,'avContent','getMethodTypes',val)}, getParentalRatingSettings:function (val) {return MySonyTV.Send(27,'avContent','getParentalRatingSettings',val)}, getPlayingContentInfo:function (val) {return MySonyTV.Send(28,'avContent','getPlayingContentInfo',val)}, getSchemeList:function (val) {return MySonyTV.Send(29,'avContent','getSchemeList',val)}, getSourceList:function (val) {return MySonyTV.Send(30,'avContent','getSourceList',val)}, getVersions:function (val) {return MySonyTV.Send(31,'avContent','getVersions',val)}, setDeleteProtection:function (val) {return MySonyTV.Send(32,'avContent','setDeleteProtection',val)}, setPlayContent:function (val) {return MySonyTV.Send(33,'avContent','setPlayContent',val)}, setPlayTvContent:function (val) {return MySonyTV.Send(34,'avContent','setPlayTvContent',val)}, }, audio:{ getMethodTypes:function (val) {return MySonyTV.Send(35,'audio','getMethodTypes',val)}, getVersions:function (val) {return MySonyTV.Send(36,'audio','getVersions',val)}, getVolumeInformation:function (val) {return MySonyTV.Send(37,'audio','getVolumeInformation',val)}, setAudioMute:function (val) {return MySonyTV.Send(38,'audio','setAudioMute',val)}, setAudioVolume:function (val) {return MySonyTV.Send(39,'audio','setAudioVolume',val)}, }, accessControl:{ actRegister:function (val) {return MySonyTV.Send(40,'accessControl','actRegister',val)}, getMethodTypes:function (val) {return MySonyTV.Send(41,'accessControl','getMethodTypes',val)}, getVersions:function (val) {return MySonyTV.Send(42,'accessControl','getVersions',val)}, }, IRCC: { setIRCC:function (val) {return MySonyTV.Send(255,'IRCC','setIRCC',val)}, }, Send: function(id,service,method,params) { this.sony.method=method; this.sony.params=params; this.sony.id=id; this.ip=getState('javascript.0.Sony_Bravia_VAR.System.IP_Adresse').val;
! var j = request.jar();
var cookie = request.cookie(this.auth);
var FormData;if(service!='IRCC'){FormData=JSON.stringify(this.sony)} else{FormData='<ircccode>'+params+'</ircccode>'; console.log('IRCC'); }
//##############################################################################
// Configure the request
var options = {
url: 'http://'+this.ip+'/sony/'+service,
jar: true,
method: 'POST',
headers: {'Authorization':'Basic '+ Buffer.from(':'+this.pin).toString('base64')},
form:FormData
};! console.log('Anfrage'+options.form);
! j.setCookie(cookie,options.url);
! // Start the request
request(options, function (error, response, body) {
! if(!error){ // && response.statusCode == 200//------------------------------------------------------------------------------- if ("undefined" !== typeof body&&service!='IRCC'){ console.log('Body '+body); this.body=JSON.parse(body); if ("undefined" !== typeof this.body.error){ if(this.body.error[1]=='not power-on'){ setState('javascript.0.Sony_Bravia_VAR.Power',val=false,akt=true); } else if(this.body.error[1]=='Unauthorized'){ setState('javascript.0.Sony_Bravia_VAR.Authorization.Status',val=false,akt=true); setState('javascript.0.Sony_Bravia_VAR.Authorization.PIN',val=0,akt=false); this.auth=''; setState('javascript.0.Sony_Bravia_VAR.Authorization.Cookie',val= this.auth); } else if(this.body.error[1]=="not register any more"){} setState('javascript.0.Sony_Bravia_VAR.Authorization.Status',val=false,akt=true); console.log(this.body.error[1]); } else { if ("undefined" !== typeof this.body.auth_url){ //tritt ein wenn keinCookie vorhanden oder abgelaufen/falsch ist setState('javascript.0.Sony_Bravia_VAR.Authorization.Status',val=false,akt=true); //Authorization(); //kann probleme machen, endlosschleife } if ("undefined" !== typeof this.body.id){ switch(this.body.id){ case 40://actRegister //cookie string zerlegen, krücke, aber gehr ;-) --------------------------------- if ("undefined" !== typeof response.headers['set-cookie']){ //wenn objekt definiert ist var C=JSON.stringify(response.headers['set-cookie']).split(';'); C=C[0].split('"'); this.auth=C[1]; setState('javascript.0.Sony_Bravia_VAR.Authorization.Cookie',val=this.auth,akt=true); }//end if if ("undefined" !== typeof this.body.result){ //positive Antwort auf ActRegister if (this.body.result.length===0){ setState('javascript.0.Sony_Bravia_VAR.Authorization.Status',val=true,akt=true); setState('javascript.0.Sony_Bravia_VAR.Authorization.PIN',val=0,akt=true); update(); } } break; case 8://getPowerStatus if(this.body.result[0].status=='active'){setState('javascript.0.Sony_Bravia_VAR.Power',val=true,akt=true)} else if(this.body.result[0].status=='standby'){setState('javascript.0.Sony_Bravia_VAR.Power',val=false,akt=true)} break; case 10://getSystemInformation this.mac=this.body.result[0].macAddr; setState('javascript.0.Sony_Bravia_VAR.System.MAC_Adresse',val=this.body.result[0].macAddr,akt=true); setState('javascript.0.Sony_Bravia_VAR.System.Generation',val=this.body.result[0].generation,akt=true); setState('javascript.0.Sony_Bravia_VAR.System.Language',val=this.body.result[0].language,akt=true); setState('javascript.0.Sony_Bravia_VAR.System.Model',val=this.body.result[0].model,akt=true); setState('javascript.0.Sony_Bravia_VAR.System.Name',val=this.body.result[0].name,akt=true); setState('javascript.0.Sony_Bravia_VAR.System.Product',val=this.body.result[0].product,akt=true); setState('javascript.0.Sony_Bravia_VAR.System.Serial',val=this.body.result[0].serial,akt=true); break; case 37://getVolumeInformation setState('javascript.0.Sony_Bravia_VAR.Audio.SpeakerVolume',val=this.body.result[0][0].volume,akt=true); setState('javascript.0.Sony_Bravia_VAR.Audio.HeadphoneVolume',val=this.body.result[0][1].volume,akt=true); setState('javascript.0.Sony_Bravia_VAR.Audio.SpeakerMute',val=this.body.result[0][0].mute,akt=true); break; case 24://getContentList' //var channels=this.body.result[0]; MySonyTV.channel=this.body.result[0]; var StateString=''; for(var i = 0; i < 20; i++) { //MySonyTV.channel.length geht nicht da mehr als 50 Sender StateString=StateString+i.toString()+':'+MySonyTV.channel[i].title+';'; //StateString=StateString+i.toString()+':'+channels[i].title+';'; } var obj = getObject('javascript.0.Sony_Bravia_VAR.TV.ChannelList'); obj.common.states = StateString; setObject('javascript.0.Sony_Bravia_VAR.TV.ChannelList', obj); break; case 28://getPlayingContentInfo': if ("undefined" !== typeof this.body.result[0].source){ setState('javascript.0.Sony_Bravia_VAR.Input.ActivInput',this.body.result[0].source,akt=true); if (this.body.result[0].source=='extInput:hdmi'&&this.body.result[0].title=='HDMI 1'){setState('javascript.0.Sony_Bravia_VAR.Input.HDMI1',true,akt=true)} else if (this.body.result[0].source=='extInput:hdmi'&&this.body.result[0].title=='HDMI 2'){setState('javascript.0.Sony_Bravia_VAR.Input.HDMI2',true,akt=true)} else if (this.body.result[0].source=='extInput:hdmi'&&this.body.result[0].title=='HDMI 3'){setState('javascript.0.Sony_Bravia_VAR.Input.HDMI3',true,akt=true)} else if (this.body.result[0].source=='extInput:hdmi'&&this.body.result[0].title=='HDMI 4'){setState('javascript.0.Sony_Bravia_VAR.Input.HDMI4',true,akt=true)} else if (this.body.result[0].source=='tv:dvbc'){setState('javascript.0.Sony_Bravia_VAR.Input.SetTV',true,akt=true)}; }; if ("undefined" !== typeof this.body.result[0].programTitle){setState('javascript.0.Sony_Bravia_VAR.TV.ProgrammTitel',val=this.body.result[0].programTitle,akt=true)}; if ("undefined" !== typeof this.body.result[0].durationSec){setState('javascript.0.Sony_Bravia_VAR.TV.Länge',val=parseFloat(this.body.result[0].durationSec)/60,akt=true)}; if ("undefined" !== typeof this.body.result[0].startDateTime){setState('javascript.0.Sony_Bravia_VAR.TV.Startzeit',val=this.body.result[0].startDateTime,akt=true)}; if ("undefined" !== typeof this.body.result[0].title){}; if ("undefined" !== typeof this.body.result[0].uri){ if ("undefined" !== typeof MySonyTV.channel[0]){ for(var i=0; i < MySonyTV.channel.length; i++){ if(MySonyTV.channel[i].uri==this.body.result[0].uri){ setState('javascript.0.Sony_Bravia_VAR.TV.ChannelList',val=i,akt=true) setState('javascript.0.Sony_Bravia_VAR.TV.Channel',val=i,akt=true) break; } } } }; break; default: break; }// end of Switch }// if id undefined }// end else } // end if undefined
}//end if !error
else{
console.log(error)
if(error.code=='EHOSTUNREACH'){setState('javascript.0.Sony_Bravia_VAR.Power',false,akt=true)
}
!
!
}
! }) ; // end of Requestreturn;
} // end of Function Send
}; // end of Object MySonyTV
//##############################################################################! // Initiale abfrage
//MySonyTV.system.getSystemInformation([]);
Authorization()
! function update(){
MySonyTV.avContent.getContentList([{source:"tv:dvbc",target:"",type:"",cnt:50,stIdx:""}]);
MySonyTV.system.getSystemInformation([]);
MySonyTV.system.getPowerStatus([]);
MySonyTV.avContent.getPlayingContentInfo([])
MySonyTV.avContent.getCurrentExternalInputsStatus([]);
MySonyTV.audio.getVolumeInformation([])
! }//end Pollen
! function Authorization(){
var user =getState('javascript.0.Sony_Bravia_VAR.Authorization.User').val
data= [{clientid:user,nickname:user},[{clientid:user,value:'yes',nickname:user,function:'WOL'}]];
MySonyTV.accessControl.actRegister(data);
}
! var data;
! on({id:'javascript.0.Sony_Bravia_VAR.System.IP_Adresse',change:"any"}, function (obj){
MySonyTV.ip=obj.state.val
MySonyTV.system.getSystemInformation([]);}) ;
! on({id:'javascript.0.Sony_Bravia_VAR.Authorization.PIN_Anfordern',val:true}, function (obj){
if(getState('javascript.0.Sony_Bravia_VAR.Authorization.User').val.length>=1){
Authorization()
}
}) ;on('javascript.0.Sony_Bravia_VAR.Authorization.PIN', function (obj){
if (!obj.state.ack) {
MySonyTV.pin=obj.state.val;
Authorization()
}});
on({id:'javascript.0.Sony_Bravia_VAR.Input.InputsStatus',val:true}, function (obj){
MySonyTV.avContent.getCurrentExternalInputsStatus([]);
//MySonyTV.avContent.getPlayingContentInfo([]);
//MySonyTV.avContent.getSchemeList([]);
//MySonyTV.avContent.getSourceList([{scheme:'tv'}]);
//MySonyTV.system.getRemoteControllerInfo([])
//MySonyTV.audio.getMethodTypes(['1.0']);});
on({id:'javascript.0.Sony_Bravia_VAR.Input.HDMI1',val:true}, function (obj){ if (!obj.state.ack) { if (obj.state.val===true){ MySonyTV.avContent.setPlayContent([{uri:'extInput:hdmi?port=1'}]); MySonyTV.avContent.getPlayingContentInfo([]); } }
});
on({id:'javascript.0.Sony_Bravia_VAR.Input.HDMI2',val:true}, function (obj){ if (!obj.state.ack) { if (obj.state.val===true){ MySonyTV.avContent.setPlayContent([{uri:'extInput:hdmi?port=2'}]); MySonyTV.avContent.getPlayingContentInfo([]); } }
});
on({id:'javascript.0.Sony_Bravia_VAR.Input.HDMI3',val:true}, function (obj){ if (!obj.state.ack) { if (obj.state.val===true){ MySonyTV.avContent.setPlayContent([{uri:'extInput:hdmi?port=3'}]); MySonyTV.avContent.getPlayingContentInfo([]); } }
});
on({id:'javascript.0.Sony_Bravia_VAR.Input.HDMI4',val:true}, function (obj){ if (!obj.state.ack) { if (obj.state.val===true){ MySonyTV.avContent.setPlayContent([{uri:'extInput:hdmi?port=4'}]); MySonyTV.avContent.getPlayingContentInfo([]); } }
});
on({id:'javascript.0.Sony_Bravia_VAR.Input.SetTV',val:true}, function (obj){ if (!obj.state.ack) { if (obj.state.val===true){ MySonyTV.avContent.setPlayContent([{uri:'tv:'}]); MySonyTV.avContent.getPlayingContentInfo([]); } }
});
on({id:'javascript.0.Sony_Bravia_VAR.Input.AV1',val:true}, function (obj){ if (!obj.state.ack) { if (obj.state.val===true){ MySonyTV.avContent.setPlayContent([{uri:'extInput:scart?port=1'}]); MySonyTV.avContent.getPlayingContentInfo([]); } }
});
on({id:'javascript.0.Sony_Bravia_VAR.Input.AV2',val:true}, function (obj){ if (!obj.state.ack) { if (obj.state.val===true){ MySonyTV.avContent.setPlayContent([{uri:'extInput:composite?port=1'}]); MySonyTV.avContent.getPlayingContentInfo([]); } }
});
on({id:'javascript.0.Sony_Bravia_VAR.BildschirmSpiegeln',val:true}, function (obj){ if (!obj.state.ack) { if (obj.state.val===true){ MySonyTV.avContent.setPlayContent([{uri:'extInput:widi?port=1'}]); MySonyTV.avContent.getPlayingContentInfo([]); } }
});
on({id: 'javascript.0.Sony_Bravia_VAR.TV.SenderLesen', val: true}, function (obj){ MySonyTV.avContent.getContentList([{source:"tv:dvbc",target:"",type:"",cnt:50,stIdx:""}]) MySonyTV.avContent.getPlayingContentInfo([]);
});
on( 'javascript.0.Sony_Bravia_VAR.TV.ChannelList', function (obj){ if (!obj.state.ack) { if ("undefined" !== typeof MySonyTV.channel[0]){ MySonyTV.avContent.setPlayContent([{uri:MySonyTV.channel[obj.state.val].uri}]) MySonyTV.avContent.getPlayingContentInfo([]); } else { MySonyTV.avContent.getContentList([{source:"tv:dvbc",target:"",type:"",cnt:50,stIdx:""}]) //setState('javascript.0.Sony_Bravia_VAR.TV.ChannelList',val=obj.oldState.val,akt=false) } } })
!
on('javascript.0.Sony_Bravia_VAR.TV.Channel', function (obj){
if (!obj.state.ack) {
if(obj.state.val>=1){
//console.log (typeof MySonyTV.channel[0])
if ("undefined" !== typeof MySonyTV.channel[0]){MySonyTV.avContent.setPlayContent([{uri:MySonyTV.channel[obj.state.val-1].uri}]); MySonyTV.avContent.getPlayingContentInfo([]); } else { MySonyTV.avContent.getContentList([{source:"tv:dvbc",target:"",type:"",cnt:50,stIdx:""}]) } } }
});
on('javascript.0.Sony_Bravia_VAR.Audio.SpeakerVolume', function (obj){ if (!obj.state.ack) { MySonyTV.audio.setAudioVolume([{target:"speaker",volume:obj.state.val.toString()}]) MySonyTV.audio.getVolumeInformation([]) }
});
on('javascript.0.Sony_Bravia_VAR.Audio.SpeakerMute', function (obj){ MySonyTV.audio.setAudioMute([{status:obj.state.val}]) MySonyTV.audio.getVolumeInformation([])
}); //
on({id:'javascript.0.Sony_Bravia_VAR.Audio.SpeakerVolume_UP',val:true}, function (obj){ if (!obj.state.ack) { var vol=getState('javascript.0.Sony_Bravia_VAR.Audio.SpeakerVolume').val if(vol<100){ vol++ MySonyTV.audio.setAudioVolume([{target:"speaker",volume:vol.toString()}]) } MySonyTV.audio.getVolumeInformation([]) }
});
on({id:'javascript.0.Sony_Bravia_VAR.Audio.SpeakerVolume_DOWN',val:true}, function (obj){
if (!obj.state.ack) {
var vol=getState('javascript.0.Sony_Bravia_VAR.Audio.SpeakerVolume').val
if(vol>0){
vol--
MySonyTV.audio.setAudioVolume([{target:"speaker",volume:vol.toString()}])
}
MySonyTV.audio.getVolumeInformation([])
}
});on('javascript.0.Sony_Bravia_VAR.Power', function (obj){
if (!obj.state.ack) { if (obj.state.val===false){MySonyTV.system.setPowerStatus([{status:false}])} else{ var wol = require('wake_on_lan'); wol.wake(getState('javascript.0.Sony_Bravia_VAR.System.MAC_Adresse').val, function(error) { if(!error){setState('javascript.0.Sony_Bravia_VAR.Power',true,akt=true)} else{console.error('Fehler beim Einschalten(WOL)')} }); } } //MySonyTV.system.getPowerStatus([]);
});
on( {id:'javascript.0.Sony_Bravia_VAR.System.Update',val:true}, function (obj){
update()! });
on( {id:'javascript.0.Sony_Bravia_VAR.Control.Play',val:true}, function (obj){ MySonyTV.IRCC.setIRCC('AAAAAgAAAJcAAAAaAw==')
! });
on( {id:'javascript.0.Sony_Bravia_VAR.Control.Stop',val:true}, function (obj){ MySonyTV.IRCC.setIRCC('AAAAAgAAAJcAAAAYAw==')
! });
! on( {id:'javascript.0.Sony_Bravia_VAR.Control.Pause',val:true}, function (obj){
MySonyTV.IRCC.setIRCC('AAAAAgAAAJcAAAAZAw==')
! });` [/i][/i][/i] -
Hallo,
endlich mal was für den Bravia. Danke dafür.
Leider läuft das Script bei mir nicht. Nach dem Start kommen im Log diese Fehlermeldungen:
! javascript.0 2017-06-14 10:14:36.852 error at script.js.common.Bravia_TV.Steuerung:314:2
! javascript.0 2017-06-14 10:14:36.852 error at Authorization (script.js.common.Bravia_TV.Steuerung:329:30)
! javascript.0 2017-06-14 10:14:36.852 error at Object.MySonyTV.accessControl.actRegister (script.js.common.Bravia_TV.Steuerung:112:65)
! javascript.0 2017-06-14 10:14:36.852 error at Object.MySonyTV.Send (script.js.common.Bravia_TV.Steuerung:144:48)
! javascript.0 2017-06-14 10:14:36.852 error at Function.from (native)
! javascript.0 2017-06-14 10:14:36.852 error script.js.common.Bravia_TV.Steuerung: TypeError: this is not a typed array.Meine Javascript Kenntnisse sind leider zu begrenzt um das richtig zu interpretieren.
-
Coole Sache.
Das Auslesen meines Fernsehers klappt schon mal.
Nur die Lautstärke wir am Fernseher als geändert angezeigt, ändert sich aber nicht. Das liegt vermutlich an der angeschlossenen Soundbar von Sonos.
-
> Leider läuft das Script bei mir nicht. Nach dem Start kommen im Log diese Fehlermeldungen:
Speichere das Skript bitte nicht unter Common, sondern in einer extra Gruppe, z.b. "Sony_Bravia" starte dann den Javaskript Adapter neu und versuch es nochmal !
Was für ein Bravia Modell hast du ?
> Nur die Lautstärke wir am Fernseher als geändert angezeigt, ändert sich aber nicht. Das liegt vermutlich an der angeschlossenen Soundbar von Sonos.
ja das ist bei mir auch so, die TV Lautstärker hat nur auswirkungen auf den TV eigenen Lautsprecher, und wirkt nicht auf CEC Geräte !
Über CEC Steuerung ist in der API auch nicht viel vorhanden
-
Danke für die Rückmeldung.
Mein Bravia ist ein KDL-55EX505
Ich habe unter "common" eine Gruppe "Bravia _TV" angelegt in der das Script liegt. Der Neustart des Adapters hat leider an den Fehlermeldungen nix geändert.
Schade auch.
Über den upnp Adapter kann ich mit dem Bravia reden, allerdings nur Lautstärke nd Mute.
-
speichere bitte nicht unter Common ! lege direkt eine neue Gruppe an !
2611_sony_skript.jpg -
Hat leider auch nix geholfen. Immer noch die gleichen Fehler im Log
-
Hallo,
habe auch den 805 und versuche, das Script zum Laufen zu bekommen.
Wo trage ich die IP ein? Ist das so korrekt?
createState('javascript.0.Sony_Bravia_VAR.System.IP_Adresse','192.168.2.248',{type: "string", role: "IP Adresse"});
Original war das so:
createState('javascript.0.Sony_Bravia_VAR.System.IP_Adresse',{type: "string", role: "IP Adresse"});
Danke & Grüße Mighty
-
Hallo,
ich habe das Skript bei mir im Einsatz. Das Ausschalten des Fernsehers geht über das Setzen der Datenpunktes "Power" auf false. (Kann gerade nicht nachsehen, ob er wirklich so heißt)
Kann ich den Fernseher darüber auch wieder einschalten? Das will mir nicht gelingen. Muß ich evtl. am Fernsher noch etwas einstellen?
Gibt es vielleicht schon eine neuere Version des Skriptes?
-
Hallo,
ich habe das Skript bei mir im Einsatz. Das Ausschalten des Fernsehers geht über das Setzen der Datenpunktes "Power" auf false. (Kann gerade nicht nachsehen, ob er wirklich so heißt)
Kann ich den Fernseher darüber auch wieder einschalten? Das will mir nicht gelingen. Muß ich evtl. am Fernsher noch etwas einstellen?
Gibt es vielleicht schon eine neuere Version des Skriptes? `
Hi tesso,
wo hast du denn die IP eingetragen und welche Infos muss man dem Skript noch geben? Bekomme es garnicht erst zum Starten.
Grüße Mighty
-
Ich habe mich einfach an die Vorgehensweise aus dem ersten Post gehalten.
Die IP habe ich im Datenpunkt für die IP eingetragen. Ich komme leider im Moment nicht auf mein System (bin unterwegs). Evtl. kann ich nachher nachschauen.
-
Wäre super, wenn du da nochmal nachschauen könntest.
Datenpunkt?
Grüße Mighty
-
System - IP Adresse
Nicht zu verfehlen
-
System - IP Adresse
Nicht zu verfehlen `
Ok. Danke. Wo finde ich den Benutzernamen?
Habe folgendes eingetragen:
createState('javascript.0.Sony_Bravia_VAR.Authorization.User','Mighty',{type: "string", role: "User"}); //System createState('javascript.0.Sony_Bravia_VAR.System.IP_Adresse','192.168.2.248',{type: "string", role: "IP Adresse"});
Bekomme folgende Fehlermeldungen:
5:59:30.270 [info] javascript.0 script.js.Sony_Bravia.Main: Anfrage{"id":40,"method":"actRegister","params":[{"clientid":"","nickname":""},[{"clientid":"","value":"yes","nickname":"","function":"WOL"}]],"version":"1.0"} 15:59:30.270 [info] javascript.0 script.js.Sony_Bravia.Main: Anfrage{"id":40,"method":"actRegister","params":[{"clientid":"","nickname":""},[{"clientid":"","value":"yes","nickname":"","function":"WOL"}]],"version":"1.0"} 15:59:30.270 [info] javascript.0 script.js.Sony_Bravia.Main: Anfrage{"id":40,"method":"actRegister","params":[{"clientid":"","nickname":""},[{"clientid":"","value":"yes","nickname":"","function":"WOL"}]],"version":"1.0"} 15:59:30.270 [info] javascript.0 script.js.Sony_Bravia.Main: registered 25 subscriptions and 0 schedules 15:59:30.270 [info] javascript.0 script.js.Sony_Bravia.Main: registered 25 subscriptions and 0 schedules 15:59:30.270 [info] javascript.0 script.js.Sony_Bravia.Main: registered 25 subscriptions and 0 schedules 15:59:32.543 [info] javascript.0 script.js.Sony_Bravia.Main: Error: getaddrinfo ENOTFOUND null null:80 15:59:32.543 [info] javascript.0 script.js.Sony_Bravia.Main: Error: getaddrinfo ENOTFOUND null null:80 15:59:32.543 [info] javascript.0 script.js.Sony_Bravia.Main: Error: getaddrinfo ENOTFOUND null null:80
Hat jemand eine Idee, was hier falsch läuft?
Grüße Mighty
-
Der Username ist etwas irreführend. gemeint ist der "Vorsinstallierte Schlüssel" den du ihm Fernseher einstellen musst.
-
So, jetzt läuft es. Ich hatte die Daten direkt unter 'Skripte' im Code eingetragen. War aber falsch.
Man muss unter Objekte ->
javascript.0.Sony_Bravia_VAR.System und .Authorization seine Daten eintragen. Dann klappt's.
Wie man an was kommt, ist hier beschrieben:
https://github.com/alanreid/bravia
Danke & Grüße Mighty
ps jetzt fehlt nur noch der MR400 der Telekom für EntertainTV.
-
Moin Moin,
ich habe mal wider etwas an dem Skript gearbeitet
1.Durch einen Update Intervall werden die States jetzt auch Aktualisiert wenn mit der Fernbedienung bedient wurde
2. Verbesserungen und Fehler behoben
hier die neue Version
! ```
`createState('javascript.0.Sony_Bravia_VAR.Authorization.PIN_Anfordern', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Authorization.Cookie', 'init',{type: "string", role: "Cookie",write:false});
createState('javascript.0.Sony_Bravia_VAR.Authorization.PIN', 0,{type: "number", role: "PIN"});
createState('javascript.0.Sony_Bravia_VAR.Authorization.Status', false,{type: "boolean", role: "Erfolgreich",write:false});
createState('javascript.0.Sony_Bravia_VAR.Authorization.User','',{type: "string", role: "User"});
//System
createState('javascript.0.Sony_Bravia_VAR.System.IP_Adresse',{type: "string", role: "IP Adresse"});
createState('javascript.0.Sony_Bravia_VAR.System.MAC_Adresse',{type: "string", role: "MAC Adresse",write:false});
createState('javascript.0.Sony_Bravia_VAR.System.Generation',{type: "string", role: "Generation",write:false});
createState('javascript.0.Sony_Bravia_VAR.System.Language',{type: "string", role: "Language",write:false});
createState('javascript.0.Sony_Bravia_VAR.System.Model',{type: "string", role: "Model",write:false});
createState('javascript.0.Sony_Bravia_VAR.System.Name',{type: "string", role: "Name",write:false});
createState('javascript.0.Sony_Bravia_VAR.System.Product',{type: "string", role: "Product",write:false});
createState('javascript.0.Sony_Bravia_VAR.System.Serial',{type: "string", role: "Serial",write:false});
createState('javascript.0.Sony_Bravia_VAR.System.Update', 0,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Power', false,{type: "boolean", role: "Power"});
//Control
createState('javascript.0.Sony_Bravia_VAR.Control.Play', false,{type:"boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Control.Stop', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Control.Pause', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Control.Skip_Plus', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Control.Skip_Minus', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Control.Page_Next', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Control.Page_Previous', false,{type: "boolean", role: "button"});
//Input
createState('javascript.0.Sony_Bravia_VAR.Input.InputsStatus', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Input.ActivInput', false,{type: "string", role: "ActivInput"});
createState('javascript.0.Sony_Bravia_VAR.Input.HDMI1', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Input.HDMI2', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Input.HDMI3', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Input.HDMI4', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Input.SetTV', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Input.AV1', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Input.AV2', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Input.BildschirmSpiegeln', false,{type: "boolean", role: "button"});
//TV
createState('javascript.0.Sony_Bravia_VAR.TV.Channel', 0,{type: "number", role: "Channel"});
createState('javascript.0.Sony_Bravia_VAR.TV.ProgrammTitel',{type: "string", role: "ProgrammTitel",write:false});
createState('javascript.0.Sony_Bravia_VAR.TV.Länge',{type: "number", role: "Länge (Minuten)",write:false});
createState('javascript.0.Sony_Bravia_VAR.TV.Startzeit',{type: "string", role: "Startzeit",write:false});
createState('javascript.0.Sony_Bravia_VAR.TV.SenderLesen', false,{type: "boolean", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.TV.ChannelList',0,{type: "number", role: "Channel List",states:"0:none"});
createState('javascript.0.Sony_Bravia_VAR.TV.SenderName',{type: "string", role: "Sendername",write:false});
//Audio
createState('javascript.0.Sony_Bravia_VAR.Audio.SpeakerVolume', 0,{type: "number", role: " SpeakerVolume"});
createState('javascript.0.Sony_Bravia_VAR.Audio.SpeakerVolume_UP', 0,{type: "number", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Audio.SpeakerVolume_DOWN', 0,{type: "number", role: "button"});
createState('javascript.0.Sony_Bravia_VAR.Audio.HeadphoneVolume', 0,{type: "number", role: " HeadphoneVolume",write:false});
createState('javascript.0.Sony_Bravia_VAR.Audio.SpeakerMute', false,{type: "boolean", role: "SpeakerMute"});
! var request = require('request');
! var MySonyTV = {
ip:'',
mac:'',
pin:0,
auth:'',
body:{},
channel:{},
sony:{id:1,method:'',params:[],version:'1.0'},system: { getColorKeysLayout:function (val) {return MySonyTV.Send(1,'system','getColorKeysLayout',val)}, getCurrentTime:function (val) {return MySonyTV.Send(2,'system','getCurrentTime',val)}, getDateTimeFormat:function (val) {return MySonyTV.Send(3,'system','getDateTimeFormat',val)}, getInterfaceInformation:function (val) {return MySonyTV.Send(4,'system','getInterfaceInformation',val)}, getMethodTypes:function (val) {return MySonyTV.Send(5,'system','getMethodTypes',val)}, getPostalCode:function (val) {return MySonyTV.Send(6,'system','getPostalCode',val)}, getPowerSavingMode:function (val) {return MySonyTV.Send(7,'system','getPowerSavingMode',val)}, getPowerStatus:function (val) {return MySonyTV.Send(8,'system','getPowerStatus',val)}, getRemoteControllerInfo:function (val) {return MySonyTV.Send(9,'system','getRemoteControllerInfo',val)}, getSystemInformation:function (val) {return MySonyTV.Send(10,'system','getSystemInformation',val)}, getSystemSupportedFunction:function (val) {return MySonyTV.Send(11,'system','getSystemSupportedFunction',val)}, getVersions:function (val) {return MySonyTV.Send(12,'system','getVersions',val)}, getWolMode:function (val) {return MySonyTV.Send(13,'system','getWolMode',val)}, requestToNotifyDeviceStatus:function (val) {return MySonyTV.Send(14,'system','requestToNotifyDeviceStatus',val)}, setCurrentTime:function (val) {return MySonyTV.Send(15,'system','setCurrentTime',val)}, setLEDIndicatorStatus:function (val) {return MySonyTV.Send(16,'system','setLEDIndicatorStatus',val)}, setLanguage:function (val) {return MySonyTV.Send(17,'system','setLanguage',val)}, setPostalCode:function (val) {return MySonyTV.Send(18,'system','setPostalCode',val)}, setPowerSavingMode:function (val) {return MySonyTV.Send(19,'system','setPowerSavingMode',val)}, setPowerStatus:function (val) {return MySonyTV.Send(20,'system','setPowerStatus',val)}, setWolMode:function (val) {return MySonyTV.Send(21,'system','setWolMode',val)}, }, avContent:{ deleteContent:function (val) {return MySonyTV.Send(22,'avContent','deleteContent',val)}, getContentCount:function (val) {return MySonyTV.Send(23,'avContent','getContentCount',val)}, getContentList:function (val) {return MySonyTV.Send(24,'avContent','getContentList',val)}, getCurrentExternalInputsStatus:function (val) {return MySonyTV.Send(25,'avContent','getCurrentExternalInputsStatus',val)}, getMethodTypes:function (val) {return MySonyTV.Send(26,'avContent','getMethodTypes',val)}, getParentalRatingSettings:function (val) {return MySonyTV.Send(27,'avContent','getParentalRatingSettings',val)}, getPlayingContentInfo:function (val) {return MySonyTV.Send(28,'avContent','getPlayingContentInfo',val)}, getSchemeList:function (val) {return MySonyTV.Send(29,'avContent','getSchemeList',val)}, getSourceList:function (val) {return MySonyTV.Send(30,'avContent','getSourceList',val)}, getVersions:function (val) {return MySonyTV.Send(31,'avContent','getVersions',val)}, setDeleteProtection:function (val) {return MySonyTV.Send(32,'avContent','setDeleteProtection',val)}, setPlayContent:function (val) {return MySonyTV.Send(33,'avContent','setPlayContent',val)}, setPlayTvContent:function (val) {return MySonyTV.Send(34,'avContent','setPlayTvContent',val)}, }, audio:{ getMethodTypes:function (val) {return MySonyTV.Send(35,'audio','getMethodTypes',val)}, getVersions:function (val) {return MySonyTV.Send(36,'audio','getVersions',val)}, getVolumeInformation:function (val) {return MySonyTV.Send(37,'audio','getVolumeInformation',val)}, setAudioMute:function (val) {return MySonyTV.Send(38,'audio','setAudioMute',val)}, setAudioVolume:function (val) {return MySonyTV.Send(39,'audio','setAudioVolume',val)}, }, accessControl:{ actRegister:function (val) {return MySonyTV.Send(40,'accessControl','actRegister',val)}, getMethodTypes:function (val) {return MySonyTV.Send(41,'accessControl','getMethodTypes',val)}, getVersions:function (val) {return MySonyTV.Send(42,'accessControl','getVersions',val)}, }, IRCC: { setIRCC:function (val) {return MySonyTV.Send(255,'IRCC','setIRCC',val)}, }, Send: function(id,service,method,params) { this.sony.method=method; this.sony.params=params; this.sony.id=id; this.ip=getState('javascript.0.Sony_Bravia_VAR.System.IP_Adresse').val;
! var j = request.jar();
var cookie = request.cookie(this.auth);
var FormData;if(service!='IRCC'){FormData=JSON.stringify(this.sony)} else{FormData='<ircccode>'+params+'</ircccode>'; console.log('IRCC'); }
//##############################################################################
// Configure the request
var options = {
url: 'http://'+this.ip+'/sony/'+service,
jar: true,
method: 'POST',
headers: {'Authorization':'Basic '+ Buffer.from(':'+this.pin).toString('base64')},
form:FormData
};! console.log('Anfrage'+options.form);
! j.setCookie(cookie,options.url);
! // Start the request
request(options, function (error, response, body) {
! if(!error){ // && response.statusCode == 200//------------------------------------------------------------------------------- if ("undefined" !== typeof body&&service!='IRCC'){ console.log('Body '+body); this.body=JSON.parse(body); if ("undefined" !== typeof this.body.error){ if(this.body.error[1]=='not power-on'){ setState('javascript.0.Sony_Bravia_VAR.Power',val=false,akt=true); setTimeout(MySonyTV.system.getPowerStatus,10000,[]); //neu (20.07.17) } else if(this.body.error[1]=='Unauthorized'){ setState('javascript.0.Sony_Bravia_VAR.Authorization.Status',val=false,akt=true); setState('javascript.0.Sony_Bravia_VAR.Authorization.PIN',val=0,akt=false); console.warn('##############################Unauthorized##############################'); this.auth=''; setState('javascript.0.Sony_Bravia_VAR.Authorization.Cookie',val= this.auth); } else if(this.body.error[1]=="not register any more"){ setState('javascript.0.Sony_Bravia_VAR.Authorization.Status',val=false,akt=true); } console.log(this.body.error[1]); } else { if ("undefined" !== typeof this.body.auth_url){ //tritt ein wenn keinCookie vorhanden oder abgelaufen/falsch ist setState('javascript.0.Sony_Bravia_VAR.Authorization.Status',val=false,akt=true); console.log('Sony TV Authorization abgelaufen ! '); //Authorization(); //kann probleme machen, endlosschleife } if ("undefined" !== typeof this.body.id){ switch(this.body.id){ case 40://actRegister //cookie string zerlegen, krücke, aber gehr ;-) --------------------------------- if ("undefined" !== typeof response.headers['set-cookie']){ //wenn objekt definiert ist var C=JSON.stringify(response.headers['set-cookie']).split(';'); C=C[0].split('"'); this.auth=C[1]; setState('javascript.0.Sony_Bravia_VAR.Authorization.Cookie',val=this.auth,akt=true); }//end if if ("undefined" !== typeof this.body.result){ //positive Antwort auf ActRegister if (this.body.result.length===0){ setState('javascript.0.Sony_Bravia_VAR.Authorization.Status',val=true,akt=true); setState('javascript.0.Sony_Bravia_VAR.Authorization.PIN',val=0,akt=true); update(); } } break; case 8://getPowerStatus if(this.body.result[0].status=='active'){ setState('javascript.0.Sony_Bravia_VAR.Power',val=true,akt=true) if(getState('javascript.0.Sony_Bravia_VAR.Authorization.Status').val===true){ if ("undefined" == typeof Intervall){ Intervall=setInterval(updateStatus,5000); } else if (Intervall._idleTimeout<0){Intervall=setInterval(updateStatus,5000)}; } } else if(this.body.result[0].status=='standby'){ setState('javascript.0.Sony_Bravia_VAR.Power',val=false,akt=true) setTimeout(MySonyTV.system.getPowerStatus,10000,[]); //neu (20.07.17) if ("undefined" !== typeof Intervall && Intervall._idleTimeout>0 ){ clearInterval(Intervall) } } break; case 10://getSystemInformation this.mac=this.body.result[0].macAddr; setState('javascript.0.Sony_Bravia_VAR.System.MAC_Adresse',val=this.body.result[0].macAddr,akt=true); setState('javascript.0.Sony_Bravia_VAR.System.Generation',val=this.body.result[0].generation,akt=true); setState('javascript.0.Sony_Bravia_VAR.System.Language',val=this.body.result[0].language,akt=true); setState('javascript.0.Sony_Bravia_VAR.System.Model',val=this.body.result[0].model,akt=true); setState('javascript.0.Sony_Bravia_VAR.System.Name',val=this.body.result[0].name,akt=true); setState('javascript.0.Sony_Bravia_VAR.System.Product',val=this.body.result[0].product,akt=true); setState('javascript.0.Sony_Bravia_VAR.System.Serial',val=this.body.result[0].serial,akt=true); break; case 37://getVolumeInformation setState('javascript.0.Sony_Bravia_VAR.Audio.SpeakerVolume',val=this.body.result[0][0].volume,akt=true); setState('javascript.0.Sony_Bravia_VAR.Audio.HeadphoneVolume',val=this.body.result[0][1].volume,akt=true); setState('javascript.0.Sony_Bravia_VAR.Audio.SpeakerMute',val=this.body.result[0][0].mute,akt=true); break; case 24://getContentList' //var channels=this.body.result[0]; MySonyTV.channel=this.body.result[0]; var StateString=''; for(var i = 0; i < 20; i++) { //MySonyTV.channel.length geht nicht da mehr als 50 Sender StateString=StateString+i.toString()+':'+MySonyTV.channel[i].title+';'; //StateString=StateString+i.toString()+':'+channels[i].title+';'; } var obj = getObject('javascript.0.Sony_Bravia_VAR.TV.ChannelList'); obj.common.states = StateString; setObject('javascript.0.Sony_Bravia_VAR.TV.ChannelList', obj); break; case 28://getPlayingContentInfo': if ("undefined" !== typeof this.body.result[0].source){ setState('javascript.0.Sony_Bravia_VAR.Input.ActivInput',this.body.result[0].source,akt=true); if (this.body.result[0].source=='extInput:hdmi'&&this.body.result[0].title=='HDMI 1'){setState('javascript.0.Sony_Bravia_VAR.Input.HDMI1',true,akt=true)} else if (this.body.result[0].source=='extInput:hdmi'&&this.body.result[0].title=='HDMI 2'){setState('javascript.0.Sony_Bravia_VAR.Input.HDMI2',true,akt=true)} else if (this.body.result[0].source=='extInput:hdmi'&&this.body.result[0].title=='HDMI 3'){setState('javascript.0.Sony_Bravia_VAR.Input.HDMI3',true,akt=true)} else if (this.body.result[0].source=='extInput:hdmi'&&this.body.result[0].title=='HDMI 4'){setState('javascript.0.Sony_Bravia_VAR.Input.HDMI4',true,akt=true)} else if (this.body.result[0].source=='tv:dvbc'){setState('javascript.0.Sony_Bravia_VAR.Input.SetTV',true,akt=true)}; }; if ("undefined" !== typeof this.body.result[0].programTitle){setState('javascript.0.Sony_Bravia_VAR.TV.ProgrammTitel',val=this.body.result[0].programTitle,akt=true)}; if ("undefined" !== typeof this.body.result[0].durationSec){setState('javascript.0.Sony_Bravia_VAR.TV.Länge',val=parseFloat(this.body.result[0].durationSec)/60,akt=true)}; if ("undefined" !== typeof this.body.result[0].startDateTime){setState('javascript.0.Sony_Bravia_VAR.TV.Startzeit',val=this.body.result[0].startDateTime,akt=true)}; if ("undefined" !== typeof this.body.result[0].title){setState('javascript.0.Sony_Bravia_VAR.TV.SenderName',val=this.body.result[0].title,akt=true)}; if ("undefined" !== typeof this.body.result[0].uri){ if ("undefined" !== typeof MySonyTV.channel[0]){ for(var i=0; i < MySonyTV.channel.length; i++){ if(MySonyTV.channel[i].uri==this.body.result[0].uri){ setState('javascript.0.Sony_Bravia_VAR.TV.ChannelList',val=i,akt=true) setState('javascript.0.Sony_Bravia_VAR.TV.Channel',val=i,akt=true) break; } } } }; break; default: break; }// end of Switch }// if id undefined }// end else } // end if undefined
}//end if !error
else{
console.log(error) //oder ETIMEDOUT
if(error.code=='EHOSTUNREACH'||"ETIMEDOUT"){setState('javascript.0.Sony_Bravia_VAR.Power',false,akt=true) if ("undefined" !== typeof Intervall){clearInterval(Intervall)} setTimeout(MySonyTV.system.getPowerStatus,10000,[]); console.log('##############################TV AUS ODER NICHT ERREICHBAR ##############################')
}
!
!
}
! }) ; // end of Requestreturn;
} // end of Function Send
}; // end of Object MySonyTV
//##############################################################################! Authorization() // Initiale abfrage bei Skript Start !!
! function update(){
MySonyTV.avContent.getContentList([{source:"tv:dvbc",target:"",type:"",cnt:50,stIdx:""}]);
MySonyTV.system.getSystemInformation([]);
MySonyTV.system.getPowerStatus([]);
MySonyTV.avContent.getPlayingContentInfo([])
MySonyTV.avContent.getCurrentExternalInputsStatus([]);
MySonyTV.audio.getVolumeInformation([])
}//end update
! function updateStatus (){
console.log('######################################################### UPDATE TV STATUS ###########################################################')
MySonyTV.system.getPowerStatus([]);
MySonyTV.avContent.getPlayingContentInfo([])
//MySonyTV.avContent.getCurrentExternalInputsStatus([]);
MySonyTV.audio.getVolumeInformation([])
! }
! function Authorization(){
var user =getState('javascript.0.Sony_Bravia_VAR.Authorization.User').val
data= [{clientid:user,nickname:user},[{clientid:user,value:'yes',nickname:user,function:'WOL'}]];
MySonyTV.accessControl.actRegister(data);
}
! var data;
! on({id:'javascript.0.Sony_Bravia_VAR.Authorization.Status',change:'any'}, function (obj){if (obj.state.val===true){ if(getState('javascript.0.Sony_Bravia_VAR.Power').val===true){ if ("undefined" == typeof Intervall){Intervall=setInterval(updateStatus,5000)}; } } else{ if ("undefined" !== typeof Intervall){clearInterval(Intervall)} }
});
! on({id:'javascript.0.Sony_Bravia_VAR.System.IP_Adresse',change:"any"}, function (obj){
MySonyTV.ip=obj.state.val
MySonyTV.system.getSystemInformation([]);}) ;
! on({id:'javascript.0.Sony_Bravia_VAR.Authorization.PIN_Anfordern',val:true}, function (obj){
if(getState('javascript.0.Sony_Bravia_VAR.Authorization.User').val.length>=1){
Authorization()
}
}) ;on('javascript.0.Sony_Bravia_VAR.Authorization.PIN', function (obj){
if (!obj.state.ack) {
MySonyTV.pin=obj.state.val;
Authorization()
}});
on({id:'javascript.0.Sony_Bravia_VAR.Input.InputsStatus',val:true}, function (obj){
MySonyTV.avContent.getCurrentExternalInputsStatus([]);
//MySonyTV.avContent.getPlayingContentInfo([]);
//MySonyTV.avContent.getSchemeList([]);
//MySonyTV.avContent.getSourceList([{scheme:'tv'}]);
//MySonyTV.system.getRemoteControllerInfo([])
//MySonyTV.audio.getMethodTypes(['1.0']);});
on({id:'javascript.0.Sony_Bravia_VAR.Input.HDMI1',val:true}, function (obj){ if (!obj.state.ack) { if (obj.state.val===true){ MySonyTV.avContent.setPlayContent([{uri:'extInput:hdmi?port=1'}]); MySonyTV.avContent.getPlayingContentInfo([]); } }
});
on({id:'javascript.0.Sony_Bravia_VAR.Input.HDMI2',val:true}, function (obj){ if (!obj.state.ack) { if (obj.state.val===true){ MySonyTV.avContent.setPlayContent([{uri:'extInput:hdmi?port=2'}]); MySonyTV.avContent.getPlayingContentInfo([]); } }
});
on({id:'javascript.0.Sony_Bravia_VAR.Input.HDMI3',val:true}, function (obj){ if (!obj.state.ack) { if (obj.state.val===true){ MySonyTV.avContent.setPlayContent([{uri:'extInput:hdmi?port=3'}]); MySonyTV.avContent.getPlayingContentInfo([]); } }
});
on({id:'javascript.0.Sony_Bravia_VAR.Input.HDMI4',val:true}, function (obj){ if (!obj.state.ack) { if (obj.state.val===true){ MySonyTV.avContent.setPlayContent([{uri:'extInput:hdmi?port=4'}]); MySonyTV.avContent.getPlayingContentInfo([]); } }
});
on({id:'javascript.0.Sony_Bravia_VAR.Input.SetTV',val:true}, function (obj){ if (!obj.state.ack) { if (obj.state.val===true){ MySonyTV.avContent.setPlayContent([{uri:'tv:'}]); MySonyTV.avContent.getPlayingContentInfo([]); } }
});
on({id:'javascript.0.Sony_Bravia_VAR.Input.AV1',val:true}, function (obj){ if (!obj.state.ack) { if (obj.state.val===true){ MySonyTV.avContent.setPlayContent([{uri:'extInput:scart?port=1'}]); MySonyTV.avContent.getPlayingContentInfo([]); } }
});
on({id:'javascript.0.Sony_Bravia_VAR.Input.AV2',val:true}, function (obj){ if (!obj.state.ack) { if (obj.state.val===true){ MySonyTV.avContent.setPlayContent([{uri:'extInput:composite?port=1'}]); MySonyTV.avContent.getPlayingContentInfo([]); } }
});
on({id:'javascript.0.Sony_Bravia_VAR.BildschirmSpiegeln',val:true}, function (obj){ if (!obj.state.ack) { if (obj.state.val===true){ MySonyTV.avContent.setPlayContent([{uri:'extInput:widi?port=1'}]); MySonyTV.avContent.getPlayingContentInfo([]); } }
});
on({id: 'javascript.0.Sony_Bravia_VAR.TV.SenderLesen', val: true}, function (obj){ MySonyTV.avContent.getContentList([{source:"tv:dvbc",target:"",type:"",cnt:50,stIdx:""}]) MySonyTV.avContent.getPlayingContentInfo([]);
});
on( 'javascript.0.Sony_Bravia_VAR.TV.ChannelList', function (obj){ if (!obj.state.ack) { if ("undefined" !== typeof MySonyTV.channel[0]){ MySonyTV.avContent.setPlayContent([{uri:MySonyTV.channel[obj.state.val].uri}]) MySonyTV.avContent.getPlayingContentInfo([]); } else { MySonyTV.avContent.getContentList([{source:"tv:dvbc",target:"",type:"",cnt:50,stIdx:""}]) //setState('javascript.0.Sony_Bravia_VAR.TV.ChannelList',val=obj.oldState.val,akt=false) } } })
!
on('javascript.0.Sony_Bravia_VAR.TV.Channel', function (obj){
if (!obj.state.ack) {
if(obj.state.val>=1){
//console.log (typeof MySonyTV.channel[0])
if ("undefined" !== typeof MySonyTV.channel[0]){MySonyTV.avContent.setPlayContent([{uri:MySonyTV.channel[obj.state.val-1].uri}]); MySonyTV.avContent.getPlayingContentInfo([]); } else { MySonyTV.avContent.getContentList([{source:"tv:dvbc",target:"",type:"",cnt:50,stIdx:""}]) } } }
});
on('javascript.0.Sony_Bravia_VAR.Audio.SpeakerVolume', function (obj){ if (!obj.state.ack) { MySonyTV.audio.setAudioVolume([{target:"speaker",volume:obj.state.val.toString()}]) MySonyTV.audio.getVolumeInformation([]) }
});
on('javascript.0.Sony_Bravia_VAR.Audio.SpeakerMute', function (obj){ MySonyTV.audio.setAudioMute([{status:obj.state.val}]) MySonyTV.audio.getVolumeInformation([])
}); //
on({id:'javascript.0.Sony_Bravia_VAR.Audio.SpeakerVolume_UP',val:true}, function (obj){ if (!obj.state.ack) { var vol=getState('javascript.0.Sony_Bravia_VAR.Audio.SpeakerVolume').val if(vol<100){ vol++ MySonyTV.audio.setAudioVolume([{target:"speaker",volume:vol.toString()}]) } MySonyTV.audio.getVolumeInformation([]) }
});
on({id:'javascript.0.Sony_Bravia_VAR.Audio.SpeakerVolume_DOWN',val:true}, function (obj){
if (!obj.state.ack) {
var vol=getState('javascript.0.Sony_Bravia_VAR.Audio.SpeakerVolume').val
if(vol>0){
vol--
MySonyTV.audio.setAudioVolume([{target:"speaker",volume:vol.toString()}])
}
MySonyTV.audio.getVolumeInformation([])
}
});on('javascript.0.Sony_Bravia_VAR.Power', function (obj){
if (!obj.state.ack) {
if (obj.state.val===false){
MySonyTV.system.setPowerStatus([{status:false}])
//if ("undefined" !== typeof Intervall){clearInterval(Intervall)}
}
else{
var wol = require('wake_on_lan');
wol.wake(getState('javascript.0.Sony_Bravia_VAR.System.MAC_Adresse').val, function(error) {
if(!error){
//setState('javascript.0.Sony_Bravia_VAR.Power',true,akt=true)
console.log('############################## TV WIRD EINGESCHALTET ##############################')setTimeout(MySonyTV.system.getPowerStatus,5000,[]); //5s nach WOL Packet Powerstatus abfragen (20.07.17) } else{console.error('Fehler beim Einschalten(WOL)')} }); } } else{}
! });
on( {id:'javascript.0.Sony_Bravia_VAR.System.Update',val:true}, function (obj){
update()! });
on( {id:'javascript.0.Sony_Bravia_VAR.Control.Play',val:true}, function (obj){ MySonyTV.IRCC.setIRCC('AAAAAgAAAJcAAAAaAw==')
! });
on( {id:'javascript.0.Sony_Bravia_VAR.Control.Stop',val:true}, function (obj){ MySonyTV.IRCC.setIRCC('AAAAAgAAAJcAAAAYAw==')
! });
! on( {id:'javascript.0.Sony_Bravia_VAR.Control.Pause',val:true}, function (obj){
MySonyTV.IRCC.setIRCC('AAAAAgAAAJcAAAAZAw==')
! });` [/i][/i][/i] -
Hallo,
bekomme folgende Fehlermeldung:
host.loxberry 2017-09-21 21:14:22.240 error instance system.adapter.javascript.0 terminated with code 0 (OK)
javascript.0 2017-09-21 21:14:22.208 info terminating
javascript.0 2017-09-21 21:14:22.181 error at emitNone (events.js:91:20)
javascript.0 2017-09-21 21:14:22.181 error at IncomingMessage.g (events.js:292:16)
javascript.0 2017-09-21 21:14:22.181 error at IncomingMessage. (/opt/iobroker/node_modules/request/request.js:1085:12)
javascript.0 2017-09-21 21:14:22.181 error at Request.emit (events.js:188:7)
javascript.0 2017-09-21 21:14:22.181 error at emitOne (events.js:96:13)
javascript.0 2017-09-21 21:14:22.181 error at Request. (/opt/iobroker/node_modules/request/request.js:1163:10)
javascript.0 2017-09-21 21:14:22.181 error at Request.emit (events.js:191:7)
javascript.0 2017-09-21 21:14:22.181 error at emitTwo (events.js:106:13)
javascript.0 2017-09-21 21:14:22.181 error at Request.self.callback (/opt/iobroker/node_modules/request/request.js:186:22)
javascript.0 2017-09-21 21:14:22.181 error at Request._callback (script.js.Sony_Bravia.Main:270:110)
javascript.0 2017-09-21 21:14:22.181 error TypeError: Cannot read property 'title' of undefined
javascript.0 2017-09-21 21:14:22.180 error uncaught exception: Cannot read property 'title' of undefined
javascript.0 2017-09-21 21:14:22.159 info script.js.Sony_Bravia.Main: Body {"id":24,"result":[[]]}
Kommentiere ich die Zeile 270 aus, geht es. Ich habe ja absolut keine Ahnung, aber kann es daran liegen, dass ich keine Kanäle habe? Benutze den Fernseher nur als Bildschirm.
Grüße Mighty