2021.4: For our advanced users ❤️

Are you running Dwains UI Theme or Lovelace_gen? If so, wait for a fix. This was found in beta and both of these custom solutions need an update to address the issue.

I’m trying to play with the new trace feature, but I keep getting

http://rpi-server.rye/frontend_latest/chunk.e4629a3bb43aafd111cb.js:849:2274 Uncaught TypeError: Cannot read property 'timestamp' of undefined

What am I doing wrong?

Only the user which is in the group “Owner” sees the new analytics options. Check this in your “Users” list

1 Like

Yes Lovelace_gen, ok thanks

OK. I understand that your strategy will avoid the error in the logs (which is a good thing), but I am sure that the response to my resource_template below, should always have data, and I am trying to understand what changed (the RESTful integration?) and whyno dict object is available to my template? I couldn’t find anything documented with the release.

Here is the resource configuration, which worked fine before upgrading::

resource_template: https://api.willyweather.com/v2/myrandomkeynot shown/locations/211344/weather.json?forecasts=tides&days=10&startDate={{ states('sensor.date') }}

lovelace gen already has the fix, here’s the code if you don’t want to wait. Replace the contents of config/custom_components/lovelace_gen/__init__.py with:

import os
import logging
import json
import io
import time
from collections import OrderedDict

import jinja2

from homeassistant.util.yaml import loader
from homeassistant.exceptions import HomeAssistantError

_LOGGER = logging.getLogger(__name__)

def fromjson(value):
    return json.loads(value)

jinja = jinja2.Environment(loader=jinja2.FileSystemLoader("/"))

jinja.filters['fromjson'] = fromjson

llgen_config = {}

def load_yaml(fname, secrets = None, args={}):
    try:
        ll_gen = False
        with open(fname, encoding="utf-8") as f:
            if f.readline().lower().startswith("# lovelace_gen"):
                ll_gen = True

        if ll_gen:
            stream = io.StringIO(jinja.get_template(fname).render({**args, "_global": llgen_config}))
            stream.name = fname
            return loader.yaml.load(stream, Loader=lambda _stream: loader.SafeLineLoader(_stream, secrets)) or OrderedDict()
        else:
            with open(fname, encoding="utf-8") as config_file:
                return loader.yaml.load(config_file, Loader=lambda stream: loader.SafeLineLoader(stream, secrets)) or OrderedDict()
    except loader.yaml.YAMLError as exc:
        _LOGGER.error(str(exc))
        raise HomeAssistantError(exc)
    except UnicodeDecodeError as exc:
        _LOGGER.error("Unable to read file %s: %s", fname, exc)
        raise HomeAssistantError(exc)


def _include_yaml(ldr, node):
    args = {}
    if isinstance(node.value, str):
        fn = node.value
    else:
        fn, args, *_ = ldr.construct_sequence(node)
    fname = os.path.abspath(os.path.join(os.path.dirname(ldr.name), fn))
    try:
        return loader._add_reference(load_yaml(fname, ldr.secrets, args=args), ldr, node)
    except FileNotFoundError as exc:
        _LOGGER.error("Unable to include file %s: %s", fname, exc);
        raise HomeAssistantError(exc)

def _uncache_file(ldr, node):
    path = node.value
    timestamp = str(time.time())
    if '?' in path:
        return f"{path}&{timestamp}"
    return f"{path}?{timestamp}"

loader.load_yaml = load_yaml
loader.SafeLineLoader.add_constructor("!include", _include_yaml)
loader.SafeLineLoader.add_constructor("!file", _uncache_file)

async def async_setup(hass, config):
    llgen_config.update(config.get("lovelace_gen"));
    return True

# Allow redefinition of node anchors
import yaml

def compose_node(self, parent, index):
    if self.check_event(yaml.events.AliasEvent):
        event = self.get_event()
        anchor = event.anchor
        if anchor not in self.anchors:
            raise yaml.composer.ComposerError(None, None, "found undefined alias %r"
                    % anchor, event.start_mark)
        return self.anchors[anchor]
    event = self.peek_event()
    anchor = event.anchor
    self.descend_resolver(parent, index)
    if self.check_event(yaml.events.ScalarEvent):
        node = self.compose_scalar_node(anchor)
    elif self.check_event(yaml.events.SequenceStartEvent):
        node = self.compose_sequence_node(anchor)
    elif self.check_event(yaml.events.MappingStartEvent):
        node = self.compose_mapping_node(anchor)
    self.ascend_resolver()
    return node

yaml.composer.Composer.compose_node = compose_node
4 Likes

Nothing changed, the behavior is the same. Now an error is raised.

Hi

Thanks for that.

So where can I get the current version of HA installed on my machine please ?

I also lost Supervisor version. Is that possible too ?

Thanks

Martyn

Open your Home Assistant instance and show your Supervisor system information.

Automation tracing… I need new pants!
I’ve waiting soooo long for this. superb!!!

1 Like

Sorry, but in my case, it is more than just a warning error. The value_template is actually no longer parsing data from the JSON that is returned. If it was just a matter of ignoring an error, I’d be fine, but I actually do see a change: I no longer have a state for me sensors.

Then fix the error with the code I posted…

What’s the harm in just trying it instead of this long winded conversation?

Sorry. Didn’t mean to try your patience. I’ll give it a shot. Appreciate your help.

1 Like

If it doesn’t work, create a separate post and tag me and I’ll come help. Just post the resource and your current codeblock.

This updated added Home Assistant Supervisor integration and its entities. They are disabled by default. How do I enable them? Never mind. Need to click on the box on the left and then the enable comes up.

Ok, will do. But where can I find the “users list”? Do you mean the “person” file in “.storage” folder? What do I have to add there to become the owner? Something like “owner” : “true”?

Issue submitted:

What is the difference between set_value vs set_config_parameter? Are they interchangeable in zwave_js

The user list is in Home Assistant “Configuration” and then “Users” (just below “Zones”)

probably should just close that

speed_range_min
speed_range_max

change max to whatever value you want, i.e. 3 for 3 speeds that range from 1 to 3. If you want 0 to 3, then do 0 for min 3 for max. But then your calc will be different.