Newbie questions

Hello

firstly, I have to admit, I’m absolutely new to Homeassistant.
I used to build my smarthome around OpenHAB, but because I feel that Openhab software quality is somehow decreasing, and I face new issues after every upgrade I’m looking into Homeassistant as an alternative.

My devices to connect are either behind a homegear bridge, a Philips HUE bridge, a deconZ Gateway or http(s) rest interfaces.
of course there some others like RTSP Cams, spotify, bose devices, etc.

I managed to setup Homeassistant in a Docker Container and i was able to connect all of my devices. That was pretty straight forward, really cool.
I have seen that some devices are recognized as entity, others as device. I assume this is “normal”?

I now have two questions for my understanding, and hopefully I can get some answers :slight_smile:

Question 1 - Automation:
When it comes down to automation rules it gets a bit more unclear to me.
I started with the UI automation topic, but this seems to be really limited? For instance I was not really able to reflect my Motion Sensor automations.
I have seen appdaemon, which gives me much more flexibility and I was able to build my motion rules with it.
But since it’s “outside” of homeassistant I would be interessted in any postive or negative expiriences with appdaemon?
Are you mixing up your automation rules? Some in appdaemon and others directly in homeassistant?

Question 2 - How/Where to store information:
I would need to store some information and/or parameters. For instance if the motion sensore can activity a light or not, how long a motion enabled light will be on, or I do have a couple of json strings(various lenghts) i’d like to store and show on a dashboard in a table for example.
I have seen there are “helpers” in Homeassistant. Is this the correct place to store such informations?
I have seen that I can create a helper with type string, but it has a maximum length of 255, which is not enough for my jsons?
Any ideas how I could store this values?

thanks
martin

Welcome to Home Assistant!

It’s normal to have devices and entities, although this varies a bit depending on the integration you’re looking at. Phillips Hue in particular creates both, other integrations only generate entities. Broadly speaking, as you’d expect, the device is the gadget, the entity is what it does - so each Hue motion detector has three entities: sensors for light and temperature and a binary sensor for motion. (If you click on the entry in the device list you’ll get a summary; if you click on the entity in the summary you’ll get detailed information.) Generally, when you write automations and scripts you’re handling entities.

I personally use the UI for automations and scripts, but I’m not a programmer and I find it it allows me to work through the logic without bothering with syntax. If you use scripts as subroutines you can get quite complex sequences of actions. I find Developer Tools very helpful in figuring out how to use entities and services. By the sound of it you’re a lot more experienced than me though. Haven’t used appdaemon.

I use “helpers” for storing information, but so far only boolean and number - don’t know about long strings. You mention motion sensors and lights - why not let the Hue bridge handle some of that?

Good luck!

AppDaemon vs internal automations

Personal choice IMO. The UI editor in HA is limited, but the full YAML isn’t so limited. Of course, if you’re at home in Python then AppDaemon gives you far more flexibility and power.

Just, pick one :wink: Don’t use both or you may end up with automations that fight each other.

Information

States in HA are limited to 255 bytes. I think attributes can be longer, but I’m not sure.

There are of course other types, so you can store things like numbers, booleans (on/off), dates or times (or both) - see the list. some of these have obvious matches for what you specify. Booleans for if the motion sensore can activity a light and a number for how long a motion enabled light will be on.

Beyond

The good news it that your Homegear, Hue and deCONZ can connect directly with HA, and HA can interact with RESTful APIs. And obviously quite a lot more :wink:

I believe you can add this to the entity and it will be much more tidy.
Having it in separate helpers will become messy.

Go to configuration -> scroll all the way down to Customize (or customization).
Here find the entity and add a attribute to the entity.

I have not done this myself but I’m quite sure it works.
What you (should) get is in the states page, the right column should list this new attribute you add.
This attribute can then be used in your automations via templates.

Hello,
thanks a lot for the great and fast responses.

let me quickly throw some further questions back :smiley:

wrt automation:
i agree, I also already think that keeping the automation stuff consistent and in one technology makes sense. However I could imagine that very simple automation can be done via the UI or yml, and I put the complex ones in appdaemon. Since appdaemon is decoupled form homeassistant it might also be possible to start multiple instances and scale it easily. Performance is one of my biggest problems in my current openHAB setup. Home Assistant and appdaemon appear to be a bit “lighter” but are there any experiences with larger environments with a lot of rules? e.g. concurrent threads running and, or concurrent rule executions?

