Tutorial for new Custom State Card UI?

You don’t need all those files in /www/custom_ui/ unless you run in dev mode.
See instructions here: https://github.com/andrey-git/home-assistant-custom-ui/blob/master/docs/installing.md

In any case if custom_ui_state_card: state-card-custom-ui is working correctly, you should have either got an empty card with dev console error or a working card…

I followed the instructions. The extra_badge work fine. But the slider not show

Hi, all. I used these tutorials:
https://github.com/andrey-git/home-assistant-custom-ui#template-attributes, https://github.com/andrey-git/home-assistant-custom-ui/blob/master/docs/templates.md
to set custom state to one of my entity e.g

binary_sensor.h_p_8_1:
  custom_ui_state_card: state-card-custom-ui
  show_last_changed: true
  friendly_name: 'Motion sensor - door'
  templates:
    state: if (state === 'on') return 'activated'; else return state;

But anyway no errors in developer console and the state of my entity does not change to activated instead on.
@andrey Am I doing something wrong or may be documentaton is incomplete?

Are you trying to customize a badge in top badges section? That is not supported.

Your config should work if binary_sensor.h_p_8_1 is part of a group.

@andrey not exactly.
I didn’t post all related configuration in previous post. My fault. Actually I have something like this:
Groups configuration:

group:
	hallway:
	  name: 'hall'
	  entities:
		- binary_sensor.h_p_8_1
		- light.hall_light
		
	motions:
	  name: 'motions'
	  entities:
		- binary_sensor.k_p_6_1
		- binary_sensor.h_p_8_1

Customizer configuration:

customizer:
  custom_ui: local
  hide_attributes:
    - node_id
    - value_index

customize:
	binary_sensor.h_p_8_1:
		custom_ui_state_card: state-card-custom-ui
		show_last_changed: true
		friendly_name: 'Motion sensor - door'
		templates:
			state: if (state === 'on') return 'activated'; else return state;
		group:
			group.motions:
				friendly_name: 'MS hall door'

But I do not see that on state changes to activated when my sensor in on state even after F5 or Ctrl + F5 (I checked this in Chromium 58.0.3029.110, Opera 43.0.2442.1144)
Only new attribute is showing in detais for sensor:
ps1

Here Developer console (no errors there as you can see only warning):

Just to make sure: The template change is only supposed to change how the state card looks like, not the actual state gets written to history.

Could you add a screenshot of this sensor and it’s full list of attributes from /dev-state?

Sure. Here you are:


Here it looks like when the sensor becomes on:
ps5

The state template attribute still runs HA’s visual label logic that shows ‘detected’ for non-off motion sensors.

I pushed a new version - 20171019 that adds support for a new _stateDisplay template attribute that sets the final visual state without running that logic.

Try it with:

templates:
  _stateDisplay: if (state === 'on') return 'activated'; else return null;

@andrey, with last update everything works as expected. Thx a lot :+1:

I have version 0.54 of HA running on a Pi 2 with Raspbian OS. I’m trying to use the new custom state card feature for one light and it is not loading in my lights group after I add it to customize_glob.yaml. I have followed the instructions on https://github.com/andrey-git/home-assistant-custom-ui361 to install and activate the custom state cards.

Here is my config:

configuration.yaml:
customize: !include customize.yaml
customize_glob: !include customize_glob.yaml
customizer:
  custom_ui: local

customize_glob.yaml:
light.corner_table_lamp_level:
  custom_ui_state_card: state-card-custom-ui
  state_card_mode: break-slider
  hide_control: false
  show_last_changed: true
  slider_theme:
    min: 0
    max: 255
    pin: true
    off_when_min: false

Here is the state info from develop tools in HA:

 Entity ID
light.corner_table_lamp_level
 State
off
 State attributes (JSON, optional)
{
  "hide_control": false,
  "node_id": 20,
  "supported_features": 1,
  "value_id": "72057594378289153",
  "friendly_name": "Corner Table Lamp",
  "old_entity_id": "light.corner_table_lamp_level_20_0",
  "value_instance": 1,
  "value_index": 0,
  "slider_theme": {
    "min": 0,
    "max": 255,
    "pin": true,
    "off_when_min": false
  },
  "show_last_changed": true,
  "new_entity_id": "light.corner_table_lamp_level",
  "custom_ui_state_card": "state-card-custom-ui",
  "icon": "mdi:lamp",
  "state_card_mode": "break-slider"
}
SET STATE

Here is my lights group:

Lights:
  - light.front_living_room_blinds
  - light.rear_living_room_blinds
  - light.left_living_room_blinds
  - light.right_living_room_blinds
  - light.corner_table_lamp_level
  - switch.dual_outlet_switch_switch_2
  - switch.dual_outlet_switch_switch_3
  - light.living_room_level
  - light.dining_room_level
  - switch.stairwell_light_switch
  - switch.sitting_room_light_switch
  - light.keenan_bedroom_level
  - light.leviton_switch_level
  - switch.front_outside_light_switch
  - switch.driveway_light_switch

I am at a loss as to why this is not working. I have spent hours looking at the configs and trying different configurations with no luck. I have verified that state-card-custom-ui.html and state-card-custom-ui.html.gz are present in the ~/.homeassistant/www/custom-ui directory and that init.py and services.yaml are in ~/.homeassistant/custom_components/customizer. As far as I can tell, I have set it up correctly.

Any help would be greatly appreciated.

I don’t use glob, so I might be missing the mark here… but my understanding is glob is when you want to use wildcards. Since you are not doing that, put your customize into customize.yaml instead.

@kylerw

Thanks for pointing that out. I have been working on both badges in state cards and customizing the slider control. Got my wires crossed as some of the config for badges in state cards goes into the customize_glob.yaml. I also noticed that andrey’s example for slider control customization uses this:

frontend:
  extra_html_url:
    - /local/custom_ui/state-card-custom-ui.html

and I was using the customizer entry. I tried moving my slider customization for the light to customize.yaml and changed my configuration.yaml from using customizer to the frontend above, but I am still unable to see it in the group card. I’m not sure which one I should be using, customizer or front end, I’ve seen people say either one should work.

I also realized that I have never seen the brightness sliders on any of my lights/switches in the group card. They are only visible when I click on one of the lights and bring up the individual component card. From the docs and examples that I have seen, it looks like those should be visible in the groups cards.

I have also tried adding a second light with the same result, neither one shows up in my group card in the UI.

The two devices I am trying to use are a zwave light bulb and zwave dimmer switch. They both have zwave and light devices showing in the developer tools states display. I’m not sure if this has any bearing on my issue.

I see no errors in home-assistant.log that are related to this issue, here’s an excerpt from the light bulb device:

2018-01-04 15:09:08 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: old_state=None, new_state=<sta
te light.corner_table_lamp_level=off; friendly_name=Corner Table Lamp, value_instance=1, icon=mdi:lamp, supported_features=1, s
tate_card_mode=break-slider, node_id=20, hide_control=False, old_entity_id=light.corner_table_lamp_level_20_0, value_id=7205759
4378289153, value_index=0, new_entity_id=light.corner_table_lamp_level, custom_ui_state_card=state-card-custom-ui, slider_theme
=min=0, max=255, pin=True, off_when_min=False, show_last_changed=True @ 2018-01-04T15:09:08.707031-08:00>, entity_id=light.corn
er_table_lamp_level>
2018-01-04 15:09:08 DEBUG (Dummy-14) [libopenzwave] notif_callback : end
2018-01-04 15:09:08 DEBUG (MainThread) [homeassistant.components.websocket_api] WS 1803147344: Sending {'event': {'data': {'old_state': None, 'new_state': <state light.corner_table_lamp_level=off; friendly_name=Corner Table Lamp, value_instance=1, icon=mdi:lamp, supported_features=1, state_card_mode=break-slider, node_id=20, hide_control=False, old_entity_id=light.corner_table_lamp_level_20_0, value_id=72057594378289153, value_index=0, new_entity_id=light.corner_table_lamp_level, custom_ui_state_card=state-card-custom-ui, slider_theme=min=0, max=255, pin=True, off_when_min=False, show_last_changed=True @ 2018-01-04T15:09:08.707031-08:00>, 'entity_id': 'light.corner_table_lamp_level'}, 'time_fired': datetime.datetime(2018, 1, 4, 23, 9, 8, 707268, tzinfo=<UTC>), 'origin': 'LOCAL', 'event_type': 'state_changed'}, 'id': 2, 'type': 'event'}

