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

"can't convert undefined to object" when calling WidgetBase #1852

Open
bbbart opened this issue Sep 8, 2023 · 0 comments
Open

"can't convert undefined to object" when calling WidgetBase #1852

bbbart opened this issue Sep 8, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@bbbart
Copy link

bbbart commented Sep 8, 2023

What happened?

I'm trying to create a new widget. Following the latest documentation (generated March 2023 apparently), I can't get the widget to work as the browser javascript console always complains with "can't convert undefined to object". This also happens when I copy paste the example basewidget from the documentation (baselight).

The error appears to come from the code behind WidgetBase.call(self, widget_id, url, skin, parameters, monitored_entities, callbacks). In my simple widget, both monitored_entities and callbacks are empty lists.

Version

4.4.2

Installation type

Home Assistant add-on

Relevant log output

Uncaught TypeError: can't convert undefined to object
    WidgetBase http://homeassistant.home:5050/javascript/dashboard.js:344
    baseday_color http://homeassistant.home:5050/compiled_javascript/application.js:3127
    <anonymous> http://homeassistant.home:5050/compiled_javascript/default/livingroom_init.js:84
    jQuery 13
        j
        k
        setTimeout handler*Deferred/then/g/<
        i
        fireWith
        fire
        i
        fireWith
        ready
        R
        EventListener.handleEvent*
        <anonymous>
        <anonymous>
dashboard.js:344:12
    WidgetBase http://homeassistant.home:5050/javascript/dashboard.js:344
    baseday_color http://homeassistant.home:5050/compiled_javascript/application.js:3127
    <anonymous> http://homeassistant.home:5050/compiled_javascript/default/livingroom_init.js:84
    jQuery 13
        j
        k
        (Async: setTimeout handler)
    g
        i
        fireWith
        fire
        i
        fireWith
        ready
        R
        (Async: EventListener.handleEvent)
    <anonymous>
        <anonymous>
        <anonymous>

Relevant code in the app or config file that caused the issue

function baseday_color(widget_id, url, skin, parameters) {

    self = this
    self.widget_id = widget_id
    self.parameters = parameters

    var monitored_entities = []
    var callbacks = []
    
    WidgetBase.call(self, widget_id, url, skin, parameters, monitored_entities, callbacks)  

    function updateColor() {
        var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
        var colors = ["violet", "red", "orange", "yellow", "green", "blue", "indigo"];
        var date = new Date();
        var dayName = days[date.getDay()];
        var color = colors[date.getDay()];

        $("#day_color_content").html(dayName);
        $("#day_color_content").css("background-color", color);
    }

    updateColor();
    setInterval(updateColor, 1000 * 60 * 60); // Update every hour
}

Anything else?

No response

@bbbart bbbart added the bug Something isn't working label Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant