ironsheep / lovelace-rpi-monitor-card

A Raspberry Pi status display Card for Home Assistant Lovelace
MIT License
195 stars 9 forks source link

The values appears and disappears #37

Closed PacmanForever closed 1 year ago

PacmanForever commented 1 year ago

Checklist:

Release with the issue: v1.2.8

Last working release (if known): v1.2.5

Browser and Operating System: All & Ubuntu

Description of problem: The values appears during 1 second and disappears later.

Javascript errors shown in the web inspector (if applicable):

Additional information:

imagen

  - type: custom:rpi-monitor-card
    entity: sensor.rpi_monitor
    card_style: glance
    temp_scale: C
    show_title: false
    show_os_age: false
    show_update_age: false
    name: States
    fs_severity:
      - color: Green
        from: 0
        to: 70
      - color: Orange
        from: 71
        to: 80
      - color: Red
        from: 81
        to: 100
    temp_severity:
      - color: Green
        from: 0
        to: 50
      - color: Orange
        from: 51
        to: 70
      - color: Red
        from: 71
        to: 200
davlaw commented 1 year ago

Ditto here, after values disappear it says "waiting for report". And 1.2.5 works as expected. Screenshot from 2023-02-07 12-42-54

BebeMischa commented 1 year ago

Also affected, when I go to the page with my RPi monitors, i clearly see values for a fraction of a second, before I can read anything, they disappear. Happened after today's update.

afbeelding

ironsheep commented 1 year ago

Hmmm.... thank you all for reporting this so quickly.

I'm working to find the issue now... More soon...

kylepyke commented 1 year ago

Thanks @ironsheep! I'm having the same issue.

PacmanForever commented 1 year ago

Update: In my case, the HA app (android) show the values right. Only fail using the browser.

kylepyke commented 1 year ago

Yup, seems to show on ios as well, but not in the browser. Confirmed not working on Firefox for MacOS here.

BebeMischa commented 1 year ago

In that case, just extra info:

Android HA app works fine here, Firefox latest release on Win 10 does not. Several PC's tested.

davlaw commented 1 year ago

Looks like data is back but it has versioning info at the top that must confuse it. Usable!

Screenshot from 2023-02-08 08-38-52

BebeMischa commented 1 year ago

1.2.9.1

Results on two machines. Better, but some error shows up:

afbeelding

afbeelding

PacmanForever commented 1 year ago

same here....

imagen

davlaw commented 1 year ago

If the version info is for the RPi Reporter MQTT2HA Daemon, I have updated it frrom 1.6.1 to 1.6.2, still reports 1.6.1.

Just fyi, not trying or wanting hijack this thread..

BebeMischa commented 1 year ago

That was understandable. that {unexpected value} thing is more of a concern ;-)

edit: that error is gone after updating the daemon to the latest ;-), but yes, it still shows one version back.

So, actually, this bug report looks solved, but we did find another buggie :-)

edit hours later: That {unexpected value) thing appears and disappears at it's own will again and again. So it is not definitelly gone. ctrl+F5 (reload) does not help, then it does show up.

ironsheep commented 1 year ago

@davlaw good catch! It's a draft so all of the mechanism is not in. I'll finish the in-place update today. With the current version, you should see the daemon update need to go away when you refresh/reload the page. The next release will have this update itself as soon as the RPi reports that it was updated.

Does the update text read ok? would there be a better possibly more terse way to show this? (Just looking for opinions... ;-)

ironsheep commented 1 year ago

@BebeMischa you are so right! The {unexpected value} thing is not good. It's showing that a library call I'm making to custom-card-helpers is not working on your installation. And this is not unique to only yours.

Can I ask two things? first, (somewhat less important ;-) I'm a fan of your theme... which one are you using?

And now the real ask: When this message is reported I'm logging what it saw to the console log. Are you familiar with developer tools? I use chrome and its developer tools extension. You may be using a different browser/toolset but the concept should be the same. Here's a pic of what you should see when looking at the console log:

Screen Shot 2023-02-08 at 15 17 09

You'll notice that I have a page with the RPi cards displayed and I have Developer Tools running with the [Console] tab selected. (top right if pic.)

Can you screenshot what the log messages you are seeing are?
it should be logging one of these: HCUTE (DBG) ( hostname ) card_timestamp_value=[...] for each card with that message showing. I'm interested to see what it says since this is not happening on my installation.

Thanks in advance for your taking the time to do this.

ironsheep commented 1 year ago

@davlaw well, my testing shows I shot myself in the foot and what you are seeing is correct with respect to the state after updating your RPi daemon. Mine shows the same. Here's why:

AUGH!!!!! when I released 1.6.2 on 17 Aug 2022, I neglected to bump the internal version number so it is still reporting v1.6.1.

I'm working on an update now to the daemon so I will clear this up in the next build. Who knew that turning this on would be quality-checking my own work... ;-)

davlaw commented 1 year ago

@ironsheep Been there done that ;)

BebeMischa commented 1 year ago

