Hello Andy,
thanks for that work, i like your template very much! I hope you dont mind taking your template and adapt it to a responsive-friendly widget by me.
Wetter-Widget.widget.json (2.6 KB)
Hello Andy,
thanks for that work, i like your template very much! I hope you dont mind taking your template and adapt it to a responsive-friendly widget by me.
Wetter-Widget.widget.json (2.6 KB)
Hi Andrew, it would be great if you could share this as I was thinking of creating something similar but have never got around to it.
Hi All,
What do I need to add to the ā.replaceā coding below in order to fix the fact I have two spaces in a condition type ( btw Iāve changed the original icon āscattered showersā to be āchance-of-rainā)
Returned Condition Type:
Chance of Rain
Code Snippet:
<tr> <td rowspan="2"><img id="weather-icon" src="{{ServerPath}}/images/{{IconSet}}/{{itemValue(config.Condition0).replace(' ','-') | lowercase }}.png"/></td> </tr>
Thanks
Hi @Nathan_Wilcox,
Iām not sure I really understand your problem, but assuming you get something like āChance[space][space]of[space]rainā then by far the easiest way would be to rename the associated icon file to have a double hyphen where the double space occurs i.e. chanceāof-rain.png.
I guess you could try the line of code:
<img id="weather-icon" src="{{ServerPath}}/images/{{IconSet}}/{{itemValue('Condition_ID1').replace(' ',' ').replace(' ','-') | lowercase }}.png"/>
where the first .replace changes two spaces to one, but I have no idea if this will work and no quick way to test this for you. If you do try the line of code and it works, let the community know as it may help others.
Sorry if this is not the problem that you are trying to solve, if you need to can you provide the source you are getting and the output you need as this may make it a bit clearer to me.
Andy
Hi Andy,
The problem I am having is that my Forecast condition of tomorrow is telling me āChance of Rainā When the .replace is kicking in it is changing the condition to show the following:
And when opening the image in a new tab:
HTTP ERROR: 404
Problem accessing /static/images/colorful/chance-of%20rain.png. Reason:
Not Found3
Therefore it is not finding an icon called
chance-of%20rain.png
If this now makes sense?
Thanks
Hey
Iām new to openHab and Linux as a Whole.
Iāve managed to write the HTML files to the custom Widget Code Section,But my Putting the directory on the server, Iām not sure how that Goes
Iām using Ubuntu: 16.04
And the Server is hosted on the same PC
Could you please help me on how to Upload the Pics on the Serverā¦
Thanks
Hi @Nathan_Wilcox,
OK, I can see the problem now. I think there are two potential causes:
of
and rain
, as you suggested. In this case try:<img id="weather-icon" src="{{ServerPath}}/images/{{IconSet}}/{{itemValue('Condition_ID1').replace(' ',' ').replace(' ','-') | lowercase }}.png"/>
%20
. So we need a way to replace the %20
in the source.<img id="weather-icon" src="{{ServerPath}}/images/{{IconSet}}/{{itemValue('Condition_ID1').replace('%20','-').replace(' ','-') | lowercase }}.png"/>
I canāt be certain which is the problem as most browsers with remove double spaces when displaying text and they are hard to spot with a standard (non-fixed width font).
Let me know how you get on. Andy
Hi @Nduzi,
Check the documentation at: http://docs.openhab.org/installation/linux.html#file-locations.
The icons go in the Site configuration
folder, html
subdirectory. So for a repository installation that would be /etc/openhab2/html/
.
If you have implemented the SAMBA shares as http://docs.openhab.org/installation/linux.html#network-sharing this is shared as \\your IP address\openHAB-conf
. Again the subdirectory html
is the place for the downloaded files. All my scripts and instructions are based upon deployment from a windows PC with a mapped drive in place, so if you have access to that technology it may be the easiest way to get going.
Hope this helps. Andy
Hi,
my settings
items
Number Precip_Probability āPrecip probability [%d %%]ā {weather=ālocationId=lublinFIO, type=precipitation, property=probabilityā}
HABpanel
{{itemValue(āPrecip_Probabilityā)}} %
I have Yahoo and ForecastIO, and see only 0 where in sites yahoo and forecast this values is different
others valueas like temp, wind is works.
Hi Nathan,
I had a similar problem and found that .replace will only replace the first instance in a string, so in your string the first space is being changed to - but the second space is not.
I found some resources that referred to using regex to replace all instances in a string but in the end I found it was easier to change the image reference to look at ācommonidā and rename my images based on this
Hi @Nic_P / @Nathan_Wilcox,
Nicās comments have made me look at this in more detail (for about two hours )ā¦ looks like I am beaten.
Nic is correct that the replace command only replaces the first instance of the space. In my defence Iāve used loads of programming languages on Windows and none of them work in this way ā¦ ok I made a bad assumptionā¦
Looks like you should be able to use a regular expression instead .replace(/\s/g, '')
but that does not seem to be supported within the HTML. Probably the various slashes screws things upā¦
So went looking for other mechanisms, looks like a custom filter would do(lowercase is an example of a built-in filter). Iāve had a go at this, but it looks like I would need a script in the <HEAD>
section of the HTML to make this work. Our custom templates are in the <BODY>
section of the HTML and so I canāt work out how to do it this eitherā¦
Perhaps @ysc may be able to suggest the right way to replace multiple spaces. Iām sure that there is a knack to make this happen, but right now my Google Foo is not getting me thereā¦
For now Nic is right, switching to the Condition_ID0
method and renaming the icon files as I discussed in this post Template Example: Weather Binding is the only workaround I can offer.
Grrrrā¦ I hate being beaten by computers!
Andy
The right way would be a filter in a separate Javascript file, loaded with oc-lazy-load
(check other threads for examples) as you suggest @AndyMB.
Now for a dirtier wayā¦ well, here you go: 'chance of rain'.split(' ').join('-')
Thanks @ysc,
I knew you would have the (two!) answer! Iāve tested the ādirtyā way with the line:
<img id="weather-icon" src="{{ServerPath}}/images/{{IconSet}}/{{itemValue('Condition1').split(' ').join('-') | lowercase }}.png"/>
tested with a manually forced status and this works perfectly to solve @Nathan_Wilcox Nahanās bug.
Iāve taken a quick delve into the ārightā way to, but Iām going to need a bit more time to get my head around that. But I do think this will offer some better ways to deal with some of the workarounds that have been added over time that have bloated the HTML.
I can only apologise that I did not keep up-to speed with this addition functionality, delving into custom widgets has been on my to-do list for too long!
Thanks for your help solving this one.
Andy
Than you all for your assistance on this. I have now implemented the new ādirtyā line and will await the result, shouldnāt be long as thereās always āChance of Rainā where I live
So I thought I had implemented the change but now Iām thinking Iāve done something incorrect as I still Have the problem:
Code:
<td>
<img src="{{ServerPath}}/images/{{IconSet}}/{{itemValue(config.Condition2).split(' ').join('-') | lowercase }}.png"/>
<p>{{itemValue(config.Condition2)}}</p>
</td>
Can you help please?
Hi @Nathan_Wilcox,
Can you repeat your trick of opening the broken image URL in a new tab and posting the URL. Without some idea of what you are getting as the URL now itās difficult to guess what is going on here.
From my testing I know that chance of rain
is successfully mapped to `chance-of-rainā. So I can only conclude that there is some weird character being used to generate the second space / supplied by the weather API. At a guess, it could be a double space being turned into a double hyphen or the inconsistent use of %20 in the condition being returned by the weather binding.
Can you also double check and confirm:
.split(' ').join('-')
method.chance-of-rain
in the correct icon folder (looks like you are using flat_colorful).Iām sure you have done the above, but worth double checking the obvious.
You may also like to use the ability to manually set the status of an item in the console. The command for the condition would be:
smarthome:update Condition0 "Chance of Rain"
I would manually set this for each of the conditions 0,1 and 2 using a SINGLE space between each word. If this all works it provides some more evidence that there is something strange in the condition data being provided by the binding (or more accurately the provider of the data).
If you see inconsistent display with all conditions manually set that would point to one of the image URLs not being right in the HTML.
Sorry but step-by-step, systematic diagnosis looks like the only way that we will get to the bottom of this one.
Regards, Andy
PS: you could always āgive upā on the 'named icon approach and change to the conditionID / number format for the icons. IMHO this is much more easier to maintain over time and allows you the option to switch providers without too much hassle should you ever need.
Hi,
I just gave this widget a try as it looks really good and exactly what I wanted. I have the same problem as some other people seem to be having, but havenāt had a chance yet to read through all the comments.
Basically, the conditions donāt match the icon names so no icons display. Does this only work with certain providers? If so, it might be an idea to update your first post with that. I just tried with OpenWeatherMap & ForecastIo.
Thanks
Hi Jay,
no its working with all providers. i actually had the same problem in the beginning.
the easiest way i thing is to copy/rename the existing icons to match the once you need.
regards
Matt
Thanks
Just what the doctor ordered
Can I Please ask: Where do I place the Icons in Ubuntu(Local Host) and how do I specify the directly in the HTML directory?
Thanksā¦