If anyone has any other ideas, they would be greatly appreciated. I’m probably blind to the issue at this point since I’ve been digging through everything so much.

I have also not been successful in getting the badges in state cards working as well. Whenever I add this to my customize_glob.yaml file (included in configuration.yaml), all my individual devices disappear from the group cards.

"*.*":
custom_ui_state_card: state-card-custom-ui

Finally got both badges in state cards and custom state cards working after doing the following:

  • Updated HA to version 0.60, reran andrey’s update.sh script
  • Refactored/split additional configuration (I had split out quite a bit of my configuration including automation, sensors, etc several months ago)
  • Changed my config to use customized: instead of frontend:

I’m not sure exactly where the issue was, as I removed the slider customizations before I started and then added them back in at the end. At that point, it started working and the sliders appeared in my group cards.

All that time to get it working and I updated to HA 0.61.1 which seems to have broken it. Getting this error for customizer:

2018-01-18 16:42:16 ERROR (MainThread) [homeassistant.setup] Error during setup of component customizer
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/setup.py”, line 196, in _async_setup_component
result = yield from component.async_setup(hass, processed_config)
File “/config/custom_components/customizer/init.py”, line 115, in async_setup
SERVICE_SET_ATTRIBUTE_SCHEMA)
TypeError: async_register() takes from 4 to 5 positional arguments but 6 were given

Anyone upgrade and run into this?

I didn’t add custom_ui until 61.1 so can’t vouch for the upgrade process, but it’s working on 61.1 here.

I ran the update script and restarted hassio. That seemed to do the trick. Not sure if @andrey fixed something in his code, I don’t see any reference to a fix for the errors I was seeing, but the update worked.

Anyone who has figured out how to use the “blacklist_states” function for the “extra_badge” function?

I have a template sensor that shows if my dishwasher is running or not (based on an input_boolean)
For that sensor I’ve added an extra badge that shows the power usage.

homeassistant:
  customize:
      sensor.dishwasher_active_status:
        friendly_name: "Diskmaskin"
        entity_picture: /local/diskmaskin.png
        show_last_changed: true
        extra_badge:
          - entity_id: sensor.dishwasher_power_energy
            blacklist_states: 'off'

And this is the template sensor

sensor:
      - platform: template
        sensors:
          dishwasher_active_status:
            friendly_name: "Diskmaskin"
            value_template: "{% if is_state('input_boolean.dishwasher_switch', 'on') %}Diskar{% else %}Avstängd{% endif %}"

The blackist_states, is that the state of the badge based on “sensor.dishwasher_power_energy” (a specific watt value, in my case 2.0 is idle) or is it the platform_template sensor (on/off state, or maybe template values? “Diskar” or “Avstängd”)

ping @andrey

The entity id in your custom ui that you’re trying to blacklist a state is not a match to the sensor you’ve pasted, but the way I understand it is that it will disappear if the state matches what you put. So in the case of the sensor you posted, there is no ‘off’, it would need to be one of the two options it can be.

Yeah thats the first thing I tried, but the badge is still visible.

Curren’t setup right now

homeassistant:
  customize:
      sensor.dishwasher_active_status:
        friendly_name: "Diskmaskin"
        entity_picture: /local/diskmaskin.png
        show_last_changed: true
        extra_badge:
          - entity_id: sensor.dishwasher_power_energy
            blacklist_states: 'Avstängd'

Capture

Should have used that code in the first post, I’ve tried several different combinations to see if I could find the correct one.