-
-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Labels
enhancementNew feature or requestNew feature or request
Description
New Feature Description
Hey, I'd love to help with this project, and I will give the caveat that I'm still fairly new to C# and .NET so I want to make sure I'm not reinventing the wheel or missing that this feature may already be present.
Any feedback on if this should not be done this way, or if this has already been done, or if there's a better way/reason to just plain not do it would be welcome. I'd obviously be doing things like passing brightness and color as optional parameters, this is a very very basic example to check if this is something you'd like to have added.
Code Example
public class Light
{
private static string domain => "light";
/// <summary>
/// The entity name in HA for the light
/// </summary>
public string EntityName { get; }
/// <summary>
/// Constructor that takes the entity name of the light to control as a string (Do not prepend light. to the entity name.)
/// </summary>
/// <param name="lightEntityName"></param>
public Light(string lightEntityName)
{
EntityName = lightEntityName;
serviceClient = ClientFactory.GetClient<ServiceClient>();
}
/// <summary>
/// Calls the turn_on service in HA for the light
/// </summary>
/// <returns></returns>
public List<StateObject> TurnOn()
{
var resultingState = serviceClient.CallService(domain, "turn_on", new { entity_id = $"{domain}.{EntityName}" });
return resultingState.Result;
}
/// <summary>
/// Calls the turn_off service in HA for the light
/// </summary>
/// <returns></returns>
public List<StateObject> TurnOff()
{
var resultingState = serviceClient.CallService(domain, "turn_off", new { entity_id = $"{domain}.{EntityName}" });
return resultingState.Result;
}
private ServiceClient serviceClient;
}
HA API Docs or Sample
svrooij and Devqon
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request