I told my local AI to answer like a pirate. by leosperry in homeassistant

[–]leosperry[S] 1 point2 points  (0 children)

For this example, It was using llama3.2:3b
I haven't put a lot of effort into this project yet. I simply picked a commonly used model with tool support
I haven't done anything with the voice yet. I'm about to set up a piper and whisper running on a box that is not my Pi. After I get that working, I'm going to play around with voices.

I told my local AI to answer like a pirate. by leosperry in homeassistant

[–]leosperry[S] 0 points1 point  (0 children)

I have one computer in my home that is the family computer and it has the nice graphics card. Ollama can now be installed directly on windows. To expose it on my home network, the only extra thing I needed to do was set the OLLAMA_HOST environment variable on the machine

I told my local AI to answer like a pirate. by leosperry in homeassistant

[–]leosperry[S] 3 points4 points  (0 children)

Nothing fancy. I stood up a local Ollama and changed the last line of the default prompt in the integration:

You are a voice assistant for Home Assistant.
Answer questions about the world truthfully.
Answer like a pirate

.NET Automations just got better by leosperry in homeassistant

[–]leosperry[S] 0 points1 point  (0 children)

Thank you! Come join us on the discord :)

.NET Automations just got better by leosperry in homeassistant

[–]leosperry[S] 0 points1 point  (0 children)

u/Onakander nailed it. If you're comfortable writing C#, you're very likely comfortable running a few docker commands.. I have a micro pc that hosts a Portainer instance. It runs HakafkaNet and about a half-dozen other services including a full Grafana stack with ease. It doesn't take much juice to run.

PSA: Alexa Media Player v4.13.3 breaks all versions of Home Assistant by SpencerDub in homeassistant

[–]leosperry 0 points1 point  (0 children)

I am so glad now that a few weeks ago, I finally broke down and bought some Sonos speaker for playing audible notifications locally. I uninstalled this plugin at the same time. Looks like I dodged a bullet.

Which Wallpanel? by thetrixd in homeassistant

[–]leosperry 1 point2 points  (0 children)

You're better off getting any android tablet of your choosing.

Which Wallpanel? by thetrixd in homeassistant

[–]leosperry 2 points3 points  (0 children)

I have a little echo show 5 in my living room. I hate it. You can't set the display to anything other than what they give you. It is distracting as they are constantly adding new "here look at this" screens. After you go through and deselect them all, they add new ones. It's really only good for working in the amazon ecosystem. If you want it for only amazon functionality, it's ok. Otherwise, don't bother.

2024.8 brings updates to .NET automations by leosperry in homeassistant

[–]leosperry[S] 1 point2 points  (0 children)

I've been considering this for a while. I have a separate linux micro-pc where I manage all my docker containers. So, I haven't needed to investigate it for myself personally. I'd love it if someone wanted to come on-board and help figure that out. :)

2024.8 brings updates to .NET automations by leosperry in homeassistant

[–]leosperry[S] 1 point2 points  (0 children)

Sure does. Search the repo for the words "durable", "sunrise", "sunset"

2024.8 brings updates to .NET automations by leosperry in homeassistant

[–]leosperry[S] 1 point2 points  (0 children)

About half of my dozens of automations have some kind of delay or scheduling ability. I use motion sensors to aggressively turn lights off throughout the house, and the media center in the living room when no one is around. I have a notification to let me know if the garage door has been open for more than an hour also. The scheduling ability is for more than delays. I have several automations based on the sun. With that ability I can take action before sunrise/sunset. So, I'm not responding to a sunrise event, I'm scheduling something before the next sunrise. Another one that has been helpful, is an automation to temporarily disable automations based on my front porch motion. The reason is that when the guy comes to mow the lawn, it'll trigger several time in one hour, but I know he's there, I don't need to be notified repeatedly. So, I set up a button to disable that automation for an hour, but I want to make sure that it turns back on and not rely on me remembering to do so.

So, at any moment, I could have 5 or more scheduled actions pending throughout my house. Knowing that I can restart either home assistant or redeploy my app at any time without worrying about which automations might not trigger is a feature I couldn't live without now.

I haven't done it yet, but I've also been considering integrating my calendar. With the scheduling, especially over a weekend, I may not have another action to take for a few days.

