Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Sources Order -- Independent Temperature and Humidity Entities #161

Closed
4 tasks done
karlobathan opened this issue Jul 3, 2024 · 0 comments
Closed
4 tasks done
Labels
bug Something isn't working.

Comments

@karlobathan
Copy link

System Health details

System Information

version core-2024.6.4
installation_type Home Assistant Supervised
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.2
os_name Linux
os_version 6.6.21-current-sunxi64
arch aarch64
timezone Asia/Manila
config_dir /config
Home Assistant Community Store
GitHub API ok
GitHub Content ok
GitHub Web ok
GitHub API Calls Remaining 4496
Installed Version 1.34.0
Stage running
Available Repositories 1386
Downloaded Repositories 32
Home Assistant Cloud
logged_in false
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Home Assistant Supervisor
host_os Debian GNU/Linux 12 (bookworm)
update_channel stable
supervisor_version supervisor-2024.06.2
agent_version 1.5.1
docker_version 25.0.4
disk_total 28.9 GB
disk_used 6.6 GB
healthy true
supported true
host_connectivity true
supervisor_connectivity true
ntp_synchronized false
virtualization
supervisor_api ok
version_api ok
installed_addons Terminal & SSH (9.9.0), File editor (5.8.0), Home Assistant Google Drive Backup (0.112.1), Cloudflared (5.1.10), Studio Code Server (5.15.0), Log Viewer (0.17.0)
Dashboards
dashboards 2
resources 26
views 1
mode storage
Recorder
oldest_recorder_run July 2, 2024 at 12:18 PM
current_recorder_run July 3, 2024 at 1:26 PM
estimated_db_size 28.80 MiB
database_engine sqlite
database_version 3.44.2

Checklist

  • I have enabled debug logging for my installation.
  • I have filled out the issue template to the best of my ability.
  • This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
  • This issue is not a duplicate issue of any previous issues..

Describe the issue

Related to #117

I tried to add a new sensor using the independent temperature and humidity approach. I simply based my configuration off of what's in the README

image

Here's how I configured mine:

- platform: apparent_temperature
  name: "Karlo's Room Feels Like Temperature"
  unique_id: "sensor.karlo_room_feels_like_temperature"
  source:
    - sensor.temperature_sensor_temperature
    - sensor.temperature_sensor_humidity

The example in the README implies that the order of the sensors should be:

  1. Temperature
  2. Humidity

However, like #117, my sensor shows unknown.

image

After debugging the script, I found out that the temperature and humidity sources are getting swapped.

  • The temperature source gets assigned to the humidity variable
  • The humidity source gets assigned to the temperature variable

What fixed it for me is to swap the order of the sources to this:

  1. Humidity
  2. Temperature
- platform: apparent_temperature
  name: "Karlo's Room Feels Like Temperature"
  unique_id: "sensor.karlo_room_feels_like_temperature"
  source:
    - sensor.temperature_sensor_humidity
    - sensor.temperature_sensor_temperature

image

Reproduction steps

  1. Create a new sensor with independent temperature and humidity. Make sure that the sources are in this order:
  • Temperature
  • Humidity
- platform: apparent_temperature
  name: "Test Feels Like Temperature"
  unique_id: "sensor.test_feels_like_temperature"
  source:
    - sensor.temperature_sensor_temperature
    - sensor.temperature_sensor_humidity
  1. Check newly created sensor
    Expected: Sensor should return feels like temperature
    image
    Actual: Sensor shows unknown value
    image

Debug logs

2024-07-03 13:23:48.038 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.karlo_s_room_feels_like_temperature fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 941, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1289, in async_device_update
    await self.async_update()
  File "/config/custom_components/apparent_temperature/sensor.py", line 305, in async_update
    self._temp_val = temp = self._get_temperature(self._temp)  # °C
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/apparent_temperature/sensor.py", line 242, in _get_temperature
    temperature = TemperatureConverter.convert(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/unit_conversion.py", line 78, in convert
    return cls.converter_factory(from_unit, to_unit)(value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/unit_conversion.py", line 446, in converter_factory
    return cls._converter_factory(from_unit, to_unit)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/unit_conversion.py", line 501, in _converter_factory
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: % is not a recognized temperature unit.

Diagnostics dump

No response

@karlobathan karlobathan added the bug Something isn't working. label Jul 3, 2024
@karlobathan karlobathan changed the title Incorrect Parameter Order -- Independent Temperature and Humidity Entities Incorrect Sources Order -- Independent Temperature and Humidity Entities Jul 3, 2024
@Limych Limych closed this as completed in 6e409a2 Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working.
Projects
None yet
Development

No branches or pull requests

1 participant