Build a sensor for flex-table-card

Hi all,

I am newbie to HASS, I tried to find similar issue but still cannot find any similar issue/solution so I am creating this topic.

I have 2 door sensors monitoring door open/close state with open duration of each sensor as .json payload below:

{
"main_door": false,
"main_door_open_duration": 0,
"back_door": true,
"back_door_open_duration": 10,
"version": "1.1"
}

I would like to use flex-table-card to display state + open duration of both sensors like this (read only):

image

I tried to created a mqtt sensor in configuration.yaml file, but I cannot get it work

This is my mqtt sensor config.:

mqtt:
  sensor:
    - name: "DoorMainX"
      state_topic: "home/main/sensor/states"
      value_template: '{{ value_json.main_door, value_json.main_door_lo |float|round(0) }}'

I also tried with template sensor in configuration.yaml file as below but it does not work neither:

template:
- sensor:
  - name: DoorMainY
    state: "{{ states('sensor.entrance_main_door'), states('sensor.entrance_main_door_opened_duration') }}"

With those above configuration, I received only table as below (missing duration):
image

Could you please help me to get separated State, Duration columns with correct information? Please show me which file I should add/modify configuration also (as a newbie needed) :slight_smile:

Thanks in advance!

Thuy

Concentrate on getting the values into HA first.
You can see in the developer tools what the different sensors have of value without having to fight card setups too.
Once you get the right value in the developer tools, then look into setting the cards up.

Thanks for your reply.

Getting correct values is easy for me. I could display single value without any issue so I want to arrange them in a structure way so this is an simple example of my payload for demonstration of my question.

Hopefully you have suggestion for me to create such “sensor” for showing data on the flex-table-card

Thuy

Ask flex-table-card-related questions here.

1 Like

I do not know the flex-table-card at all. I would probably use a markdown card instead and then use a html table inside.
The markdown card is much more powerful and flexible.

1 Like