add auto volume and total power on hours action

This commit is contained in:
Vincent Maas committed 2022-07-24 15:14:44 +02:00
1 parent 6c21245b98
commit 84cb7e6446
4 files changed
+58 -19

No files matched your search

+2 -2
View File
@@ -18,8 +18,8 @@
<PublisherName>Maassoft</PublisherName>
<Company>Maassoft</Company>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>7.1.0.0</ApplicationVersion>
<Version>7.1.0.0</Version>
<ApplicationVersion>7.2.0.0</ApplicationVersion>
<Version>7.2.0.0</Version>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>false</BootstrapperEnabled>
+1 -1
View File
@@ -3136,7 +3136,7 @@ Do you want to continue?"
return;
}
var actions = device.GetInvokableActions();
var actions = device.GetInvokableActions(_lgService.Config.ShowAdvancedActions);
var gameBarActions = device.GetInvokableActionsForGameBar();
var activatedGameBarActions = device.GetActionsForGameBar();
+37 -3
View File
@@ -23,6 +23,7 @@ namespace ColorControl.Services.LG
public int CurrentValue { get; set; }
public int NumberOfValues { get; set; }
public LgPreset Preset { get; set; }
public bool Advanced { get; set; }
}
public class LgDevicePictureSettings
@@ -204,7 +205,11 @@ namespace ColorControl.Services.LG
AddGenericPictureAction("soundMode", typeof(SoundMode), category: "sound", title: "Sound Mode");
AddGenericPictureAction("soundOutput", typeof(SoundOutput), category: "sound", title: "Sound Output");
//await ExecuteRequest("luna://com.webos.settingsservice/setSystemSettings", new { category = "network", settings = new { wolwowlOnOff = "true" } });
AddGenericPictureAction("autoVolume", typeof(OffToOn), category: "sound", title: "Auto Volume");
//AddGenericPictureAction("enableToastPopup", typeof(OffToOn), category: "option", title: "enableToastPopup");
AddSetConfigAction("tv.conti.supportUsedTime", typeof(BoolFalseToTrue), title: "Total Power On Time");
AddGenericPictureAction("wolwowlOnOff", typeof(FalseToTrue), category: "network", title: "Wake-On-LAN");
}
@@ -260,6 +265,21 @@ namespace ColorControl.Services.LG
_invokableActions.Add(action);
}
private void AddSetConfigAction(string name, Type type, string title)
{
var action = new InvokableAction
{
Name = name,
Function = new Func<Dictionary<string, object>, bool>(GenericSetConfigAction),
EnumType = type,
Title = title == null ? Utils.FirstCharUpperCase(name) : title,
Category = "Config",
Advanced = true
};
_invokableActions.Add(action);
}
public void AddGameBarAction(string name)
{
if (!ActionsOnGameBar.Contains(name))
@@ -310,6 +330,8 @@ namespace ColorControl.Services.LG
await _lgTvApi.SubscribePictureSettings(PictureSettingsChanged);
await _lgTvApi.SubscribeForegroundApp(ForegroundAppChanged);
//await _lgTvApi.SetConfig("tv.conti.supportUsedTime", true);
//await _lgTvApi.Reboot();
//var result = await GetPictureSettings();
@@ -773,9 +795,9 @@ namespace ColorControl.Services.LG
return result;
}
public List<InvokableAction> GetInvokableActions()
public List<InvokableAction> GetInvokableActions(bool includedAdvanced = false)
{
return _invokableActions;
return includedAdvanced ? _invokableActions : _invokableActions.Where(a => !a.Advanced).ToList();
}
public List<InvokableAction> GetInvokableActionsForGameBar()
@@ -920,6 +942,18 @@ namespace ColorControl.Services.LG
return true;
}
private bool GenericSetConfigAction(Dictionary<string, object> parameters)
{
var key = parameters["name"].ToString();
var values = parameters["value"] as object[];
var value = values[0];
var task = _lgTvApi.SetConfig(key, value);
Utils.WaitForTask(task);
return true;
}
private void UpdateCurrentValueOfAction(string settingName, string value)
{
if (settingName != "backlight" && settingName != "contrast" && settingName != "brightness" && settingName != "color")
+18 -13
View File
@@ -124,6 +124,14 @@ namespace LgTv
true_
}
public enum BoolFalseToTrue
{
[Description("Disabled")]
bool_false,
[Description("Enabled")]
bool_true
}
public enum GammaExp
{
low,
@@ -417,6 +425,11 @@ namespace LgTv
{
await _connection.SendCommandAsync(new RequestMessage("", "ssap://system/turnOff"));
}
public async Task Reboot()
{
await ExecuteRequest("luna://com.webos.service.tv.power/reboot", new { reason = "" });
}
public async Task Play()
{
await _connection.SendCommandAsync(new RequestMessage("play", "ssap://media.controls/play"));
@@ -662,6 +675,11 @@ namespace LgTv
string jsonValue;
var valueType = value.GetType();
var intType = typeof(int);
if (value.ToString().StartsWith("bool_"))
{
value = bool.Parse(value.ToString().Substring(5));
}
if (valueType.IsArray && intType.IsAssignableFrom(valueType.GetElementType()))
{
var values = ((Array)value).Cast<int>();
@@ -746,19 +764,6 @@ namespace LgTv
await ExecuteRequest(lunauri, @params);
}
public async Task Reboot()
{
//await ExecuteRequest("luna://com.webos.service.oledepl/setGlobalStressReduction", new { enable = true });
//var requestMessage = new RequestMessage("ssap://com.webos.service.devicereset/requestReboot", new { reason = "broadcastSystemChanged" });
//var response = await _connection.SendCommandAsync(requestMessage);
//await ExecuteRequest("luna://com.webos.settingsservice/setSystemSettings", new { category = "network", settings = new { wolwowlOnOff = "true" } });
//await ExecuteRequest("luna://com.webos.settingsservice/setSystemSettings", new { category = "general", settings = new { powerOffBySCA3SystemChanged = "true" } });
//await ExecuteRequest("luna://com.webos.service.devicereset/requestReboot", new { reason = "broadcastSystemChanged" });
}
private async Task ExecuteRequest(string lunauri, object @params)
{
var buttons = new[]