New custom component - HAM - Home Automation Manager

Hi all,

This is the most complicated component I wrote,
I’m using it over 9 months (just finished to document it).

Background:
I moved from VeraPlus to HA and the only thing that I missed was the ability to define profiles, after getting to component that provides the capabilities available in VeraPlus (Home, Away, Vacation and Night profiles), I extended its capability to become something more flexible,

Below are the capabilities, in the repo you can find also configuration example:
Define the day parts according to your life,
define different day profiles (default or additional custom like holiday),
each of those custom profiles allow you to override the day parts of the default profile.

It also provides an ability to define device_tracker to allow the component to define the home as “at home” / “away” mode.

in case you will define scenes according to the profiles, it will trigger the corresponding script,
In addition to the profiles you defined, there is a “secret” profile - away that once the home mode set as away will be triggered.

in addition to the domain component, it comes with binary sensors and sensor,
Binary Sensor will represent each of the profiles defined with their day parts
Sensors - 4 of them are:

  1. Weekday - state will represent the day name
  2. Current Day Part - state will represent the current day part
  3. Current Profile - state will represent the current profile name, Attributes of that sensor will present the same attributes of the binary sensor attributes of the current profile
  4. Current Scene - state will represent the current profile name or away mode in case none of the device tracker are at home, when that sensor state is being changed it triggers the different scripts of the corresponding scene

the component is exposing 2 services:

  1. ham.update - will update all the sensors / binary sensors
  2. ham.run_current_scene - will invoke the script of the current scene

You can try to use it and provide feedbacks, it’s available in the following link:

Good luck :slight_smile:

6 Likes

Thanks for your contribution! I read the sample configuration file and it gave me a clearer idea of how “HAM” works.

Do you have any examples you can share of how you are using HAM’s sensors? I imagine you are using them in automations (in triggers and conditions).

What about the scenes? What are your scenes doing when a ‘day part’ changes?

Sure, so first of all I’m using 5 different day parts which represents 5 different profiles - morning, noon, after noon, evening and night,
on top of it there is the away profile.

I have at home 15 covers controled by HA, lights, air conditions, based on the different profiles i change them.

Few examples:

  • In the morning, I open all the covers to 30%, turn off the night light
  • In the noon, I close all the covers of the bed rooms
  • In the afternoon, I open the bed rooms covers again to 30%, living room to 100%,
  • Evening, closing the bed rooms again and turn on the lights of the kids hallway
  • Night, closing all the covers and turn LED lights in the rest of the hallways.
  • When away mode is being activiated, close all covers, enable the alerts of the NVR system, turn off all lights and air conditions.

All of those actions are based on the scripts in the scenes, no automation.
I do use automation for other purposes, for example:

  • Report when no-one at home or during the night when doors or windows are being opened using notification of telegram
  • When specific doors are being opened when no-one is at home, it will alert as well, and take snapshot from the camaras around that area
  • Send notification when all persons left home and one of the doors / windows are opened
  • Battery alert of all the sensors on the morning
  • Traffic updates at morning

In the device tracker I set the devices of my family, babysitter, house keeper,
the last 2 solves lots of pains I saw in the past for poeple that using home automation systems that cannot define scenes for those 2 specific cases, with that component you can handle them as well.

I use the override profiles of half day and weekday mostly in the weekend,
I changed the morning from 6:00 AM in default profile to 6:30 AM on Half Day profile and 9:00 AM on Holidays profile,
In different countries the rest days are different, so you can actually define it according to your needs,
Same applies for different vacation days.

2 Likes

Very interesting component! Is anyone using this? And what are your experiences? I have been trying to do something similar with tons of separate integrations, but it’s hard to combine that many things.

@bar Thanks for the work you put in. Is this component still alive? If so, I’ll give it a try.

Sure, link is up above, over the last 3 weeks I started transform the component into Node-RED flow (in case you are using it as well), my house is running with the HAM component for more than a year with almost no incidents (mostly related to wrong configurations of holidays)

Thanks for your reply. I tried to familiarise myself with Node-RED, but couldn’t really get used to it.
I have started working on the setup of HAM. I am actually surprised that you don’t get a lot of response on this topic, because I really like the idea of combining structure in life with home automation. I’ll let you know if it works for me. If I run into any issues, or if I have any ideas for improvement I’ll let you know as well. Thanks again!

So, I got it up and running. It was quite easy to set up.
I was wondering if the parts of the day can only have the names: Morning, noon, etc… or can I use other names like: Wake up, Bedtime, etc? Dividing the day into standard activities that I do every day, suits me better :slight_smile:

What exactly do the trackers do in this component?

I also have a suggestion for making it look less complex (I thought it was harder to set up than it turned out to be). Maybe you could combine the sections for default profile (required) and custom profiles (optional). Or even let go of the default profile and require at least one profile to be made.

Anyway, so far I am impressed. I think this component will make quite a few things easier for me in terms of combining Home Assistant with my need for structure in daily and weekly routines :slight_smile:

The reason why I created the component was that it will be easy to configure while provide the complex functionality, so I’m glad you find it like that.

Device tracker - when one of the devices is at home it switch to default (or custom profiles), when last device is getting out of home, it converts to profile away.

The reason why default profile is separated from custom profiles, default profile is mandatory while other are not, any feedback is wellcom, so please let me know what will be more convenient.

You can name the profile as you would like to (as long as keeping the events aligned with that name), as for day parts (morning, noon, etc…) not remember, need to check it (will do it later today)

Okay, the device tracker makes sense. I’ll look into that again.

About the profiles: I looked at your example and it took me a little while to figure out what is what and where in the config does everything go :slight_smile: I kind of turned your example into a component text as you can find with the official components. After that I managed to set it up correctly. I guess what I am trying to say is: the set-up might be more complex than necessary :slight_smile: if you are still maintaining this component, I wouldn’t mind sending you some well-structured suggestions (in stead of this chaotic rambling that I am doing right now :D)

I just gave changing the day parts a go. I figured I couldn’t mess up too badly. Well, the outcome is: HAM won’t start if you change the names to anything other than the ones in your example.

I can understand if the component works well for you, that you don’t really want to change it/put more time into it. If you do plan to make some changes, and you want my opinion, let me know.

Sure, I would like to hear your opinion, if you can send a sample of how you think it should be structured, it would be even more convenient

I have tried to make my ideas a bit understandable. I hope this example makes it clear. If not, let me know. It makes sense to, but that doesn’t always mean that others get it :smiley:

ham:
  profiles:
  #### default_profile is mandatory, custom profiles can be added here as well.
    - profile: default_profile
      #### Custom names for parts of the day (Example: Wake_up, Bedtime). "From" might make more sense as "Time", but that may depend on the user.
      parts:
      - name: Wake_up
        time: '06:45:00'
      - name: Afternoon
        time: '12:00:00'
      - name: Evening
        time: '18:00:00'
      - name: Bedtime
        time: '23:15:00'
    ##Nothing is copied from default_profile, unless "time" has value "default" and part exists in default profile
    - profile: custom_profile
      parts:
      - name: Morning
        time: '06:45:00'
      - name: Afternoon
        time: 'default'  ##Will be copied from default_profile
      - name: Evening
        time: '18:00:00'
      - name: Night
        time: 'default' ### Won't do anything, because Night does not exist in my default_profile

    - profile: Custom_profile.... etc.

##Trackers seems fine, after using the component for a day, I have seen that it switches of the automations when away
  trackers:

##I assume that this revolves completely around script? Might not be a necessary part if you already have scripts. 
##Not a problem though, you can still call the scripts through a service.
  scenes:     
    - scene: Wake_up
      script: script.wake_up_alarm

##Events seems fine. I have to spend more time on the events with a date, to see how that works
  events:
    - profile: Weekend
      day: Saturday
      title: Weekend
    - profile: Weekend
      day: Sunday
      title: Weekend

I managed to get one of my requests done :slight_smile: It’s not the cleanest solution, but I added my own preferred day parts to the ‘const.py’ file, in all 3 places where the day parts are mentioned. I am not very good at python, but I think I did it right.

I may try to make a few more changes to your code, but I have already seen that you are way better at coding in python than I am :slight_smile: I might learn something. If I manage to come up with anything useful, I’ll let you know.

Would it also be possible to use the date events with a from-till setting? For example if you have holidays that are longer than a day. As far as I can tell, I have to specify every single day.

Hello,
I am potentially interested in the node-red version of the tool. Is it already available?
Thanks any way for what you have done so far !
GV

Flow is available in GitHub:

In the flow there are comments with description what to change and how,
Note that there are changes you need to have in HA to support it as well (presence is working with Person entity with custom attribute auto_scene)

there are examples of how to consume the MQTT message it publishes as sensor / binary_sensor in HA.

I will try to get to it in the upcoming days, can’t promise anything but will do my best :slight_smile:

Thanks! I can understand if it is too much of a hassle, especially if it is an option that you don’t really need. I am currently trying to figure out your code and the basics of writing components. It’ll take me a while, but if I come up with any improvements, I will share it with you.

On thing that might interest you is a component in HACS. It’s originally for Israeli school holidays, but I reworked it to work with my own data. If I can work out how to do this, I’ll try to combine it with the events part of your component, so I can add special days and holidays in bulk, or even scrape the data from a website.

The original and right solution as I think is to use calendar for the events,
Special days - weekend will be configuration
Events - read from calendar, you will have a UI to add / modify events easily, it will support multiple day events or even shorter than a day event (e.g. babysitter),
You can use the category / description of the event to classify it as event type…

What do you think about that?

I haven’t been able to find a calendar integration that I like, but in general that does sound like a good solution. The more I can do from the UI the better.

Is your idea that the user has to link calendar events through an automation, or are you planning to add this to the component?

Either way, that does sound like a good idea!

I though it should relay on calendar sensor somehow, in the HAM component you will be able to define which calendar and what is the criteria