ver. 1.3.0:

afbeelding

afbeelding

Unfortunately, where I'm now, I can't play with console, I can do that in the weekend maybe.

And for the theme: https://github.com/orickcorreia/caule-themes-pack-1

PacmanForever commented 1 year ago

Which is the current theme that you have selected? In my case, it don't change the color icons (updated, up-time, etc).

BebeMischa commented 1 year ago

Black purple glass

BebeMischa commented 1 year ago

HCUTE (DBG) (raspberrypi) card_timestamp_value=[NaN-NaN-NaN] rpi-monitor-card.js:204:3827 HCUTE (DBG) (localhost) card_timestamp_value=[NaN-NaN-NaN] 2 rpi-monitor-card.js:204:3827 HCUTE (DBG) (raspberrypi) card_timestamp_value=[NaN-NaN-NaN] rpi-monitor-card.js:204:3827 HCUTE (DBG) (localhost) card_timestamp_value=[NaN-NaN-NaN] 2 rpi-monitor-card.js:204:3827 HCUTE (DBG) (raspberrypi) card_timestamp_value=[NaN-NaN-NaN] rpi-monitor-card.js:204:3827 HCUTE (DBG) (localhost) card_timestamp_value=[NaN-NaN-NaN] 2 rpi-monitor-card.js:204:3827 HCUTE (DBG) (raspberrypi) card_timestamp_value=[NaN-NaN-NaN]

and so on...

BebeMischa commented 1 year ago

Expiration(){const[t,e]=this._getRelativeTimeSinceUpdate();if(t&&t.length>0){let i=t;t.includes("NaN")&&(console.log(" HCUTE (DBG) ("+this._hostname+") card_timestamp_value=["+t+"]"),i="{bad value}"),this._cardUpdateString!=i&&(this._cardUpdateString=i),this._cardSecondsSinceUpdate!=e&&(this._cardSecondsSinceUpdate=e)}}_logChangeMessage(t){const e="("+this._hostname+"): "+t;this._showDebug&&console.log(e)}_updateSensorAvailability(){let t=!1;if(this.hass&&this._config){const e=this._configEntityId?this.hass.states[this._configEntityId]:void 0;if(this._configEntityId||e){if(this._configEntityId)try{const e="unavailable"!=this.hass.states[this._configEntityId].state;t=this._sensorAvailable!=e,this._sensorAvailable=e}catch(e){this._sensorAvailable=!1,t=!0}}else this._sensorAvailable=!1,t=!0}else this._sensorAvailable=!1,t=!0;t&&this._logChangeMessage("* SENSOR available: "+this._sensorAvailable)}_computeDaemonUpdMessage(t){let e="";return this._showDebug&&(console.log("- RNDR currentDaemonVersion=["+t+"]"),console.log("- RNDR latestDaemonVersions=["+this.latestDaemonVersions+"]")),this.latestDaemonVersions.length>0&&""!=t?t!=this.latestDaemonVersions[0]&&(e=t+" ---\x3e "+this.latestDaemonVersions[0]):e=""!=this.currentDaemonVersion?"{no info avail.}":"v?.?.? {no info avail.}",e}_getRelativeTimeSinceUpdate(){var t;const e=this._configEntityId?this.hass.states[this._configEntityId]:void 0;let i="",o=0,s="";if(this.hass.locale&&e){try{const o=yt(null===(t=this.hass)||void 0===t?void 0:t.localize,e,this.hass.locale),n=void 0===o?"{unknown}":this._formatTimeAgo(o);i=this._sensorAvailable?n:"{unknown}";s=n.split(" ")[0]}catch(t){console.log("GRTSU - exception:"),console.error(t)}o=s.includes("just")||s.includes("unknown")?0:Number(s)}return[i,o]}_formatTimeAgo(t){const e=new Date((t||"").replace(/-/g,"/").replace(/[TZ]/g," ")),i=((new Date).getTime()-e.getTime())/1e3,o=Math.floor(i/86400),s=e.getFullYear(),n=e.getMonth()+1,r=e.getDate();if(isNaN(o)||o<0||o>=31)return s.toString()+"-"+(n<10?"0"+n.toString():n.toString())+"-"+(r<10?"0"+r.toString():r.toString());let a="{unknown}";return 0==o?i<60?a="just now":i<120?a="1 min ago":i<3600?a=Math.floor(i/60)+" mins ago":i<7200?a="1 hr ago":i<86400&&(a=Math.floor(i/3600)+" hrs ago"):1==o?a="Yesterday":o<7?a=o+" days ago":o<31&&(a=Math.ceil(o/7)+" wks ago"),a}_getIconNameForPercent(t){let e="";for(const i in this._circleIconsValueByName){if(t<=this._circleIconsValueByName[i]){e=i;break}}return e}_computeReporterAgeColor(t){let e;return this._colorReportPeriodsAgoDefault.forEach((i=>{t>=i.from&&t<=i.to&&(e=i.color)})),null!=e&&"default"!=e||(e=""),e}_computeTemperatureColor(t){const e=this._config,i=Number(t),o=e.temp_severity?e.temp_severity:this._colorTemperatureDefault;let s;if(isNaN(i)||o.forEach((e=>{if(i>=e.from&&i<=e.to&&(s=e.color,this._showDebug)){const i="_computeTemperatureColor() - value=["+t+"] matched(from="+e.from+", to="+e.to+", color="+s+")";console.log(i)}})),this._showDebug){const e="_computeTemperatureColor() - value=["+t+"] returns(color="+s+")";console.log(e)}return null!=s&&"default"!=s||(s=""),s}_computeFileSystemUsageColor(t){const e=this._config,i=Number(t),o=e.fs_severity?e.fs_severity:this._colorUsedSpaceDefault;let s;if(isNaN(i)||o.forEach((e=>{if(i>=e.from&&i<=e.to&&(s=e.color,this._showDebug)){const i="_computeFileSystemUsageColor() - value=["+t+"] matched(from="+e.from+", to="+e.to+", color="+s+")";console.log(i)}})),this._showDebug){const e="_computeFileSystemUsageColor() - value=["+t+"] returns(color="+s+")";console.log(e)}return null!=s&&"default"!=s||(s=""),s}_computeMemoryUsageColor(t){const e=this._config,i=Number(t),o=e.memory_severity?e.memory_severity:this._colorUsedMemoryDefault;let s;if(isNaN(i)||o.forEach((e=>{if(i>=e.from&&i<=e.to&&(s=e.color,this._showDebug)){const i="_computeMemoryUsageColor() - value=["+t+"] matched(from="+e.from+", to="+e.to+", color="+s+")";console.log(i)}})),this._showDebug){const e="_computeMemoryUsageColor() - value=["+t+"] returns(color="+s+")";console.log(e)}return null!=s&&"default"!=s||(s=""),s}_computeOsReleaseColor(t){const e=this._config,i=e.os_age?e.os_age:this._colorReleaseDefault;let o="default";if(i.forEach((e=>{if(t===e.os&&(o=e.color,this._showDebug)){const i="_computeOsReleaseColor() - value=["+t+"] matched(os="+e.os+", color="+o+")";console.log(i)}})),this._showDebug){const e="_computeOsReleaseColor() - value=["+t+"] returns(color="+o+")";console.log(e)}return null!=o&&"default"!=o||(o=""),o}_computeDaemonUpdateVersionColor(t){let e;if(e=this.latestDaemonVersions.length>0&&""!=t?this.latestDaemonVersions[0]==t?"default":this.latestDaemonVersions.includes(t)?"orange":"red":"orange",this._showDebug){const i="_computeDaemonUpdateVersionColor() - value=["+t+"] returns(color="+e+")";console.log(i)}return null!=e&&"default"!=e||(e=""),e}_filterUptime(t){const e=t.split(" ");let i=t;if(i.includes(":")){for(let t=0;t<e.length;t++){const i=e[t];if(i.includes(":")){const o=i.split(":"),s=o[0]+"h:"+o[1]+"m";e[t]=s}}i=e.join(" ")}return i}_getAttributeValueForKey(t){let e="";try{if(this.hass&&this._config&&this._configEntityId){const i=this._configEntityId?this.hass.states[this._configEntityId]:void 0;i&&null!=i.attributes&&t in i.attributes&&(e=null==i?void 0:i.attributes[t])}}catch(t){console.error(t)}return e}_emptyCardValuesWhileWaitingForSensor(){const t=this.shadowRoot;if(this._sensorAvailable)if(this._showFullCard)for(const e in this._cardFullCssIDs){const i=this._cardFullCssIDs[e];t.getElementById(i).textContent=""}else for(const e in this._cardGlanceCssIDs){const i=this._cardGlanceCssIDs[e],o=this._cardGlanceElements[e];if(t.getElementById(i).textContent="",o==Vt){t.getElementById(this.kClassIdTempScale).textContent=this._getTemperatureScale()}}}_generateFullsizeCardRows(){const t=[];for(const e in this._cardFullElements){const i=this._cardFullElements[e],o=this._getFullCardValueForAttributeKey(i);let s=this._cardFullIconNames[e];if(i==Nt){const t=this._getAttributeValueForKey(i);s=this._getIconNameForPercent(t)}const n=this._cardFullIconCssIDs[e],r=this._cardFullCssIDs[e];let a="attribute-row";"Model"==e?a="first-short":"Interfaces"==e&&(a="last-short"),t.push(F

`
ironsheep commented 1 year ago

Thanks to all of you for helping provide more info. I've replaced the failing mech. with new code.

Please let me know if there are further problems with the card age indication! (other than most card updates stopping after 5 mins. due to our underlying update() exception which I'm still chasing... )

ironsheep commented 1 year ago

Fixes committed and appear in v1.3.2 and later. I'm closing this issue as (#38) (which I'm keeping open) is tracking the ongoing failure to update the card (due to an underlying exception in the update() Lovelace method.)