wrt storing data:
great hint about the attributes in the entity. I think i can write my “can my motion sensor enable something” in such an attribute.
But I’m still facing issues with my jsons. I have seen the rest connector (i think it’s called sensor?) and I can add it to my configuraiton and retrieve information. I can also extrect information.
but my scenario is a bit different:
I have a rest api with delivers a json array with a various amount of elements (usually not more than 30, but in theory it could be more). each element of the array consists of the same set of attributes.
I would like to regulary poll my API, fetch and store the latest json and show it as a table in a lovelace card.
Until now I can extract one specific key/value pair, but i want to keep everything offered by the api.
any ideas how I can handle that one?

thanks
martin

I ran on a Pi3 for the first few years of using HA, and I had about 350 automations, plus NGINX, and AppDaemon (which I ended up ditching), and a few other things. The only performance problems I had were down to the storage speed (or lack of) on the Pi.

I upgraded to a VM on an i5 and haven’t looked back.

Maybe you’ll need to tackle it by splitting each array member into an attribute of your entity, maybe you’ll need to split it down further. Unfortunately HA isn’t designed to handle and display large monolithic blocks of data…

I’m quite sure you can use node red to parse the json since it uses JavaScript in the function nodes.
It all depends on the use case of this json string.
As I understand you don’t need this all the time and when you need it it’s not always the same value?

If that is true then you could perhaps use a input_select and populate that with the keys and have the selection trigger an automation to fetch the value.

That is one possible option.
But if you describe better how you use this json string then it’s a lot easier to help.

Hello again,
and thanks again for sharing your experience.

to my json thing:
well, the json array have all the same keys, but the array has always a different length.
actually I use it for instance to manage my inventory, or I organize the money I spent this month for shopping, etc. this data are provided by other applications and I’d like to present them on my wall-mounted tablets.
so yes, i know exactly the keys in the json, but the length of the array is variable. that makes it hard to assign it directly to any states, since I cannot create the necessary amount of things beforehand.
However, the attribute idea before was great.
I started playing around with a helper element (entity? perhaps, homeassistant naming is still new to me :blush: ) and added a custom attribute. I can now poll my api with appdaemon and store the data in the attribute field. I now use the state of the helper for the timestamp of the last poll. the cool thing the attribute obviously understand the json itself, so I can easily iterate through it in a lovelace card. The lovelace part is not done yet (I want to present it in a table, and also some modification buttons later on) but i think that will work :slight_smile:

cheers
martin

In the Home Assistant Community Store (HACS) there’s a custom Lovelace card called flex-table. “Any tabular data can be visualized, formatted & modified” (it says here…). This may deal with the Lovelace part.

You can go directly to it on github here. It’s a good idea to load it through the HACS add-on, though. Instructions of installing that here.

1 Like

Hello,

great thanks for the hint to the flex-table, i’ll give it a try!

Meanwhile I started with some javascript (based on an attribute-entity-row card i found) to extract the attributes and show them as a table in a lovelace card, Attribute is updated by appdaemon polling my api. My card doesn’t look nice yet, but basically I have my json in a table. thats good and I think I’ll finish my first home assistant try-day and think whether I should migration from openhab to homeassistant or not :slight_smile:

thanks
martin

PS: great community here! Thanks for all the quick comments and feedback!!

1 Like

Hello,

just a quick other questions on how setting up things best.

two examples:
Example 1: Motion Sensors:
I do have some motion sensors, and a motion sensor should of course turn on the lights. But I want to control it, meaning I would like to be able to turn it off. Is using a Helper (Boolean) the best way to do this?

Example 2: HUE Scene:
I have a couple of Hue Scenes for the same group of lights. Depending on various conditions (hour of the day, who is at home, etc.) I want to have a different “default” scene. I can again put the scene name in a helper, but again the question, is this the best way to do?

Going above approach I would end up with a lot of helpers, but I do not know if this is good or bad?
I also tried it with one helper per room, with various attributes. My appdaemon apps can handle this, but it seems to be tricky to get this attributes controlled (adjusted) via a lovelace card.

How are you dealing with this kind of automation requirements.?

Any feedback/idea is appreciated :slight_smile:

thanks
martin

  1. Using an input_boolean as a control in the automation’s conditions is pretty typical here. That’s exactly what I (and many others) do

  2. You could use a single input_select helper here, and that’s exactly what I do

Don’t worry about “a lot of helpers”. Unless this is a mansion and you’re creating a few dozen helpers per room, it doesn’t matter at all (and even then, it probably doesn’t matter). I’ve got about 100 all in, mostly booleans, and a total of 1.6K entities (of which some 350 are automations). Even on a Pi3 my HA system didn’t have any issues with that lot. I could probably have tripled that count without issue.

1 Like