jseidl / hass-magic_areas

Areas with batteries included for Home Assistant
MIT License
273 stars 28 forks source link

Confused Question and Slow Loading Query #158

Closed thorrrr closed 2 years ago

thorrrr commented 2 years ago

Hey Jseidl I have had this installed for 12 months and i have read the professionally written blog and Wiki but my poor brain does not grasp how it works. Do you have any other blogs or examples on how you would use this in an example config format? I use many other installs which most i fully understand but this for some reason is a mental block for me.

On a side note this install is taking 89 to 110 seconds to load which seems terribly slow. Is this normal for this integration?

jseidl commented 2 years ago

Hey @thorrrr, so sorry the documentation is not working for you. One thing that might have confused you is that the wiki is written for the upcoming 3.0.0 release which differs in some aspects from the current stable 2.x. The blog post is entirely on 2.x tho.

This integration is a bit unorthodox as the configuration has a bit on yaml and a the rest over the UI.

In your configuration.yaml you just need to add

magic_areas:

and after that the integration will be officially "installed". Upon first restart, the integration will cycle through all Areas you have created in Home Assistant and create a Magic Area integration instance for it which you can manage through the UI.

The following explanation is considering the new 3.0.0-beta branch as I've been testing it for months and don't really remember how the configuration looks like on the 2.x much but the concepts are the same

Magic Areas works with the concepts of features, which you can read as "plug-ins" which provide different functionality. Users can opt into which ones they want to enable. The configuration flow has an initial screen which you have a few basic area settings and the next one will be where you tie the secondary states to arbitrary entity states from Home Assistant. These secondary states are used further in the features/plugins for different purposes (for example, the Automatic Light control aspect of the Light Groups feature requires an Area to have the dark secondary state).

All the configuration options have some explanation on the configuration UI, let me know what other questions you have that I can help answering.

PS: Yes it takes a while to load as several calculations are done for some features and also we have to wait for other integrations to be done so we can have a full list of entities to work with. I'm still on the "make it work" phase of building this integration and I do plan in the future on doing some profiling to enhance those load times.

thorrrr commented 2 years ago

HI Jan Cheers for quick reply it is not your docs more my mental bock. I have in my setup Dwaines Dashboard so i can use HA on a wall mount. Part of that is setting up groups for each room I tried to think if your integration could be used but gave up as it didn’t get it . Like i mentioned do you have few examples of how you use it in an automation so i can see it visually ? I like what i read and it sounds like it helps a lot but it is not computing in my head :), I have asked other on Discord but they are a little stumped. I did look on Youtube to see if thee were anny guides but did not see any.

jseidl commented 2 years ago

The idea is that Magic Areas offloads a lot of automations through the feature system. For example, automation for turning lights on and off automatically are handled by the Light Group (3.x) / Light Control (2.x) feature and so on but you can create your own.

Whenever you first install, Magic Areas will create a binary sensor for the area that will track if an area is occupied or not via the presence sensors in that area. Here's an example of one of my Area's binary_sensor

image

As you can see, there's a lot of entities that are used as presence state. You could use this binary_sensor as a trigger for when you want to perform actions whenever the room is occupied or not. I also have views for each room as you have and I use the "Aggregates" feature to show the overall motion, temp and luminosity levels and so on

image

Here's a shot of the aggregate sensor for temperature

image

Another feature (this one is on 3.x only) is the light groups and climate groups features that will automatically control lights and climate devices based on the occupancy status of an area

image

On the top row you see the light groups created by Magic Areas (Overhead, Task etc)

Here's the "Area Climate" group which will turn on any climate device in the area after it has been occupied for a while and off when the room is clear.

image

Hope that helps, let me know if you have other questions

thorrrr commented 2 years ago

HI Jan I have just installed Beta 3 to try new features and everything in MR has broke all entities saying not available ?

jseidl commented 2 years ago

Did you got it from the releases tab or from the branch?

thorrrr commented 2 years ago

HI I picked it from HACS i had show Beta ?

jseidl commented 2 years ago

Hmm that one might be slightly outdated. Lemme generate a new one

thorrrr commented 2 years ago

