Skip to content

Instantly share code, notes, and snippets.

@pjv
Last active January 12, 2020 12:58
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjv/521073b982e37418339afbf420691310 to your computer and use it in GitHub Desktop.
Save pjv/521073b982e37418339afbf420691310 to your computer and use it in GitHub Desktop.
Lovelace Compact Custom Header for old devices
@pjv
Copy link
Author

pjv commented Feb 14, 2019

NEW LOCATION

@maykar, the author of CCH is now keeping an up-to-date legacy version of CCH at this gist: https://gist.github.com/maykar/278cf3d81e99a7594d4a0d1677fe981f


LAST VERSION

The current version (1.0.4b8) is the last version I am able to produce automatically and make available here. Due to changes in how the editor component is being dynamically imported, my limited javascript and babelization skills make it so that my automated build no longer works. Someone with more JS fu would probably be able to get more recent versions transpiled successfully. I'm actually still using CCH (currently on version 1.2.1) but using it on my Fire Tablet requires my manually hacking the transpiled code to strip out most everything to do with the editor component. I'm not going to make that code public because it strays too far from @maykar's code.


Current (Revision 18) is version 1.0.4b8 of Compact Custom Header transpiled to old javascript for older (pre ES6) devices. As long as I am using CCH, as new versions of CCH are released, I'll revise this gist with updates.

For those who know babel better than me (which would be easy) this is the config that I am using for the transpile (suggestions for a better config gratefully encouraged):

const presets = [
  [
    "@babel/env",
    {
      targets: {
        chrome: "50"
      },
    },
  ],
];
module.exports = { presets };

The resulting commonJS is then processed with browserify to produce the code above.

Please note that this version has the Home Assistant Lovelace Editor functions commented out as that was keeping me from successfully producing working js, so this will only be useful to you if you are using yaml mode to manage your Lovelace UI.

Editor code included as of revision 2. I am using YAML mode so cannot test, but the editor code is included in this gist. You do not need the separate compact-custom-header-editor.js file - it's all in the above.

I suggest changing the name so as not to collide with updates to the standard version of CCH. I'm using compact-custom-header-legacy.js. Contrary to the documentation on the CCH github, you should include this in your Lovelace config as js rather than as module like so:

- url: /local/custom-lovelace/compact-custom-header/compact-custom-header-legacy.js?v=0.0.1
  type: js

Finally, this code is 100% unsupported as-is-ware. If it works for you and helps you out, great. But neither myself nor (more importantly) @maykar are supporting this code so if you are running it and you have issues, please don't post them in the original project's github. Just assume that whatever the problem is is my fault and I'm too dumb to fix it.

@MarcWim
Copy link

MarcWim commented Mar 15, 2019

Thanks a lot for this!!! It is exactly what I needed :)

@skynet01
Copy link

Thanks again for maintaining this, really appreciate it!

@volpmatt
Copy link

volpmatt commented Jul 21, 2019

Hey, can anyone tell me how to use this please? I have the normal version of CCH working, but not on my Fire HD 8. What do I have to do with this legacy version once I have it installed in

/local/custom-lovelace/compact-custom-header/

and

- url: /local/custom-lovelace/compact-custom-header/compact-custom-header-legacy.js?v=1.0.4
  type: js

added to my Lovelace config?

@skynet01
Copy link

just paste the code from legacy.js (this file) over the standard compact-custom-header.js code and it should be working... however the newest version is not working for me either. Any updates to get the latest version pjv?

@pjv
Copy link
Author

pjv commented Jul 28, 2019

Any updates to get the latest version pjv?

I believe that @maykar is working on a new way of referencing the editor component code and once he releases a version with that re-factoring, I should be able to post up a legacy version of that code.

@pjv
Copy link
Author

pjv commented Aug 4, 2019

@maykar is now providing an up-to-date version of this legacy code here: https://gist.github.com/maykar/278cf3d81e99a7594d4a0d1677fe981f

@GreenhouseAU
Copy link

I assume this is kaput now? (link above is dead)

@pjv
Copy link
Author

pjv commented Jan 12, 2020

I assume this is kaput now? (link above is dead)

You should try asking @maykar if he is still supporting a legacy version of the new custom header which replaced CCH.

@maykar
Copy link

maykar commented Jan 12, 2020

There should be no need for a legacy version for the new custom header. I'm now using Babel to convert in the main project in order to support all devices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment