Skip to content

Commit

Permalink
Merge pull request #5 from GamerClassN7/dev
Browse files Browse the repository at this point in the history
Fixes To Binary Sensor Payload
  • Loading branch information
GamerClassN7 committed Aug 19, 2022
2 parents 9aa356d + 7f30da3 commit 605a72d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions HA_Desktop_Companion/Libraries/HAApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public JsonObject HASenzorRegistration(string uniqueID, string uniqueName, int s
return HARequest(token, "/api/webhook/" + webhook_id, body);
}

private object HAGenericSenzorDataBody(string uniqueID, object state, string icon = "")
private object HAGenericSenzorDataBody(string uniqueID, object state, string type = "sensor",string icon = "")
{
Dictionary<string, object> entityTemplate = new() { };

Expand All @@ -255,7 +255,7 @@ private object HAGenericSenzorDataBody(string uniqueID, object state, string ico
Dictionary<string, object> data = new()
{
{ "unique_id", uniqueID },
{ "type", "sensor" },
{ "type", type },
{ "state", state }
};

Expand All @@ -280,7 +280,7 @@ public JsonObject HASendSenzorData(string uniqueID, string state)

public JsonObject HASendSenzorData(string uniqueID, bool state)
{
object body = HAGenericSenzorDataBody(uniqueID, state);
object body = HAGenericSenzorDataBody(uniqueID, state, "binary_sensor");

return HARequest(token, "/api/webhook/" + webhook_id, body);
}
Expand Down
2 changes: 2 additions & 0 deletions HA_Desktop_Companion/Libraries/Sensors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,11 @@ public static bool queryConsetStore(string category = "webcam")
{
if (subKey.GetValueNames().Contains("LastUsedTimeStop"))
{

var endTime = subKey.GetValue("LastUsedTimeStop") is long ? (long)subKey.GetValue("LastUsedTimeStop") : -1;
if (endTime == 0)
{
//MessageBox.Show(subKey.GetValue("LastUsedTimeStop").ToString());
return true;
}
}
Expand Down

0 comments on commit 605a72d

Please sign in to comment.