snarky-snark / home-assistant-variables

A custom Home Assistant component for declaring and setting generic variable entities dynamically.
Apache License 2.0
278 stars 16 forks source link

hashmap support ? #111

Closed gkathan closed 6 months ago

gkathan commented 6 months ago

hi, probably I am too stupid ;-) but what I need is to set a variable in configuration.yaml which acts like a hashmap - a collection / array of key - value pairs:

Logger: homeassistant.config Source: config.py:1335 First occurred: 02:55:32 (1 occurrences) Last logged: 02:55:32

Invalid config for 'var' at configuration.yaml, line 117: expected a dictionary for dictionary value 'var->tvbox_channels', got [{'name': 'orf1', 'id': 11}, {'name': 'orf2', 'id': 12}, {'name': 'orf3', 'id': 22}, {'name': '3sat', 'id': 48}, {'name': 'arte', 'id': 47}, {'name': 'atv', 'id': 13}, {'name': 'pro7', 'id': 17}, {'name': 'comedycentral', 'id': 44}, {'name': 'automotorsport', 'id': 110}, {'name': 'zdfinfo', 'id': 57}], please check the docs at https://github.com/snarky-snark/home-assistant-variables/blob/master/README.md

any advice? thänx in advance

Screenshot_20240329-073634.png

estegewr commented 6 months ago

As far as I understand the module, a hash mode is not supported yet. Each variable can provide a value and optionally a few attributes. Then this is configured like

var:
  tvbox_channel_1:
    friendly_name: "TV Channel 1"
    initial_value: "orf1"
    attributes:
      id: 11
  tvbox_channel_2:
    friendly_name: "TV Channel 2"
    initial_value: "orf2"
    attributes:
      id: 12
estegewr commented 6 months ago

Or this is what you are looking for: https://github.com/snarky-snark/home-assistant-variables/issues/48#issuecomment-782387905