Using feed data in textbox

This may be a stupid question, but I am trying to read a value from my feeds to insert into a textbox on my dashboard.
The available feedvalue widget makes the text blurry and very restrictive editing is possible.

I have tried:

<iframe src= </iframe> But with this I can only get the value in “” and cannot edit the text format.

Also looking at reading out of the JSON but have no idea how…

Help appreciated!

This isn’t something I’ve done but…

HTML text formatting is what you need to look for. Can you have a look and post back?

@TrystanLea will have an idea I’m sure.

Thanks, I have been using HTML text formatting for titles etc. The problem is reading values from a feed and then being able to edit them.

I need to somehow extract the value, I was trying something like:

p style="font-size:36px; font-weight:bold; font-family:arial; color: white; text-align:right;"> 
x =;

I’m not sure.
Maybe use an online editor and firefox ‘inspect’ to help debug? Online HTML Editor - 𝗛𝗧𝗠𝗟-𝗢𝗻𝗹𝗶𝗻𝗲.𝗰𝗼𝗺
I’m also interested in the result as I’m building a dashboard today. I’ll have a look.

When you post any code, could you please put 3 back ticks ` before and after the code, so that it displays correctly.
I’ve just edited your post above, and added them.


Code goes here



@danbates or @TrystanLea I would be grateful if you can give me some direction, I haven’t been able to do this yet.

Patience. We’re both very busy.

I’ve fixed this now to return the number without quotes.

You can edit the feedvalue widget font, font style, font weight, size, colour, what else do you need?
Reading JSON requires javascript, what are you looking to do?

Where is that fix implemented Trystan?

I raised an issue on emoncms (#977) about some formatting of a api reply, while looking into that I learned about the php json.encode() defaults and suggested those defaults get over-ruled and the “emoncms defaults” get set in a wrapper function for encoding JSON.

The numerical values being returned as strings has come up before as you know (#273 and #540), I’m guessing that maybe using proper float JSON settings that might also handle nulls, infs and nans without manually handling the stings as has been the case in the past, but that is just a guess :slight_smile:

As it happens I was using feedvalue widgets the other day and found it frustrating that I could not set both a pre-fix and post-fix (unit) eg

Temp1 <val> °C

I had to chose between putting the single “unit” field before or after the value. That selection (before or after) uses a field itself. IMO it would be better to have a leading text and trailing text, still only 2 fields but vastly more flexible.

I currently have to use

<val> °C (Temp1)

which I really don’t like. I could have a seperate second text box, but I find myself dragging these around alot and having to try and keep the textbox and feedvalue grouped and aligned is a pain.

Annnnd… (since you ask)

It would be real nice if the widget settings could be carried forward when creating a batch of new feedvalues. I recently set up 40 feed values on one page all the same, but the font, weight and size all had to be changed individually, it would be nice if I could have set up one and then the next “new feed value” had the settings applied from the last. it only needs to last the edit session, I think it would get a bit messy for users to be able to save their own widget settings. Could this be possible by changing the scope of the widget variables?

Fixed on to match behaviour of emoncms core API. (Im working through a whole lot of backend stuff to bring the code bases back together).

A before and after field makes sense, could you open an issue on the dashboard module with that suggestion and for carrying the settings forward?

1 Like

The other problem with the widget is that the resolution is a bit fuzzy and you can’t align text right or left. I also was after the above pre and post text fields so that solves part of the problem. Alignment options would be great though

Yes, that was something else I found frustrating too. I was (on this occasion) trying to show a floor plan with temperatures all around the edges and wanted to put those temps inside the rooms but as close to the walls as possible without clashing. The top and bottom walls are fine, but ideally I would have liked the left hand wall temps left aligned and the right hand wall temps right aligned so that any movement in the decimal scaling would not alter the distance between the feed value and it’s corresponding wall.

I’ll raise some issues for feature requests.

Here is a partial screenshot (browser scaling at +500%) which seems to show your right about the fuzzy resolution. In that shot the feedvalue is using Arial,Bold,16px, Black with an “after” unit of “°C t05” and auto decimals.

I’m also pretty sure when I added that feedvalue it was fully inside the grey block, it was showing around 17°C at the time so I’m surprised it is now overflowing the box area. So the positioning logic is pretty “fuzzy” too.

I have just created issues for

leading and trailing “units” #165

alignment options #166

fuzzy text #167

and carrying forward settings #168

did I get everything?

That should cover it

I use this in my Dashboard to read a feedvalue:

      url: "http://myserversipaddress/emoncms/feed/get.json?apikey=xxxxxxxxxxxxxxxxxxx&id=59&field=value",
      type: 'GET',
      success: function(res) {
          if (Math.abs(dt.getMinutes() - parseInt(res,10)) > 2 && parseInt(res,10) != 59) {
             $('#43').css('color', 'red');
          } else {
             $('#43').css('color', 'black');
      error: function(res,e) {
          $('#43').css('color', 'red');

What this snippet is doing is to retrieve the minute value of the time I’m logging and comparing it to the local minute. If it’s out by more than 2 minutes then I turn my time display red to show that something’s not updating.

The whole code in an invisible textbox is:

$("#43").css({"font-size":"120px","color":"black"}); // Time

function dispTime(){
  var dt = new Date();
  var time = getPaddedComp(dt.getHours()) + ":" + getPaddedComp(dt.getMinutes())
      url: "http://myserversipaddress/emoncms/feed/get.json?apikey=xxxxxxxxxxxxx&id=59&field=value",
      type: 'GET',
      success: function(res) {
          if (Math.abs(dt.getMinutes() - parseInt(res,10)) > 2 && parseInt(res,10) != 59) {
             $('#43').css('color', 'red');
          } else {
             $('#43').css('color', 'black');
      error: function(res,e) {
          $('#43').css('color', 'red');

getPaddedComp = function(comp) {
   return ((parseInt(comp) < 10) ? ('0' + comp) : comp);

So this just displays the local time on my dashboard, updated every 5 seconds, normally black but turn red if my feeds aren’t updating for some reason.

You can pretty much run any jQuery this way.


I’ve changed the feedvalue widget to use standard html text rather than canvas for rendering (available for testing in latest master branch of the dashboard module), this fixes the fuzzy text issue.


Also added in feedvalue left, center, right align option.

For the prepend/append units option I realise removing the option field for units and unit positioning and replacing with two new options “prepend” and “append” will affect existing dashboards. Any preferences on how to proceed?

1 Like

If there are going to be big changes to many a dashboard we could look at doing dashboards v2 perhaps, to somehow manage versions to allow .org users time to adjust.
For the emoncms local, could just go for it I think. If people press the update button and stuff is different it’s ultimately their responsibility, and it really is too valuable a minor update to not do. I say go for it :slight_smile:

What are the options?