Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce new parameters to hide history and logbook #2

Merged
merged 3 commits into from
Jan 1, 2024

Conversation

elchininet
Copy link
Collaborator

This pull request implements four new paremeters to manage the visibility of the history and logbook blocks inside more-info dialogs.

The next example is made using hide_history and unhide_history, but the same applies to hide_logbook and unhide_logbook.

custom_more_info:
  hide_history:
    by_entity_id:
      - some_entity
      - some_entity
    by_domain:
      - some_domain
      - some_domain
    by_device_class:
      - some_device_class
      - some_device_class
    by_glob:
      - some_glob
      - some_glob
 unhide_history:
    by_entity_id:
      - some_entity
      - some_entity
    by_domain:
      - some_domain
      - some_domain
    by_device_class:
      - some_device_class
      - some_device_class
    by_glob:
      - some_glob
      - some_glob 

@elchininet elchininet added enhancement New feature or request refactor labels Dec 23, 2023
@elchininet
Copy link
Collaborator Author

@Mariusthvdb,
This is still a draft, so don‘t merge it yet. As it refactors the whole library, it needs to be tested not only for the new parameters but also for the previous ones. Test it deeply and let‘s track in this pull request any bug or unwanted behaviour that you find, so we can start fixing from here.

@Mariusthvdb
Copy link
Owner

Mariusthvdb commented Dec 23, 2023

ok first test on input_boolean fails...

I have it setup alongside custom_attributes, to only hide logbook/history for now.

[Debug] { (custom-more-info.js, line 1)
    "debug": true,
    "hide_history": {
        "by_entity_id": null,
        "by_domain": [
            "input_select"
        ],
        "by_device_class": null,
        "by_glob": null
    },
    "hide_logbook": {
        "by_entity_id": null,
        "by_domain": null,
        "by_device_class": null,
        "by_glob": null
    }
}

is in instpector, so I take it the debug: true also works?

Scherm­afbeelding 2023-12-23 om 17 05 51

the others are left empty, not sure if that causes harm

adding it also on input_boolean and showing g the more info logs

[Debug] dialog content has not been found (custom-more-info.js, line 1)

deleting the empty hide, and only setting it on input_select for logbook and history works!

Scherm­afbeelding 2023-12-23 om 17 12 34
[Debug] { (custom-more-info.js, line 1)
    "hide_history": true,
    "hide_logbook": true
}
[Debug] finished the task of querying attributes, the result is (custom-attributes.js, line 1)
[Debug] attributes have not been found (custom-attributes.js, line 1)

note that I havent set any attributes filtering in custom-more-info, so the logging is from the other plugin? maybe we shouldnt log anything if no filter was set? this reads like an error, while in fact it is simply not set.

still doesnt work on boolean:

Scherm­afbeelding 2023-12-23 om 17 14 07

maybe because it is under another 'tab' on the more-info? and not directly there like on input_select

Scherm­afbeelding 2023-12-23 om 17 13 32

yes I think that is it. the separate history icon/view does not get filtered (like on domain siren), while others, like input_number, number filter fine.

btw, I did also try

hide_all:

  by_domain:
    - number

but that does nothing yet ;-) might be a FR already..

@elchininet
Copy link
Collaborator Author

@Mariusthvdb,
Do not use both plugins at the same time because they do the same. Test just this plugin. This is the beginning of what I get on my end:

image

@elchininet
Copy link
Collaborator Author

Also, in the line of the error, the t.find, try to check the piece of code that throws the error so I can detect which part of the code is failing.

@elchininet
Copy link
Collaborator Author

maybe because it is under another 'tab' on the more-info? and not directly there like on input_select

yes I think that is it. the separate history icon/view does not get filtered (like on domain siren), while others, like input_number, number filter fine.

That is not implemented, at the moment we only search inside the more-info dialog not inside the view that appears when you click on the history on the header. That is also supported by home-assistant-query-selector but it needs to be implemented.

@Mariusthvdb
Copy link
Owner

Mariusthvdb commented Dec 23, 2023

Test just this plugin.

ok, done.
installed the filters I had before in custom_attributes, and now the additional hide's of custom-more-info.

results seems to be the same, though the logging is a bit different.

That is not implemented, at the moment we only search inside the more-info dialog not inside the view that appears when you click on the history on the header. That is also supported by home-assistant-query-selector but it needs to be implemented.

yes, that is important, because it is like that for quite some domains/entities

maybe we can make that easier, but simply not showing the icon to that view?

