Custom UI: Tiles

Thank you for posting, will be copying a lot of this to make a tablet display

Does that entity properly show the current title of the content playing?

Hi all,

Hereā€™s another addition Iā€™ve recently added that makes designing remote controls much easier by associating the button press with a specific remote command. No need for automations.

In the button_tapped function of each custom_ui file, add:

	if (ev.model.entity.remote_service){
		var remote_device = ev.model.entity.remote_service.device;
		var remote_command  = ev.model.entity.remote_service.command;
		var remote_entity_id = ev.model.entity.remote_service.entity_id;
		this.hass.callService("remote", "send_command", { "device":remote_device, "command":remote_command, "entity_id": remote_entity_id});
		return 
	}

These few lines add the ability to associate a service of a remote entity directly with a press of the tile. Just add a section under an entityā€™s config with remote_service. Tabbed into the remote service should be (1) device, (2) command, and (3) entity_id. The entity id here is the id of the remote that youā€™d like to trigger when the button is pressed. All three of these are required.

As an example:

input_text.dummy_media_controls:
  custom_ui_state_card: state-card-tiles
  config:
    columns: 1    
    row_height: 54px      
    gap: 8px              
    entities:
      - entity: light.null
        label: Living Room Television
        column: 1              
        column_span: 1
        row: 1          
        row_span: 1
        icon: mdi:power
        icon_size: 18px
        remote_service:
          device: '123456789'
          command: 'PowerToggle'
          entity_id: 'remote.harmony_hub'

I hope that makes sense. It has been working great for me.


@eddi89 - whatā€™s your preferred means for feature requests/feature additions? PRs on github? Posts on this forum?

2 Likes

Anyone know how to do this with Custom UI Tiles? Basically Iā€™m trying to have the entity picture of a media player on the left and text details of what the media player is playing on the right.
41%20PM

Iā€™d also like to use Tiles to show my cameras (so I can fit more on the screen than HA allows at one time). Any thoughts on how to do that as well?

Thanks in advance

I have 6 favourite radiochannels and the TV as sound sources for my sonos.
When i play the diffrent channels i get some diffrent results in the state in my media_player.sonos_living_room
Its the state ā€œmedia_titleā€ i use for sensor.sonos_titel.

I would love to be able to detect when the state is ā€œmixmegapol_instream_se_aacp?ā€, ā€œRIX FMā€, ā€œNRJā€, ā€œRockklassikerā€, ā€œVinyl FMā€ or ā€œā€ (null)
And instead set the sensor.sonos_titel to ā€œnot availibleā€.
But if the state is anything else, that should be set. (like ā€œSpending My Timeā€ or ā€œBohemian Rhapsodyā€ in the case from down below)


Diffrent state on diffrent radio channel

Mix Megapol
media_title: mixmegapol_instream_se_aacp?
media_title: Spending My Time

Rix FM
media_title: RIX FM

Bandit Rock
media_title: Bohemian Rhapsody

NRJ
media_title: NRJ

Rockklassiker
media_title: Rockklassiker

Vinyl
media_title: Vinyl FM

TV
media_title:

would one be able to use an input_select also? Looking for ways to have Tiles use several of them hereā€¦

Yes, certainly possible. That said, Iā€™d recommend going the more_info route for selecting the option. Else, a UI for selecting an option would have to be designed. Perhaps not, but Iā€™d go with more_info dialogs. Thatā€™s what Iā€™ve done for our HVAC, for example.

eddi89 doesnā€™t post on here anymore unfortunately (https://github.com/c727/home-assistant-tiles/issues/14), but he is very responsive on this projectā€™s GitHub page: https://github.com/c727/home-assistant-tiles
It certainly is worth doing some PRs because I really like the additions youā€™ve made to the UI code.

He and I are in touch. In fact, heā€™s already added the remote feature I wrote about less than 12 hours ago!

I think Iā€™d first try accessing the attribute directly from the tile in lieu of adding a sensor.

But that is not the problem, i can show the ā€œrawā€ value from the attribute.
But what i want to do is ā€œfilter outā€ sertain values that from some radio channels is irelevant, and replace them with a generic value.
Since some radio channel reports a strange string (mixmegapol_instream_se_aacp?) instead of the song title on the ā€œsong titleā€ attribute.

must have missed that, is in in your code posted here? or maybe you can share?

not posted here - still working out a number of kinks. :slight_smile:

That said, itā€™s similar to other nest control input_select projects youā€™ll find on the forum. Still not quite happy with it, but when I am, Iā€™ll post it!

Iā€™m not sure I completely understand the issue, but it sounds like a label_template is what youā€™re looking for. Perhaps looking for an underscore and branch to a different attribute or string then? Perhaps something like:

label_template: ' if (attributes.song_title.contains("_")) { return DO SOMETHING} else {return state}'

ok thanks, please do :+1:

Thank you very much for sharing! i used a lot of your code in my own set-up and it is looking amazing.

1 Like

Thank you very much for sharing. Very nice and useful.

1 Like

Chrome shows this warning the console:

Deprecation] Styling master document from stylesheets defined in HTML Imports is deprecated, and is planned to be removed in M65, around March 2018. Please refer to https://goo.gl/EGXzpw for possible migration paths.

And I think it refers to this plugin. Or maybe to the panel functionality that one can use with this plugin.

@andrewjfreyer: Are you aware of that problem and is it something that can be fixed on your side? This will soon stop working.
EDIT: Or actually @eddi89 I guess. I confused the author. Sorry.

Has anyone successfully used math in their label templating? Iā€™m trying to show temperature sensors and round them to just the whole number (ie. ā€œ69ā€ instead of ā€œ69.3ā€). Iā€™ve tried a few different ways without any luck.

entities:
          - entity: sensor.home_temperature
            label: {{ states.sensor.home_temperature.state | round }}
            label_sec: Home

For anyone else searching - I couldnā€™t find a way to do this through Jinja templating, but it works with javascript (which I missed in the tiles readme):

label_template: "return Math.round(state) + 'ĀŗF'"

1 Like