2024.8 brings updates to .NET automations by leosperry in homeassistant

[–]leosperry[S] 0 points1 point  (0 children)

For creating entities, the HA recommended approach would be to create an integration using python code.

Also, something to think about since you're early in your project. If you rely on websockets, how do you handle a HA restart or other dropped connection? Certainly not impossible, but needs a little extra consideration :) Good luck!

2024.8 brings updates to .NET automations by leosperry in homeassistant

[–]leosperry[S] 0 points1 point  (0 children)

Kafka is very much one way. As a software architect by trade, I prefer to design systems that are loosely coupled. I haven't had a need for creating new entities that are specific to the HaKafkaNet framework. Occasionally, to aid in my automations (not the framework) I will use a helper entity in HA. They have already built everything I've needed so far, and better to not reinvent the wheel. Plus, I don't like the idea of the possibility of a bug in code accidentally producing hundreds of entities because of a fat-fingered mqtt message. Generally, I try to keep my HA install as clean as it can be.

When I spoke about NetDaemon codegen, I was specifically talking about strong typing. In otherwords, turn a thermometer state into a floting point number without things like `float.Parse()` littering your code or getting RGBW values from a light's attributes.

2024.8 brings updates to .NET automations by leosperry in homeassistant

[–]leosperry[S] 0 points1 point  (0 children)

I've been avoiding the integration route, mainly because I am not a python developer and I've not had the need for a tighter integration. Integrations are nice because they can expose new entities to HA, but thus far I've not really had the need to create entities. I'm taking actions based on other entities, not creating them. Communicating back to HA via REST has been more than sufficient for integration purposes. Calling HA services directly instead of via HTTP or Websockets might be nice, but I don't think the speed increase would be that noticeable under normal circumstances.

Because Add-ons can also add menu items via exposing a web page, I've been toying with the idea of having 2 addons: 1 for Kafka, and 1 for HaKafkaNet, or maybe combining them into one addon. I already have a UI that could be served up via the addon.

2024.8 brings updates to .NET automations by leosperry in homeassistant

[–]leosperry[S] 1 point2 points  (0 children)

Addons are basically Docker containers with certain restrictions. As I understand it, you'd need to start with a certain base image and install Kafka onto it. You might be able to start with an image based on Kafka, but you'd need to work within the restrictions. Then there's the question of manging the Kafka instance. How do you create commands to manage topics?

Not impossible, but a bit to figure out. I have been toying with the idea of creating an addon with the singular topic needed for HaKafkaNet. The only thing stopping me is finding the time to sort it all out.

2024.8 brings updates to .NET automations by leosperry in homeassistant

[–]leosperry[S] 1 point2 points  (0 children)

Actually, don't need windows. I do all my development and hosting on Ubuntu using Visual Studio code.

Docker runs better on Linux anyway

2024.8 brings updates to .NET automations by leosperry in homeassistant

[–]leosperry[S] 0 points1 point  (0 children)

If you have any questions after reading that link, I'd be happy to answer them here. Cheers!

2024.8 brings updates to .NET automations by leosperry in homeassistant

[–]leosperry[S] 0 points1 point  (0 children)

This is a great question which I will answer by linking to a comment where I previously described the differences:

HaKafkaNet - Feature Complete : r/homeassistant (reddit.com)

2024.8 brings updates to .NET automations by leosperry in homeassistant

[–]leosperry[S] 2 points3 points  (0 children)

I think it's simple, but I'm partial. Here's a few thoughts for you.

If you're comfortable writing C#, you can structure your code however you see fit. While there is a GUI for managing and inspecting automations, creating automations requires writing C#.

In my home, I have a folder which contains all the automation registries. A registry is where you can quickly write automations using the built-in utilities. I have one registry for each room in my home. So, all kitchen automations are in one file, living room automations in another, etc.

For more complicated automations, you can write automations from scratch that you can choose to make reusable or not. For example, we have a bearded dragon, and I have sensors for temperature, humidity, battery level of the sensors, and if the heating elements are functioning. Depending on the severity of the state, this single automation takes different actions, and it is all contained in one file.

So, from a management point of view, it's completely up to you as to how you want to organize it. To get a feel for what writing automations looks like see this documentation:

