Skip to content

Convert decimals from SQL results#13059

Merged
balloob merged 1 commit intodevfrom
sql-sensor-decimal
Mar 10, 2018
Merged

Convert decimals from SQL results#13059
balloob merged 1 commit intodevfrom
sql-sensor-decimal

Conversation

@balloob
Copy link
Copy Markdown
Member

@balloob balloob commented Mar 10, 2018

Description:

Some adapters for SQL Alchemy will return data wrapped in Decimal. This should not be added to the state machine as it blows up the JSON conversion.

Related issue (if applicable): fixes #13021, #13050

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@balloob balloob added this to the 0.65.2 milestone Mar 10, 2018
@dgomes dgomes mentioned this pull request Mar 10, 2018
2 tasks
@balloob balloob merged commit 0e00de8 into dev Mar 10, 2018
@balloob balloob deleted the sql-sensor-decimal branch March 10, 2018 18:40
balloob added a commit that referenced this pull request Mar 10, 2018
@balloob balloob mentioned this pull request Mar 10, 2018
@juan11perez
Copy link
Copy Markdown

juan11perez commented Mar 11, 2018

Good day. Updated to 65.2, frontend loading. sql sensor still generating similar log:

2018-03-10 20:46:42 ERROR (MainThread) [homeassistant.components.sensor] sql: Error on device update!
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 188, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 327, in async_device_update
    yield from self.hass.async_add_job(self.update)
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 327, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 243, in result
    raise self._exception
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/sensor/sql.py", line 147, in update
    value = float(decimal)

@home-assistant home-assistant locked and limited conversation to collaborators Jul 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed integration: sql small-pr PRs with less than 30 lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL Sensor adds non JSON serializable types to the state machine

3 participants