• Resolved Ramadamadam

    (@ramadamadam)


    I am getting the following WP_Error when running the shortcode on my page:

    Fatal error: Cannot use object of type WP_Error as array in /homepages/26/d412001039/htdocs/www.xel4.co.uk/wp-content/plugins/wordhue/includes/lighting-lights.php on line 15

    Am I the only one having having this problem or is there a re bug in the plugin code?

    My bridge is setup correctly and I can “get” the “lights” information if I use the Philips Hue debug tool and enter the “/api/username/lights” url manually in my browser.

    I have tried to work around the problem, but I cant get it to work.

    Thanks for your help.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Michael Visser

    (@visser)

    Hi @ramadamadam, thanks for raising this and your patience (5 months…); I don’t get notifications of new support topics which is weird. ??

    I’ll have a look at that line and see what’s going on, it’s working fine here on my Synology NAS connected to the local network.

    Plugin Author Michael Visser

    (@visser)

    Hi @ramadamadam, I just pushed a minor release with some changes. Can you confirm if this still persists after updating?

    Thread Starter Ramadamadam

    (@ramadamadam)

    Hi @visser, thanks for your update, but I am still having the following issue when loading the page that has your short code on it:

    What do you think is going wrong on line 15?

    Fatal error: Uncaught Error: Cannot use object of type WP_Error as array in /**/**/**/**/www.mysite.co.uk/wp-content/plugins/wordhue/includes/lighting-sensors.php:15 Stack trace: #0 /**/**/**/**/www.mysite.co.uk/wp-content/plugins/wordhue/includes/page.php(15): codex_nas_lighting_sensors_job() #1 /**/**/**/**/www.mysite.co.uk/wp-includes/shortcodes.php(345): codex_nas_lighting_shortcode('', '', 'philips_hue_lig...') #2 [internal function]: do_shortcode_tag(Array) #3 /**/**/**/**/www.mysite.co.uk/wp-includes/shortcodes.php(223): preg_replace_callback('/\\[(\\[?)(philip...', 'do_shortcode_ta...', '[philips_hue_li...') #4 /**/**/**/**/www.mysite.co.uk/wp-includes/class-wp-hook.php(298): do_shortcode('[philips_hue_li...') #5 /**/**/**/**/www.mysite.co.uk/wp-includes/plugin.php(203): WP_Hook->apply_filters('[philips_hue_li...', Array) #6 /**/**/**/**/www.mysite.co.uk/wp-includes/post-template.php(240): apply_f in /**/**/**/**/www.mysite.co.uk/wp-content/plugins/wordhue/includes/lighting-sensors.php on line 15

    What theme are you getting it to work on? I have tested it with my themes as well as Twenty Seventeen and it still has the same error.

    Could it be a PHP version error? What version are you running?

    UPDATE:
    I was using PHP version 7.0 so I have just tested with PHP version 5.6 but I get this error message:

    Fatal error: Cannot use object of type WP_Error as array in /**/**/**/**/www.mysite.co.uk/wp-content/plugins/wordhue/includes/lighting-sensors.php on line 15

    • This reply was modified 7 years, 11 months ago by Ramadamadam. Reason: PHP Testing
    Plugin Author Michael Visser

    (@visser)

    You’re very welcome @ramadamadam, knowing you are on the same codebase as me makes diagnosing this alot quicker. I’ll have a fix shortly.

    Plugin Author Michael Visser

    (@visser)

    Here are the details of my WordPress instance:

    WordPress 4.7.3
    PHP 5.6
    Synology NAS DS213+
    Theme: TwentyFifteen

    I’ll push a minor release now that checks that a array was returned like in the wp_remote_get() example:

    https://codex.www.ads-software.com/Function_Reference/wp_remote_get

    Plugin Author Michael Visser

    (@visser)

    Can you add the following line above line #15 that contains [code]$response = wp_remote_get( $url );[/code]:

    error_log( ‘[wordhue] url: ‘ . $url );

    You’ll need to then open that Lighting screen triggering the PHP error and open the PHP error log or WordPress debug.log if enabled.

    I’m keen to see what URL is produced, please strip out your IP address and validation token and replace it with AAA for the length of the string.

    Also, noob question did you set your IP address and token from the Settings > Philips Hue screen?

    Thread Starter Ramadamadam

    (@ramadamadam)

    Thanks again @visser for looking in to this and updating your code again. Your update has removed the frontend error message, but using your debug suggestion (see results below) and adding:

    echo '<pre>'; print_r( $response ); echo '</pre>';
    error_log( '[wordhue] url: ' . $url );

    on lines 18 and 19 I can now see the following:

    WP_Error Object
    (
        [errors] => Array
            (
                [http_request_failed] => Array
                    (
                        [0] => cURL error 28: Connection timed out after 5000 milliseconds
                    )
            )
    
        [error_data] => Array
            (
            )
    )

    The URL you asked me to check correct displays my bridge data if I put it in the address bar manually.

    This is what the debug.log is getting now:

    [31-Mar-2017 10:08:41 UTC] [wordhue] sensors_job (error):
    wp_remote_get() returned false for the URL: https://IP/api/USERNAME/sensors
    
    [31-Mar-2017 10:08:46 UTC] [wordhue] url: https://IP/api/USERNAME/lights
    
    [31-Mar-2017 10:08:46 UTC] [wordhue] lights_job (error):
    wp_remote_get() returned false for the URL: https://IP/api/USERNAME/lights
    
    [31-Mar-2017 10:08:51 UTC] [wordhue] sensors_job (error):
    wp_remote_get() returned false for the URL: https://IP/api/USERNAME/sensors
    
    [31-Mar-2017 10:08:51 UTC] [wordhue] sensors_job (error):
    wp_remote_get() returned false for the URL: https://IP/api/USERNAME/sensors

    I have tested wp_remote_get() and it works using a normal URL, just not with the URL to connect to my bridge.

    Doing a bit of googling I have found that someone else had an issue with their server not supporting cURL correctly (I don’t understand it). So I have contact my server to see if the issue is at their end. I will let you know what happens once they’ve look into it.

    I hope I can get this sorted as I would love to use your plugin and maybe help develop it further if you were interested? I was looking for something that I could expand on so I could customise my lights myself rather than being stuck to 3rd party apps etc.

    Thanks again for your help.

    Plugin Author Michael Visser

    (@visser)

    Hi @ramadamadam, just clarifying are you hosting the WordPress site yourself on a NAS or network attached device within your home network or just via a WordPress site on the internet?

    If you’re hosting from a standard hosting provider (e.g. GoDaddy, MediaTemple, etc.) then you’ll need to expose the Hue Bridge on your home network to the internet by configuring your home network router to forward that traffic.

    I run WordPress on my NAS (a Synology DS213+) as well as a Raspberry Pi within my home network.

    Thread Starter Ramadamadam

    (@ramadamadam)

    Hi @visser, the site in question is hosted with 1and1.co.uk (standard hosting provider). I am in conversation with them to see if the issue at my end, as it might not be your code at all! I don’t want to stress you looking for an issue that isn’t there. I will let you know what I find as soon as possible.

    When I copy & paste the “$url” (that “wp_remote_get()” uses in your code) directly into the address bar it is getting the data back from my bridge just fine. Does that mean I do or do not still need to “configure my home network router to forward the traffic”?

    If I do still need to configure it, what exactly does that mean and how would I go about doing it?

    Thanks again.

    Plugin Author Michael Visser

    (@visser)

    Hi @ramadamadam, you really need to be running this Plugin within your home network not via a third-party hosting provider. I’m sure you can modify your home router to forward traffic to the Hue bridge but you’ll need to do your own homework on this as it differs with each manufacturer and there are trust issues when exposing home devices to the internet. I’ll update the Plugin description to explain this requirement better for future users ??

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘WordHue Timeout Error’ is closed to new replies.