do you need me to find all domains and see what they have in more-info? Or, is this a generic thing, and will the 2 formats (direct in the more-info, or on the separate icon/view) be enough to handle all situations

@Mariusthvdb
Copy link
Owner

Also, in the line of the error, the t.find, try to check the piece of code that throws the error so I can detect which part of the code is failing.

cant reproduce the error anymore now, maybe it was because of the double plugin being used

@elchininet
Copy link
Collaborator Author

results seems to be the same, though the logging is a bit different.

So does it keep broken for you then?

yes, that is important, because it is like that for quite some domains/entities
maybe we can make that easier, but simply not showing the icon to that subview?

No, do not worry, it is something that will not be hard to implement because home-assistant-query-selector throws and event when that view is open.

do you need me to find all domains and see what they have in more-info? Or, is this a generic thing, and will the 2 formats (direct in the more-info, or on the separate icon/view) be enough to handle all situations

I think that is the case, only those two situations.

cant reproduce the error anymore now, maybe it was because of the double plugin being used

Ok, perfect.

@Mariusthvdb
Copy link
Owner

@elchininet really odd, please check if you can explain this. my testing config was:

hide_history:
  by_entity_id:
#       - input_number.active_icon_size
     - binary_sensor.ongemeten_verbruik_te_hoog

  by_domain:
    - input_select
    - input_boolean
    - number

  by_device_class:
    - sound

  by_glob:
    - 'siren.*'
    - 'input_number.*'
    - '*_overcurrent_detected'

and then I noticed at least all of my filter attributes that are configured below this to stop working.... could not understand, as they are 1-1 copy of the custom_attributes config.

then I noticed that I made a typo, and that the bottom hide should have been

    - '*_over_current_detected'

I corrected it, and yes, then all of the other filters started working again..

could this be true? maybe you can test that too.
I would have expected that wrong glob simply would have done nothing, as here are no entities in the system that match.

not cause such an effect at all

@Mariusthvdb
Copy link
Owner

So does it keep broken for you then?

no not broken, this was my first test, and it happened to be the input_boolean that wasn't implemented just yet...

@elchininet
Copy link
Collaborator Author

no not broken, this was my first test, and it happened to be the input_boolean that wasn't implemented just yet...

Got it. I just pushed a change to hide history and logbook also in the onLovelaceHistoryAndLogBookDialogOpen event. Test it with those input booleans.

@elchininet
Copy link
Collaborator Author

could this be true? maybe you can test that too.
AI would have expected that wrong glob simply would have done nothing, as here are no entities in the system that match.

I‘ll check it.

@elchininet
Copy link
Collaborator Author

then I noticed that I made a typo, and that the bottom hide should have been

I cannot reproduce this, could you test it again to see if you can reproduce it every time that you add it to your config?

@Mariusthvdb
Copy link
Owner

I just pushed a change to hide history and logbook also in the onLovelaceHistoryAndLogBookDialogOpen event. Test it with those input booleans.

yes, the boolean is now hidden too:

Scherm­afbeelding 2023-12-23 om 23 59 41

which ofc is a bit silly ;-)

coming from the entity more-info

Scherm­afbeelding 2023-12-24 om 00 01 16

we should try and hide the history icon instead

@Mariusthvdb
Copy link
Owner

Mariusthvdb commented Dec 23, 2023

I cannot reproduce this, could you test it again to see if you can reproduce it every time that you add it to your config?

this is new:

{
    "filter_attributes": [
        "icon_color",
        "id",
        "all",
        "_$Ei",
        "isUpdatePending",
        "hasUpdated",
        "_$El",
        "enableUpdating",
        "_$E_",
        "_$AL",
        "renderOptions",
        "_$Do",
        "___expanded",
        "__hass",
        "__stateObj",
        "renderRoot"
    ],
    "unfilter_attributes": [
        "ip",
        "mac",
        "ap_mac"
    ]
}

filtering 'all' attributes on glob

  by_glob:
# first filter 'all' in glob, then unfilter only what user needs in the unfilter section
    'device_tracker.google*':
      - all

and unfilter some attributes

  by_glob:

    'device_tracker.google*':
      - ip
      - mac
      - ap_mac

and the result is, none of the attributes are filtered anymore (this happens with the latest push )

@elchininet
Copy link
Collaborator Author

elchininet commented Dec 23, 2023

We should try and hide the history icon instead

I think that you want to replicate the entire kiosk mode here 😅
haha, no not at all!

Kiosk-mode is extremely powerful and very generic. which is great, I use it as a core piece of software in my dashboard.

