Hi there,
sorry in advance, i´m quite new to home assistant.
I have a bsb-lan device, which is broadcasting via mqtt.
I have a weatherxm-station which i integrated with a code i got from a forum.
I try to integrate both as sensors.
In configuration.yaml i have this:
sensor: !include_dir_merge_list configs/sensors/
then in the folder i have two files.
One is for bsb-lan, bsb_lan.yaml:
mqtt:
sensor:
- name: "BSB-LAN Aussentemperatur"
state_topic: "BSB/8700"
unique_id: bsb_lan_aussentemperatur
unit_of_measurement: °C
device_class: temperature
state_class: measurement
availability_topic: "BSB/status"
device:
{
identifiers: ["00000002"],
name: "Heizung",
model: "Arduino Due",
manufacturer: "Github",
}
the other one, code is from an other user, is the weatherxm.yaml:
- platform: rest
name: "weatherxm_sensor"
resource: https://api.weatherxm.com/api/v1/cells/XXX/devices
scan_interval: 300
value_template: "{{ value_json.value }}"
json_attributes_path: $.[0].current_weather
json_attributes:
- temperature
- feels_like
- humidity
- icon
- precipitation
- precipitation_accumulated
- pressure
- uv_index
- wind_direction
- wind_gust
- wind_speed
## temperature celsius °C
- platform: template
sensors:
weatherxm_temperature_celsius:
value_template: >
{% set state = state_attr('sensor.weatherxm_sensor', 'temperature')|round(1) %}
{% if state < 1 %} {{ state | round(0) }}
{% else %} {{ state }}
{% endif %}
device_class: temperature
unit_of_measurement: "°C"
## temperature fahrenheit °F
- platform: template
sensors:
weatherxm_temperature_fahrenheit:
value_template: "{{ (state_attr('sensor.weatherxm_sensor', 'temperature') * 9/5 + 32) |round(1)}}"
device_class: temperature
unit_of_measurement: "°F"
## feels like celsius °C
- platform: template
sensors:
weatherxm_feels_like_celsius:
value_template: >
{% set state = state_attr('sensor.weatherxm_sensor', 'feels_like')|round(1) %}
{% if state < 1 %} {{ state | round(0) }}
{% else %} {{ state }}
{% endif %}
device_class: temperature
unit_of_measurement: "°C"
## feels like fahrenheit °F
- platform: template
sensors:
weatherxm_feels_like_fahrenheit:
value_template: "{{ (state_attr('sensor.weatherxm_sensor', 'feels_like') * 9/5 + 32) |round(1)}}"
device_class: temperature
unit_of_measurement: "°F"
## humidity
- platform: template
sensors:
weatherxm_humidity:
value_template: "{{ state_attr('sensor.weatherxm_sensor', 'humidity')|round(2)}}"
device_class: humidity
unit_of_measurement: "%"
## wind speed kmh
- platform: template
sensors:
weatherxm_wind_speed_kmh:
value_template: "{{ (state_attr('sensor.weatherxm_sensor', 'wind_speed') |float * 3.6) |round(2) }}"
unit_of_measurement: "km/h"
## wind gust kmh
- platform: template
sensors:
weatherxm_wind_gust_kmh:
value_template: "{{ (state_attr('sensor.weatherxm_sensor', 'wind_gust') |float * 3.6) |round(2) }}"
unit_of_measurement: "km/h"
## wind speed mph
- platform: template
sensors:
weatherxm_wind_speed_mph:
value_template: "{{ (state_attr('sensor.weatherxm_sensor', 'wind_speed') |float / 1.60934) |round(2) }}"
unit_of_measurement: "mph"
## wind gust mph
- platform: template
sensors:
weatherxm_wind_gust_mph:
value_template: "{{ (state_attr('sensor.weatherxm_sensor', 'wind_gust') |float / 1.60934) |round(2) }}"
unit_of_measurement: "mph"
## weather condition
- platform: template
sensors:
weatherxm_weather_condition:
value_template: >
{% set state = state_attr('sensor.weatherxm_sensor', 'icon') %}
{% if state == 'partly-cloudy-night' %} Partly cloudy
{% elif state == 'partly-cloudy-day' %} Partly cloudy
{% elif state == 'cloudy-night' %} Cloudy
{% elif state == 'cloudy-day' %} Cloudy
{% elif state == 'sunny' %} Sunny
{% elif state == 'drizzle' %} Rainy
{% elif state == 'rainy' %} Rainy
{% elif state == 'rain' %} Rainy
{% elif state == 'unavailable' %} -
{% elif state == 'Unavailable' %} -
{% elif state == 'unknown' %} -
{% elif state == 'Unknown' %} -
{% endif %}
## weather condition icon
- platform: template
sensors:
weatherxm_icon:
friendly_name: 'weatherxm icon'
value_template: >
{% set state = state_attr('sensor.weatherxm_sensor', 'icon') %}
{% if state == 'partly-cloudy-night' %} mdi:weather-night-partly-cloudy
{% elif state == 'partly-cloudy-day' %} mdi:weather-partly-cloudy
{% elif state == 'cloudy-night' %} mdi:weather-night-partly-cloudy
{% elif state == 'cloudy-day' %} mdi:weather-cloudy
{% elif state == 'sunny' %} mdi:weather-sunny
{% elif state == 'drizzle' %} mdi:weather-pouring
{% elif state == 'rainy' %} mdi:weather-pouring
{% elif state == 'rain' %} mdi:weather-pouring
{% elif state == 'unavailable' %} mdi:reload
{% elif state == 'Unavailable' %} mdi:reload
{% elif state == 'unknown' %} mdi:reload
{% elif state == 'Unknown' %} mdi:reload
{% endif %}
## weather condition icon color
- platform: template
sensors:
weatherxm_icon_color:
friendly_name: 'weatherxm icon color'
value_template: >
{% set state = state_attr('sensor.weatherxm_sensor', 'icon') %}
{% if state == 'partly-cloudy-night' %} blue-grey
{% elif state == 'partly-cloudy-day' %} white
{% elif state == 'cloudy-night' %} blue-grey
{% elif state == 'cloudy-day' %} white
{% elif state == 'sunny' %} yellow
{% elif state == 'drizzle' %} blue
{% elif state == 'rainy' %} blue
{% elif state == 'rain' %} blue
{% elif state == 'unavailable' %} grey
{% elif state == 'Unavailable' %} grey
{% elif state == 'unknown' %} grey
{% elif state == 'Unknown' %} grey
{% endif %}
## pressure hpa
- platform: template
sensors:
weatherxm_pressure_hpa:
value_template: "{{ state_attr('sensor.weatherxm_sensor', 'pressure')|round(0)}}"
device_class: pressure
unit_of_measurement: "hPa"
## wind direction
- platform: template
sensors:
weatherxm_wind_direction:
value_template: "{{ state_attr('sensor.weatherxm_sensor', 'wind_direction')}}"
unit_of_measurement: "°"
## wind direction cardinal
- platform: template
sensors:
weatherxm_wind_direction_cardinal:
value_template: >
{% set direction = ['N','NNE','NE','ENE','E','ESE','SE','SSE','S','SSW','SW','WSW','W','WNW','NW','NNW','N'] %}
{% set degree = states('sensor.weatherxm_wind_direction')|float %}
{{ direction[((degree+11.25)/22.5)|int] }}
## live precipitation mm
- platform: template
sensors:
weatherxm_live_precipitation_mm:
value_template: "{{ state_attr('sensor.weatherxm_sensor', 'precipitation') | float | round(2)}}"
device_class: precipitation_intensity
unit_of_measurement: "mm/h"
## live precipitation inch
- platform: template
sensors:
weatherxm_live_precipitation_inch:
value_template: "{{ (state_attr('sensor.weatherxm_sensor', 'precipitation')| float / 25.4)|round(2) }}"
device_class: precipitation_intensity
unit_of_measurement: "in/h"
## uv index
- platform: template
sensors:
weatherxm_uv_index:
value_template: "{{ state_attr('sensor.weatherxm_sensor', 'uv_index')}}"
unit_of_measurement: "UV Index"
## daily precipitation mm
- platform: template
sensors:
weatherxm_daily_precipitation_mm:
value_template: "{{ state_attr('sensor.weatherxm_sensor', 'precipitation_accumulated') | float | round(2) }}"
device_class: precipitation
unit_of_measurement: "mm"
## daily precipitation inch
- platform: template
sensors:
weatherxm_daily_precipitation_inch:
value_template: "{{ (state_attr('sensor.weatherxm_sensor', 'precipitation_accumulated') | float / 25.4)|round(2) }}"
device_class: precipitation
unit_of_measurement: "in"
## 7days precipitation mm (testing)
- platform: statistics
name: "weatherxm 7days precipitation mm"
entity_id: sensor.weatherxm_daily_precipitation_mm
state_characteristic: total
max_age:
days: 7
sampling_size: 168
precision: 0
## 7days precipitation inch (testing)
- platform: template
sensors:
weatherxm_7days_precipitation_inch:
friendly_name: 'weatherxm 7days precipitation inch'
value_template: >
{{ (((states('sensor.weatherxm_7days_precipitation_mm')) | float) / 25.4) | round(2) }}
unit_of_measurement: "in"
My Problem is, that both yaml don´t fit together. The mqtt way of configuration doesn´t fit to other sensors. I tried different ways f.e. the mqtt without sensor:. Separately everything works fine, but together no way.
what do i miss?
Thanks!