public static bool AnyoneJustArrived(this NetDaemonRxApp app)
 {
     try
     {
         var isa_location    = app.State(Isa.PersonEntity)?.State?.ToString()?.ToLower();
         var stefan_location = app.State(Stefan.PersonEntity)?.State?.ToString()?.ToLower();
         if (isa_location != null || stefan_location != null)
         {
             if (stefan_location == PresenceStatus.JustArrived ||
                 isa_location == PresenceStatus.JustArrived)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         // return true if null, assume someone could be home
         app.Log($"A person returned null as location state, assuming someone is home.");
         return(true);
     }
     catch (System.Exception e)
     {
         // return true if something goes wrong, assume someone could be home
         app.Log($"Error: {e}");
         return(true);
     }
 }
    public static void NotifyIos(
        this NetDaemonRxApp app,
        string title,
        string message,
        string notifier = "",
        bool onlyIfHome = false,
        string threadId = "home-assistant",
        string category = "",
        bool critical   = false,
        string imageUrl = "")
    {
        var isHome = app.State("person.isa")?.State?.ToString()?.ToLower() == "home" ||
                     app.State("person.isa")?.State?.ToString()?.ToLower() == "just arrived";

        if (!onlyIfHome || (onlyIfHome && isHome))
        {
            // object sound = "";
            var contentType   = "";
            var hideThumbnail = "";
            var entityId      = "";

            if (!string.IsNullOrWhiteSpace(entityId))
            {
                contentType   = "jpeg";
                category      = "camera";
                hideThumbnail = "";
            }
            // if (critical)
            // {
            //     sound = new Dictionary<string, object>
            //     {
            //         ["name"] = "default",
            //         ["critical"] = 1,
            //         ["volume"] = 1.0
            //     };
            // }

            var data = new Dictionary <string, object>
            {
                ["title"]   = title,
                ["message"] = message,
                ["data"]    = new Dictionary <string, object>
                {
                    ["attachment"] = new Dictionary <string, object>
                    {
                        ["url"]            = imageUrl,
                        ["content-type"]   = contentType,
                        ["hide-thumbnail"] = hideThumbnail
                    },
                    ["push"] = new Dictionary <string, object>
                    {
                        ["thread-id"] = threadId,
                        ["badge"]     = 0,
                        // ["sound"] = sound,
                        ["category"] = category
                    },
                    ["entity_id"] = entityId
                }
            };
            if (string.IsNullOrWhiteSpace(notifier))
            {
                app.CallService("notify", Isa.IosNotifier, data);
            }
            else
            {
                app.CallService("notify", notifier, data);
            }
        }
    }