however, it does not allow the control we seek to offer here.

Surely you agree that it is useless to display the history icon, when both logbook and history are hidden?
It would add to the user experience not to be offered an empty view like that, and simply not be distracted. by that icon I the first place.

edit

@Mariusthvdb
Copy link
Owner

Mariusthvdb commented Dec 24, 2023

not sure whats happening, but this also shows on a ha_*_version glob:

filter_attributes:

  by_glob:

    '*.*':
#       - templates
      - icon_color
      - id

# filter all atributes on all entities
#       - all

# first filter 'all' in glob, then unfilter only what user needs in the unfilter section
    'device_tracker.google*':
      - all
    'device_tracker.heater_*':
      - all

    'sensor.ha_*_version':
      - all

Scherm­afbeelding 2023-12-24 om 12 28 33

ive found the issue I think, it isnt the glob, but its the

- all

all of my filters work fine, except the ones using - all, on any of the 4 by_xx options

check this happing on a light

  by_domain:

    light:
      - all
Scherm­afbeelding 2023-12-24 om 12 34 44

@Mariusthvdb
Copy link
Owner

Mariusthvdb commented Dec 24, 2023

We should try and hide the history icon instead

I think that you want to replicate the entire kiosk mode here 😅 haha, no not at all!

Kiosk-mode is extremely powerful and very generic. which is great, I use it as a core piece of software in my dashboard.

however, it does not allow the control we seek to offer here.

Surely you agree that it is useless to display the history icon, when both logbook and history are hidden? It would add to the user experience not to be offered an empty view like that, and simply not be distracted. by that icon I the first place.

@elchininet not sure what happened here, but I seem to have edited your post...... and not quoted it, which is what I intended to do.
How is this even possible.....

@elchininet
Copy link
Collaborator Author

all of my filters work fine, except the ones using - all, on any of the 4 by_xx options

I will take a look at the all filter later to see if I detect the issue there.

Surely you agree that it is useless to display the history icon, when both logbook and history are hidden? It would add to the user experience not to be offered an empty view like that, and simply not be distracted. by that icon I the first place.

I am not saying if it is useless or not, I am just pointing out that maybe you need to wait for something being a problem or create a bad user experience to someone before implement it. Every piece of code creates tech debt, code more dificult to maintain, more hard to get cntributors willing to contribute, more prone to bugs and more likely to break in new Home Assistant version. That is why is wise to have the base features and escalate a product depending on real user necessities and the feedback that you receive from them instead of covering every single edge case that occurs if one sets certains options in certain way. But this is just my recommendation, you can implement what you prefer and when you prefer.

@elchininet not sure what happened here, but I seem to have edited your post...... and not quoted it, which is what I intended to do.
How is this even possible.....

Really don‘t know, Github has some glitches sometimes. 🤷🏼‍♂️

@elchininet
Copy link
Collaborator Author

all of my filters work fine, except the ones using - all, on any of the 4 by_xx options

@Mariusthvdb, this should be fixed now, there was a bug in the all logic.

@elchininet
Copy link
Collaborator Author

we should try and hide the history icon instead

About this, what do you think is the best way to manage it? Hide it automatically when someone hides history and logbook? or hiding it with a config option?

@Mariusthvdb
Copy link
Owner

his should be fixed now, there was a bug in the all logic.

confirm the fix, thanks you vm.

About this, what do you think is the best way to manage it? Hide it automatically when someone hides history and logbook? or hiding it with a config option?

if you ask me, we need both.....
as a servie to the user, automatic would be very good.

then again, the user hides it with a config option, so these are in fact the same (unless there is something I dont understand in what you are saying...)

Also, besides the config option, I still would hope we can import (Include) the history/logbook/recorder config and make it all happen automatically based on that (so not even require a manual configuration a all)

@elchininet
Copy link
Collaborator Author

Hi @Mariusthvdb,
Happy new year :)
If this is working, let‘s merge it. I‘ll try with minimum changes to bring the new functionalities for hiding the icon on the header in a separate PR.
Regards

@Mariusthvdb Mariusthvdb marked this pull request as ready for review January 1, 2024 15:18
Copy link
Owner

@Mariusthvdb Mariusthvdb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please go ahead, thank you very much.

Have a great 2024 ;-)

@elchininet elchininet merged commit 7a5cf95 into main Jan 1, 2024
2 checks passed
@elchininet elchininet deleted the new_parmeters_to_hide_history_logbook branch January 1, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants