Hi,
is there an easy way of handling given code fragments from people, who do share their code into your own i.e. lovelace file?
Running Hassio 108.9 I wanted to open a new manual card and include i.e. following code
The problem is, that in ‘MANUAL CARD’ it seems, that the leading spaces and indentations are complete different. So for longer fragments and as a beginner it ends up in try and error…
My 2nd attempt was, to open the YAML Raw Configurator after creating an empty manual card.
I wanted afterwards to copy paste the code from Notepad++.
In Notepad++ I can use Column mode to add/delete spaces over the complete code fragment.
I thought , that is a good way. But after copying to RAW Configurator the YAML parser launches errors - looks like it is not that easy.
Is there a way I am missing?
Easier to go?
YAML seems - so far - not to be my friend
Maybe we are getting closer in Corona times
That’s not true they are the same. If you took that code snip above and pasted it into a manual card, it should work as is.
The things that stand out about that snip above is that it uses 3 custom cards and 2 built in cards. You’ll get errors if you haven’t added the custom card resources.
Hi,
I have tried exactly that.
I pasted following code and at line 45 I get message
end of the stream or a document separator is expected at line 45, column 13: - type: markdown ^
----- That is exactly the line ‘maarkdown’ below comment #white color —
This whole section prior to the markdown card belongs inside an entities card. You’re missing that whole bit. So the yaml parser complains when it gets to the markdown line which has a different indentation level.
You can’t just paste things without understanding the spacing. Your first example would work exactly. This second bit that you posted is so far from wrong that you can’t really fix it without heavy modifications.
So, seems like you don’t understand yaml. I had a conversation with a guy that didn’t understand it either about a month ago and I tried to explain it to him a few different ways.
Hi petro, thanks for your patience.
I used to do some programming in the past - not many - and it’s some years ago, but from that experience, my idea is, that if I have a part of a code i.e. inside an upper level structure and I cut this code part off, I can use it separately as well. (as far as all variables are defined etc)
At least the structure should be ok, if I cut the leading 16 spaces.
The original code is linked in my 1st post at the bottom.
It includes the indent - type: custom:text-divider-row
The 1st code I posted has already been modified by me, because I experienced that manual card works, if the indent is deleted. I already used another code part, where I changed every line adding spaces etc.
For me, it seems that a code copy/paste and changing some variables/entities is not easy possible here. If coders invest already a lot of time - and imho YAML is quite time consuming - to create a lovelace card with all details of markdown etc. I thought it is easy and achievable for HA starters to copy / paste the code and use it.
Yep, yaml can be a pain. But it’s really only bad because you’re using the frontend. If you move to full yaml mode, you’ll be able to use it as you intend to use it. When you use the frontend, it ‘hides’ stuff that contextually is meaningless to the current card that you’re working on. If you take a look at the posts i linked above, you’ll see what I mean.
Yea I liked having the front end as an option to get started so I can use the GUI to try out cards and see how the YAML looks. And I still leave it as front-end editable so I can do that once in a while, mainly to try something out when responding here. But I basically just use the raw configuration option.
A neat trick for copying and pasting if you happen to use sublime text editor is when you do CMD+Shift+V to paste it automatically fixes the indenting for you. So often I copy my raw config over to sublime, paste what I’m adding in there to let it fix the indenting then copy it back. I’m sure other text editors do this as well.
OK, I gave up on markdown for now.
Took the first part and deleted until type: custom-card is in 1st column.
With all mirror strokes deleted.
For this part only:
And then it worked and finally at 109.0 HA version (don’t know if that would have happen earlier as well) there is an additional card configuration menu!