smarthomeNG / smarthome

Device integration platform for your smart home
https://www.smarthomeNG.de
GNU General Public License v3.0
123 stars 92 forks source link

Multiple items for sv_widget in YAML-configuration throws error #249

Closed realhik closed 6 years ago

realhik commented 6 years ago

Classic configuration of multiple sv_widgets, as

sv_widget = {{ device.rtr('item', 'Heizt mit ', 'item', 'item.soll', 'item.mode', 'item.mode', 'item.mode', '', 'item.state', '0.5') }} | {{ plot.rtr('foyer-history', 'item', 'item.soll', 'item.state') }}

is no longer supported for yaml

sv_widget:
    - "{{ device.rtr('item', 'Heizt mit ', 'item', 'item.soll', 'item.mode', 'item.mode', 'item.mode', '', 'item.state', '0.5') }}"
    - "{{ plot.rtr('foyer-history', 'item', 'item.soll', 'item.state') }}"

It throws error:

2017-12-17  21:21:46 ERROR    Main         Item ug.foyer.h1: problem creating: 'list' object has no attribute 'find'
Traceback (most recent call last):
  File "/usr/local/smarthome-v1.4-rc1/lib/item.py", line 404, in __init__
    child = Item(smarthome, self, child_path, value)
  File "/usr/local/smarthome-v1.4-rc1/lib/item.py", line 465, in __init__
    update = plugin.parse_item(self)
  File "/usr/local/smarthome-v1.4-rc1/plugins/visu_smartvisu/__init__.py", line 91, in parse_item
    item.expand_relativepathes('sv_widget', "'", "'")
  File "/usr/local/smarthome-v1.4-rc1/lib/item.py", line 592, in expand_relativepathes
    self.conf[attr] = self.get_stringwithabsolutepathes(self.conf[attr], begintag, endtag, attr)
  File "/usr/local/smarthome-v1.4-rc1/lib/item.py", line 612, in get_stringwithabsolutepathes
    if evalstr.find(begintag+'.') == -1:
AttributeError: 'list' object has no attribute 'find'
msinn commented 6 years ago

The sv_widget attribute is not designed to accept lists. (It did not accept lists in conf format either).

sv_widget had to be one string:

sv_widget:  "{{ device.rtr('item', 'Heizt mit ', 'item', 'item.soll', 'item.mode', 'item.mode', 'item.mode', '', 'item.state', '0.5') }} {{ plot.rtr('foyer-history', 'item', 'item.soll', 'item.state') }}"

You can insert cr-lf for better readability though:

sv_widget:  "{{ device.rtr('item', 'Heizt mit ', 'item', 'item.soll', 'item.mode', 'item.mode', 'item.mode', '', 'item.state', '0.5') }} 
             {{ plot.rtr('foyer-history', 'item', 'item.soll', 'item.state') }}"
realhik commented 6 years ago

It seems that

sv_widget = {{ device.rtr('item', 'Heizt mit ', 'item', 'item.soll', 'item.mode', 'item.mode', 'item.mode', '', 'item.state', '0.5') }} | {{ plot.rtr('foyer-history', 'item', 'item.soll', 'item.state') }}

was kind of supported as it showed both plots in different containers.

Using one string in YAML as proposed results in a merged (and not separated) view for device.rtr and plot.rtr.

msinn commented 6 years ago

Ok, I see the problem. It has nothing to do with YAML though.

The list isn't handled by the routine to expand relative item pathes. It should already exist in SmartHomeNG v1.3 version of the plugin.

By the way: You are not using the actual plugin. The error

 File "/usr/local/smarthome-v1.4-rc1/plugins/visu_smartvisu/__init__.py", line 91, in parse_item
    item.expand_relativepathes('sv_widget', "'", "'")

Is logged for line 91. In the actual plugin the conflicting statement is in line 106.

The v1.4-rc1 branch was never intended to be used as an installation source, so it didn't reference the actual commit in the plugin repository. So, you are using a lot of old plugin versions.

If you are not using relative item pathes with the sv_widget attributes, you could comment out that line (until the plugin is fixed)

msinn commented 6 years ago

The problem should be fixed with SmartHomeNG v1.4.1. Could you test and give feedback?

realhik commented 6 years ago

Tested for 1.4.1-rc1. Works now as expected. Thx for fixing.