h4 / LYWSD02-home-assistant

Home-Assistant sensor for LYWSD02 Thermometer
75 stars 12 forks source link

create sensor templates (maybe basic question..?) #9

Closed dlwoals131 closed 4 years ago

dlwoals131 commented 4 years ago

The sensor is connected after step 2. Then I add step 3 at Configuration.yaml same as below. Then it shows some error.. Please check Config file, error log, Template editor

Configuration.yaml file

lywsd02: mac: E7:2E:00:D1:04:5B sensor:

sensor:

error log

Error loading /config/configuration.yaml: while parsing a block collection in "/config/configuration.yaml", line 24, column 4 expected , but found '' in "/config/configuration.yaml", line 25, column 5

Template editor

Imitate available variables: {% set my_test_json = { "temperature": 25, "unit": "°C" } %}

The temperature is {{ my_test_json.temperature }} {{ my_test_json.unit }}.

{% if is_state("device_tracker.paulus", "home") and is_state("device_tracker.anne_therese", "home") -%} You are both home, you silly {%- else -%} Anne Therese is at {{ states("device_tracker.anne_therese") }} Paulus is at {{ states("device_tracker.paulus") }} {%- endif %}

For loop example: {% for state in states.sensor -%} {%- if loop.first %}The {% elif loop.last %} and the {% else %}, the {% endif -%} {{ state.name | lower }} is {{state.state_with_unit}} {%- endfor %}.

dlwoals131 commented 4 years ago

I deleted the step 3 then it shows some error also.^^; 2019-11-14 10:10:50 ERROR (MainThread) [custom_components.lywsd02] Could not update data - Failed to connect to peripheral E7:2E:00:D1:04:5B, addr type: public

h4 commented 4 years ago

In most cases message Failed to connect to peripheral E7:2E:00:D1:04:5B, addr type: public sends if your device placed too far from host.

dlwoals131 commented 4 years ago

Oops! I solved the problem/// The problem was space^^; Thanks