(Last Updated: July 3, 2020)

Running Lua. Doing something wrong



  • Just chasing down a couple of oddities. This is (again) around the SRT321 which I have to currently control around an http call. No biggy there but in Reactor I have this:

    os.execute (curl 'http://127.0.0.1:3480/data_request?id=action&output_format=json&DeviceNum=20300&serviceId=urn:upnp-org:serviceId:TemperatureSetpoint1_Heat&action=SetCurrentSetpoint&NewCurrentSetpoint=18')
    

    Works perfectly except:

    2020-07-02 23:01:10.612   luup_log:11: Reactor: "Zen" (23) aborting scene "grpsh8y6su.true" Lua execution at group step 4, Lua run failed: "[string \"rs23_scgrpsh8y6su.true_gr1_ac4\"]:1: attempt to call global 'curl' (a nil value)"
    

    Simple enough to work around and move it to the end, but any idea on a fix?

    Cheers

    C



  • You’re missing quotes “ between the ()



  • DOH so

    os.execute ("curl 'http://127.0.0.1:3480/data_request?id=action&output_format=json&DeviceNum=20300&serviceId=urn:upnp-org:serviceId:TemperatureSetpoint1_Heat&action=SetCurrentSetpoint&NewCurrentSetpoint=18'")
    

    ?

    C



  • Why would you not use

    luup.inet.wget "..."
    

    Instead of

    os.execute "curl ..."
    

    ...?



  • Because I'm not very good? 😉

    I was going to ask in fact.

    So

    luup.inet.wget "http://127.0.0.1:3480/data_request?id=action&output_format=json&DeviceNum=20300&serviceId=urn:upnp-org:serviceId:TemperatureSetpoint1_Heat&action=SetCurrentSetpoint&NewCurrentSetpoint=18"
    

    C



  • Something like that... except, that now I take a closer look, I see that you’re HTTP-ing to the same machine... so why not just:

    luup.call_action(...)
    


  • @akbooer said in Running Lua. Doing something wrong:

    Something like that... except, that now I take a closer look, I see that you’re HTTP-ing to the same machine... so why not just:

    luup.call_action(...)
    

    Have I mentioned I was never a developer? 😄

    I was snagging all these from what HA Bridge was generating as perfectly valid, if not elegant, ways to solve a problem. I need to look deeper into luup clearly 🙂

    C


Log in to reply