Fix history graphs with mysql/mariadb (#36769)
parent
dd239661e7
commit
9cc20fc6b8
|
@ -12,11 +12,7 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant.components import recorder
|
||||
from homeassistant.components.http import HomeAssistantView
|
||||
from homeassistant.components.recorder.models import (
|
||||
DB_TIMEZONE,
|
||||
States,
|
||||
process_timestamp,
|
||||
)
|
||||
from homeassistant.components.recorder.models import States, process_timestamp
|
||||
from homeassistant.components.recorder.util import execute, session_scope
|
||||
from homeassistant.const import (
|
||||
ATTR_HIDDEN,
|
||||
|
@ -355,7 +351,9 @@ def _sorted_states_to_json(
|
|||
ent_results.append(
|
||||
{
|
||||
STATE_KEY: db_state.state,
|
||||
LAST_CHANGED_KEY: f"{str(_process_timestamp(db_state.last_changed)).replace(' ','T').split('.')[0]}{DB_TIMEZONE}",
|
||||
LAST_CHANGED_KEY: _process_timestamp(
|
||||
db_state.last_changed
|
||||
).isoformat(),
|
||||
}
|
||||
)
|
||||
prev_state = db_state
|
||||
|
|
|
@ -223,11 +223,8 @@ class TestComponentHistory(unittest.TestCase):
|
|||
# will happen with encoding a native state
|
||||
input_state = states["media_player.test"][1]
|
||||
orig_last_changed = json.dumps(
|
||||
process_timestamp(input_state.last_changed.replace(microsecond=0)),
|
||||
cls=JSONEncoder,
|
||||
process_timestamp(input_state.last_changed), cls=JSONEncoder,
|
||||
).replace('"', "")
|
||||
if orig_last_changed.endswith("+00:00"):
|
||||
orig_last_changed = f"{orig_last_changed[:-6]}{recorder.models.DB_TIMEZONE}"
|
||||
orig_state = input_state.state
|
||||
states["media_player.test"][1] = {
|
||||
"last_changed": orig_last_changed,
|
||||
|
|
Loading…
Reference in New Issue