Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different dashboards generated between remote and local on different devices with the same strategy file #20860

Closed
4 tasks done
dalton5 opened this issue May 23, 2024 · 2 comments

Comments

@dalton5
Copy link

dalton5 commented May 23, 2024

Checklist

  • I have updated to the latest available Home Assistant version.
  • I have cleared the cache of my browser.
  • I have tried a different browser to see if it is related to my browser.
  • I have tried reproducing the issue in safe mode to rule out problems with unsupported custom resources.

Describe the issue you are experiencing

I created a strategy to generate a dashboard.

I cleared the cache but I have two different dashboards based on local access or remote access.
I log with the same user.

On my desktop and chrome with local access:

image

On the same computer with my remote access online:

image

PS: I removed the cache cleared browser, changed browser, incognito mode ... Nothing changes. It stays stuck on the same dashboard

On my mobile device: I cleared the cache of the app and with local access it works good and remote access it keeps something in cache I can't remove

image

I can't understand why there is the difference. It keeps the first test I did with my strategy.

My strategy works perfectly in local.

I think it"s a bug or I miss a point. I searched for more than 2 days on this without finding anything.

I even changed the name of the strategy to see if it will refresh but nothing changes...

Describe the behavior you expected

I expect to have the latest version of my generated dashboard on all my devices.

Steps to reproduce the issue

  1. Create a strategy
  2. See it in a dashboard
  3. Change the strategy code
  4. Clear the cache
  5. It should work locally but not with remote access url

What version of Home Assistant Core has the issue?

2024.5.4

What was the last working version of Home Assistant Core?

No response

In which browser are you experiencing the issue with?

Version 124.0.6367.209 (Build officiel) (64 bits) and mobile app

Which operating system are you using to run this browser?

Windows 11 - Android

State of relevant entities

No response

Problem-relevant frontend configuration

import TemplateCard from './automation/template.js'; 

class StrategyDemo {

  static async generate(config, hass) {

    var typeEntity = "light"
    var titlePage = "Lumières"
    var path = "lights"

    const [floors, areas, devices, entities] = await Promise.all([
      hass.callWS({ type: "config/floor_registry/list" }),
      hass.callWS({ type: "config/area_registry/list" }),
      hass.callWS({ type: "config/device_registry/list" }),
      hass.callWS({ type: "config/entity_registry/list" }),
    ]);

    const cards = [];

    const floorsByArea =  Map.groupBy(areas, (floor => { return floor.floor_id }) );

    for (let [x,y] of floorsByArea.entries()) {

      var f = floors.find(item => item.floor_id === x);

      cards.push(TemplateCard.getTitle(f.name));

      for(const area of y)
      {
console.log("errrr", area)
        const areaDevices = new Set();
        
        for (const device of devices) {
          if (device.area_id === area.area_id) {
            areaDevices.add(device.id);
          }
        }

          var entitiesForObject = [];
          entitiesForObject.push({
            "type": "divider"
          })
          var hasEntity= false;

          // Find all devices linked to this area
          for (const entity of entities) {

            if (
              entity.area_id
                ? entity.area_id === area.area_id
                : areaDevices.has(entity.device_id)
            ) {
              if(entity.entity_id.startsWith(typeEntity+'.'))
                {

                  hasEntity = true;

              entitiesForObject.push(TemplateCard.getLightCard(entity.entity_id));
            }
            }
          }

              var arEntities = 

              {
                "title": area.name,
                "type": "entities",
                "entities": entitiesForObject,
                "show_header_toggle": true,
                "header": {
                  "type": "picture",
                  "image": "/local/images/"+area.area_id+".jpg",
                  
                }
              }

          if(hasEntity){
            cards.push(arEntities)
          }

    }
  }


    return {
      "cards": [
        {
          type: "vertical-stack",
          cards
        }
      ]
    };
  }
}

customElements.define("ll-strategy-view-my-demo", StrategyDemo);

Javascript errors shown in your browser console/inspector

No response

Additional information

No response

@dalton5 dalton5 changed the title Different dashboards generated with strategy on different devices Different dashboards generated on different devices with the same strategy file May 23, 2024
@dalton5 dalton5 changed the title Different dashboards generated on different devices with the same strategy file Different dashboards generated between remote and local on different devices with the same strategy file May 23, 2024
@dalton5
Copy link
Author

dalton5 commented May 23, 2024

Ok I thin k I could solve it. My domain name is on cloudflare and I had to purge cache in cliudflare and refresh.

It works now. is it the good way to do it?

Thanks,

@karwosts
Copy link
Contributor

I would check forums for advice on managing custom resources and caching. I believe a common solution is to append an extra parameter in the url (like my-strategy.js?v=2) to your resource each time you change it, so that it doesn't retrieve cached page.

But that is off topic for here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants