diff --git a/README.md b/README.md index de48d45e..32ce8c68 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ time_format: 24 date_pattern: ccc, d.MM.yy hide_today_section: false hide_forecast_section: false -hide_humidity: false +show_humidty: false hide_clock: false hide_date: false hourly_forecast: false @@ -126,7 +126,7 @@ time_zone: null | title | string | **Optional** | Title of the card | `''` | | sun_entity | boolean | **Optional** | ID of the sun entity. Used to determine whether to show a day or night icon. If sun integration is not enabled, day icon will be shown | `sun.sun` | | temperature_sensor | string | **Optional** | ID of the temperature sensor entity. Used to show the current temperature based on a sensor value instead of the weather forecast | `''` | -| humidity_sensor | string | **Optional** | ID of the humidity sensor entity. Used to show the current humidity based on a sensor value | `''` | +| humidity_sensor | string | **Optional** | ID of the humidity sensor entity. Used to show the current humidity based on a sensor value, if `show_humidity` is set to `true` | `''` | | weather_icon_type | `line` \| `fill` | **Optional** | Appearance of the large weather icon | `line` | | animated_icon | boolean | **Optional** | Whether the large weather icon should be animated | `true` | | forecast_rows | number | **Optional** | The amount of weather forecast rows to show. Depending on `hourly_forecast` each row either corresponds to a day or an hour | `5` | @@ -134,7 +134,7 @@ time_zone: null | time_format | `24` \| `12` | **Optional** | Format used to display the time. If not provided, falls back to the default time format of the configured `locale`. This option is ignored if `time_pattern` is set. | `24` | | time_pattern | string | **Optional** | Pattern to use for time formatting. See [luxon](https://moment.github.io/luxon/#/formatting?id=table-of-tokens) for valid tokens. If not provided, falls back to time_format option. | `null` | | date_pattern | string | **Optional** | Pattern to use for date formatting. If not provided, falls back to a localized default date formatting. See [luxon](https://moment.github.io/luxon/#/formatting?id=table-of-tokens) for valid tokens | `D` | -| show_humidity | boolean | **Optional** | Shows the humidity in the today section | `false` | +| show_humidity | boolean | **Optional** | Shows the humidity in the today section | `false` | | hide_today_section | boolean | **Optional** | Hides the cards today section (upper section), containing the large weather icon, clock and current date | `false` | | hide_forecast_section | boolean | **Optional** | Hides the cards forecast section (lower section),containing the weather forecast | `false` | | hide_clock | boolean | **Optional** | Hides the clock from the today section and prominently displays the current temperature instead | `false` | diff --git a/src/clock-weather-card.ts b/src/clock-weather-card.ts index 810a6b2b..12dbf95d 100644 --- a/src/clock-weather-card.ts +++ b/src/clock-weather-card.ts @@ -446,9 +446,9 @@ export class ClockWeatherCard extends LitElement { private getCurrentTemperature (): number | null { if (this.config.temperature_sensor) { - const temperatueSensor = this.hass.states[this.config.temperature_sensor] as TemperatureSensor | undefined - const temp = temperatueSensor?.state ? parseFloat(temperatueSensor.state) : undefined - const unit = temperatueSensor?.attributes.unit_of_measurement ?? this.getConfiguredTemperatureUnit() + const temperatureSensor = this.hass.states[this.config.temperature_sensor] as TemperatureSensor | undefined + const temp = temperatureSensor?.state ? parseFloat(temperatureSensor.state) : undefined + const unit = temperatureSensor?.attributes.unit_of_measurement ?? this.getConfiguredTemperatureUnit() if (temp !== undefined && !isNaN(temp)) { return this.toConfiguredTempWithoutUnit(unit, temp) } @@ -460,11 +460,9 @@ export class ClockWeatherCard extends LitElement { private getCurrentHumidity (): number | null { if (this.config.humidity_sensor) { - const humiditeeSensor = this.hass.states[this.config.humidity_sensor] as HumiditySensor | undefined - const humid = humiditeeSensor?.state ? parseFloat(humiditeeSensor.state) : undefined - // Removed the unit handling as it's not needed for humidity + const humiditySensor = this.hass.states[this.config.humidity_sensor] as HumiditySensor | undefined + const humid = humiditySensor?.state ? parseFloat(humiditySensor.state) : undefined if (humid !== undefined && !isNaN(humid)) { - // Directly return the humidity value without converting based on unit return humid } } diff --git a/src/types.ts b/src/types.ts index 23ca5d62..73c68b73 100644 --- a/src/types.ts +++ b/src/types.ts @@ -47,7 +47,7 @@ export interface MergedClockWeatherCardConfig extends LovelaceCardConfig { date_pattern: string hide_today_section: boolean hide_forecast_section: boolean - show_humidity?: boolean + show_humidity: boolean hourly_forecast: boolean hide_clock: boolean hide_date: boolean @@ -89,7 +89,6 @@ export interface MergedWeatherForecast { datetime: DateTime condition: string temperature: number - humidity?: number precipitation: number precipitation_probability: number templow: number