Anashost / MY-HA-DASH

81 stars 8 forks source link

Light Group #4

Closed ephraimvm closed 8 months ago

ephraimvm commented 8 months ago

Hi

I am new to HA and coding hope you have patience to point mistakes on my codes, I can't still make the Light Group works. Kind regards, ephraim

this is my card

[url]https://i.imgur.com/maXE9qZ.png[/url]

and this is my sensor yaml

[img]https://i.imgur.com/maXE9qZ.png[/img]

did i miss something?

- platform: template
  sensors:
          lights_of_count:
            friendly_name: 'Lights of count'
            unique_id: lights_of_count
            value_template: > 
              {%- set search_state = 'on' %}
              {%- set search_areas = ['Master Bedroom','Living Room','Kitchen','Kids Room','Bathroom','Dining Room','Garage'] %}
              {%- set ns = namespace(lights=[]) %}
              {%- for light in states.light 
  selectattr('state','eq', search_state)
          | rejectattr('object_id', 'search', 'segment')%}
            {%- for area in search_areas %}
              {% if area_name(light.entity_id) == area %}
                {%- set ns.lights = ns.lights + [ light.entity_id ] %}
              {% endif%}
              {%- endfor %}
              {%- endfor %}
              {{ ns.lights| list | length }}
Anashost commented 8 months ago

Hey friend I think this is the header card, So whats exactly not working, like you get error messages or unknown/unavailable states from the sensor. Could you give me more context on what you have done?

Make sure you pay attention to the steps and restart Home assistant after creating the sensor, the lights group and adding the lights to the Area's you've created.

ephraimvm commented 8 months ago

yes it was the header card I have trouble with the yaml when I pasted the code im getting this error in the bottom of the last line

can not read a block mapping entry; a multiline key may not be an implicit key YAML

ephraimvm commented 8 months ago

Don't worry I am able to Fix it now, its just some indentation issues. thanks heaps.