Logger: homeassistant.components.binary_sensor Source: custom_components/magic_areas/binary_sensor.py:223 Integration: Binary Sensor (documentation, issues) First occurred: 18:46:58 (44 occurrences) Last logged: 18:47:00

Error adding entities for domain binary_sensor with platform magic_areas Error while setting up magic_areas platform for binary_sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 613, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 747, in add_to_platform_finish await self.async_added_to_hass() File "/config/custom_components/magic_areas/binary_sensor.py", line 265, in async_added_to_hass await self._initialize() File "/config/custom_components/magic_areas/binary_sensor.py", line 290, in _initialize self.load_attributes() File "/config/custom_components/magic_areas/binary_sensor.py", line 223, in load_attributes for feature_name, opts in self.area.config.get( AttributeError: 'list' object has no attribute 'items'

thorrrr commented 2 years ago

Logger: custom_components.magic_areas.media_player Source: custom_components/magic_areas/media_player.py:114 Integration: Magic Areas (documentation, issues) First occurred: 18:46:58 (1 occurrences) Last logged: 18:46:58

No areas with media_player entities. Skipping creation of area-aware-media-player

jseidl commented 2 years ago

Anyway it will break you current install because the configuration has been changed, you'll need to remove all instances of the integration from HA through the configuration UI and restart to have them re-created. I'm generating a new beta release now

thorrrr commented 2 years ago

So do i just mark it as remove in HACS?

jseidl commented 2 years ago

Go to the integrations area on Home Assistant, you'll see something like this

image

Then click the entry, then the dots button and select Delete

image

Do this for all areas and restart.

Once I get the new release out you can update through HACS and then get it to deleting and restarting

thorrrr commented 2 years ago

i have deleted all areas and it disappeared so i restarted. Please let me know when Beta is ready

thorrrr commented 2 years ago

Even after restart

Logger: homeassistant.helpers.entity Source: helpers/entity.py:549 First occurred: 19:02:32 (21 occurrences) Last logged: 19:02:34

Entity binary_sensor.area_garden (<class 'custom_components.magic_areas.binary_sensor.AreaPresenceBinarySensor'>) implements device_state_attributes. Please report it to the custom component author. Entity binary_sensor.area_guest_bedroom_one (<class 'custom_components.magic_areas.binary_sensor.AreaPresenceBinarySensor'>) implements device_state_attributes. Please report it to the custom component author. Entity binary_sensor.area_global (<class 'custom_components.magic_areas.binary_sensor.AreaPresenceBinarySensor'>) implements device_state_attributes. Please report it to the custom component author. Entity binary_sensor.area_interior (<class 'custom_components.magic_areas.binary_sensor.AreaPresenceBinarySensor'>) implements device_state_attributes. Please report it to the custom component author. Entity binary_sensor.area_exterior (<class 'custom_components.magic_areas.binary_sensor.AreaPresenceBinarySensor'>) implements device_state_attributes. Please report it to the custom component author.

jseidl commented 2 years ago

This is fixed on beta1, release is out https://github.com/jseidl/hass-magic_areas/releases/tag/3.0.0-beta1. It might take a bit for HACS to update it

thorrrr commented 2 years ago

Sorry for being thick how is it best to load this ?

When i try to remove from HACS i get this popup see here

jseidl commented 2 years ago

Don't need to remove it, just update with the beta1 whenever it pops up.

If you DO need to remove it here's how to do it: https://github.com/jseidl/hass-magic_areas/wiki/Uninstalling

jseidl commented 2 years ago

And thanks for testing out 3.x, it really helps and I understand it's quite a hassle to reconfigure the areas

jseidl commented 2 years ago

If you go to hacs > integrations > search for Magic Areas and click the more button, you can force to pull the latest beta1 by clicking "Update infromation" then the beta1 should become available for updating

image

thorrrr commented 2 years ago

not sure what has happened none of my HACS intergrations are showing up on HACS page

thorrrr commented 2 years ago

See here

jseidl commented 2 years ago

That is weird, I just updated Magic Areas through HACS to beta1 and it worked fine. image

Try reloading page / restarting?

thorrrr commented 2 years ago

i might have to re load a backup

jseidl commented 2 years ago

i might have to re load a backup

That's really weird, integrations would not affect HACS itself AFAICT even if they were broken. Can you navigate to https://$YOUR_HA_IP:8123/hacs/integrations

thorrrr commented 2 years ago

ok got it back do i still need to removes each areas ? Like you said in https://github.com/jseidl/hass-magic_areas/issues/158#issuecomment-1005994506

jseidl commented 2 years ago

If you had removed it before than the 3.x-beta shall have reconstructed it correctly and the update (beta1) wouldn't change it much. You only need to delete/restart/let it recreate if upgrading from 2x.

Did it worked?

thorrrr commented 2 years ago

I have rstored from 8 hours ago so everything is as it was nothing removed i now see a HACS upgrad for Magic Rooms

thorrrr commented 2 years ago

https://xbackbone.daddycloud.co.uk/Piqa4/SeJOFIYi24.jpg

thorrrr commented 2 years ago

What i am saying is i am currently on ver 2 can i directly update now? Or do i still need to remove each room ?

jseidl commented 2 years ago

Update, then before you restart remove all rooms then restart

thorrrr commented 2 years ago

it has loaded but not picked up my living room the old one did new ver not seeing it ???

thorrrr commented 2 years ago

See here

jseidl commented 2 years ago

You need to enable the Media player groups feature. If you mean to use the media player as a presence sensor, then you need also to add playing to the on_states on the first configuration screen

thorrrr commented 2 years ago

No i mean it is not even picking up the motion sensors in the Living Room

jseidl commented 2 years ago

Can you post a screenshot of the attributes of the binary_sensor.living_room ? Also double check that the sensors are in the Living Room area in Home Assistant

thorrrr commented 2 years ago

https://xbackbone.daddycloud.co.uk/Piqa4/XEFECoga54.jpg

thorrrr commented 2 years ago

https://xbackbone.daddycloud.co.uk/Piqa4/qEFuVUPo30.jpg

jseidl commented 2 years ago

Weird, didn't seems like it created any. Can you post a screenshot of the integration page, like this image

thorrrr commented 2 years ago

https://xbackbone.daddycloud.co.uk/Piqa4/SeFiQeqI13.jpg

jseidl commented 2 years ago

Do you see "Living Room" on the list? If so, can you click the > arrow then entities and post screenshot?

thorrrr commented 2 years ago

Nope that’s what i mean it is not in the list

jseidl commented 2 years ago

wth... alright time to pull out the big guns

Can you set the log level for custom_components.magic_areas.binary_sensor to debug? If you don't currently have it defined, the full statement would look like this

logger:
  default: warn
  logs:
    custom_components.magic_areas.binary_sensor: debug

Then restart & check/post the logs

thorrrr commented 2 years ago

https://0bin.net/paste/fq6FvI-B#XojY3KNEAcC1qLV0KunXNqpSzSBfAUOUBfLGfLpAhAO

jseidl commented 2 years ago

Hmmm weird it seems to completely ignore the existence of the "Living Room" area.

Let's change a bit:

logger:
  default: warn
  logs:
    custom_components.magic_areas: debug
    custom_components.magic_areas.binary_sensor: warn
    custom_components.magic_areas.light: warn
    custom_components.magic_areas.climate: warn
    custom_components.magic_areas.media_player: warn
    custom_components.magic_areas.sensor: warn
    custom_components.magic_areas.switch: warn
    custom_components.magic_areas.cover: warn
    custom_components.magic_areas.config_flow: warn

This shall give us the initializer logs while suppressing the other features for now. Don't forget to restart!

thorrrr commented 2 years ago

https://0bin.net/paste/vdYuiRLQ#McxTIGm8jr6ThzDCu0koYmoENiJq-s1KvZu/AJYi3/D

Does that help?

jseidl commented 2 years ago

It's like the area didn't existed but I recall in a previous screenshot some devices assigned to a Living Room area. Just for peace of mind, can you double check the Areas section on Home Assistant and see if Living Room doesn't have any funny business? Should look something like this

image

jseidl commented 2 years ago

Are there other areas not loading or only Living Room?

thorrrr commented 2 years ago

image

thorrrr commented 2 years ago

image

jseidl commented 2 years ago

So Kitchen and Living Room are missing from my count. That is WEIRD. Trying to think of what's going on there....