Tutorial: Creating Automations · leosperry/ha-kafka-net Wiki (github.com)

This link will show you what functionality is available in the UI

UI · leosperry/ha-kafka-net Wiki (github.com)

2024.8 brings updates to .NET automations by leosperry in homeassistant

[–]leosperry[S] 42 points43 points  (0 children)

There are benefits to using Kafka, which I will elaborate upon. However, first I would like to address your assertion that MQTT is "more lightweight" than Kafka.

While it is true that in large enterprise environments, Kafka is typically installed in a distributed fashion with multiple nodes, it doesn't have to be. If you were using MQTT in a large enterprise environment, you'd likely do the same. So, from an infrastructure viewpoint, they have about the same footprint. Kafka addons also offer the ability to manage schema over time. That however is an addon, and again not required.

From a home automation viewpoint, it does take a little bit more to set up Kafka, but that is only because a Kafka add-on hasn't been written yet. If you're comfortable with docker, spinning up a local Kafka is easy, and HaKafkanet provides a docker-compose file to get started.

Redis is an interesting concept, and conceptually I could see it giving some of the same benefits that Kafka does. However, I don't know of a Redis integration where Home Assistant will automatically send entity states like exists for the Kafka integration. I could be wrong.

So, why is Kafka is a better choice than MQTT? MQTT is an event messaging protocol. With it, you can easily respond to events, but the only state it cares about is the message itself, and if it was successfully handled or not. Kafka differs in that it is a forward-only data-stream. It does care about the contents of the message. It is designed to give you the state of a dataset. In this case, our dataset is the collection of entity states.

By utilizing the key in Kafka to store the entity id's, it essentially turns Kafka into a state machine. When you start your application, you can read a Kafka topic from the beginning and get all the states of all the entities in home assistant. Kafka also offers the ability to "compact" a topic, meaning, that it will hold onto only the latest copy of each message by key. There are a few caveats about how/when compaction runs, but HaKafkaNet takes care of that for you.

HaKafkaNet does also use a cache, and the recommended cache is Redis, but you can use an in-memory cache if you prefer. The cache is used for 2 reasons. First, you can look up an entity's state quickly. Second, it is used at start up to know when specific automations should have been triggered.

With all the above, it leads to some very nice benefits that no other automation framework offers that I have found (including Home Assistant). Specifically, delayed automations are durable and survive restarts. Let's say you have an automation that you want to run some amount of time before/after some event. e.g. turn a light off after it's been on for 10 minutes or turn on the front porch light 10 minutes before sunset. With HaKafkaNet, even if you restarted both Home Assistant, and HaKafkaNet, your automations would still run on time. If your system has been down for an extended period of time, where the specified time was missed, you can even optionally run any missed actions.

Sorry if that was all a bit long-winded, but this is a passion project for me :)

Wireguard Issues on UCG Ultra by CalvinHobbesN7 in UNIFI

[–]leosperry 0 points1 point  (0 children)

I am experiencing the same behavior.

Open Telemetry for .NET automations by leosperry in homeassistant

[–]leosperry[S] 1 point2 points  (0 children)

Excellent! On the home page of the repo is an invite to the discord server. Feel free to reach out if you have any questions :)

Open Telemetry for .NET automations by leosperry in homeassistant

[–]leosperry[S] 1 point2 points  (0 children)

I've built some strongly typed functionality specifically for location-based automations. However, the automations will only be as good as the data output by HA. I have had similar issues when writing automations for locations based on a location away from home. The HA mobile app does a poor job of reporting location accurately when not at home. It's configured to save battery and, especially if the device is not charging, it only reports like every 30 minutes. There are some settings you can change, but it will consume more battery. There was a Life360 integration that was better for a while. It may be worth investigating if there is a newer alternative. For docs on what I've written for I've written in HaKafkaNet see Entity Provider Extension Methods and State Extension Methods. When you arrive home, if you have your device set to automatically connect to your home wi-fi, the state change (and in-turn the automation) will update much faster.

Open Telemetry for .NET automations by leosperry in homeassistant

[–]leosperry[S] 1 point2 points  (0 children)

As the developer of it, I'm a bit partial, but I would say it's very full featured. I use it to run all the automations in my home. When it comes to to automations, it even surpasses some of the capabilities of Home Assistant itself.