• T
    temp

    Hello,
    I have a lot of scripts/tools which reports into my MySQL Database but I need to use scripts with curl to update variables. It would be easier if there is an MySQL Variable device. To display MySQL Information directly.

    Thanks

    posted in Feature Requests read more
  • T
    temp

    Hello,
    I like to update a variable in pimatic with phone my
    code is

    $data = array("value" => "133");
    $data_string = json_encode($data);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HTTPHEADER,     array('Content-Type: application/json', 'Content-Length: ' . strlen($data_string)));
    
     curl_setopt($ch, CURLOPT_URL, 'http://(server)/api/variables/variable_string_today');
     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
      curl_setopt($ch, CURLOPT_USERPWD, "user:password"); 
    curl_exec($ch);
    
    if(curl_error($ch))
    {
        echo 'error:' . curl_error($ch);
    }
    

    And the error is

       error:Empty reply from server
    

    What is wrong? @Gleno0h can you help once more?

    It’s solved I can post the code later.

    posted in Rules and Scripts read more
  • T
    temp

    Hello I tried to configure the alarm system plugin.
    I would like to have that the “device_plugin_zway_windowsensor14” triggers a alarm an then the “device_plugin_zway_binaryswitch13” is switched on. How do I do this? I am confused…

    {
      "includes": [
        "device_plugin_zway_windowsensor14",
        "device_plugin_zway_windowsensor15",
         "device_plugin_zway_binaryswitch13"
      ],
      "id": "device_plugin_alarmsystem_alarmsystem",
      "name": "device_plugin_alarmsystem_alarmsystem",
      "class": "AlarmSystem"
    },
    {
      "id": "device_plugin_alarmswitch_alarmswitch1",
      "name": "device_plugin_alarmswitch_alarmswitch1",
      "class": "AlarmSwitch"
    }
    ],
    

    @michbeck100

    posted in Rules and Scripts read more
  • T
    temp

    Hello is it possible that an email with the email plugin is send out?

    posted in Plugins read more
  • T
    temp

    Something for the off topic but is tradfri now compatible to Philips hue?

    posted in Plugins read more
  • T
    temp

    Hello everybody,
    I hang time again on a problem I have written with flask a restapi which works so far now I would like expand with conditional mysql queries. However, the question how I access the Variable “id” in the MYSQL “Select” . Thanks for your help

    #!/usr/bin/python
    
    from flask import Flask
    from flask_restful import Resource, Api
    from flask_restful import reqparse
    from flask.ext.mysql import MySQL
    
    
    
    mysql = MySQL()
    app = Flask(__name__) 
    
    # MySQL configurations
    app.config['MYSQL_DATABASE_USER'] = 'xxx'
    app.config['MYSQL_DATABASE_PASSWORD'] = 'xxxx'
    app.config['MYSQL_DATABASE_DB'] = 'xxxxx'
    app.config['MYSQL_DATABASE_HOST'] = 'localhost'
    
    
    mysql.init_app(app)
    
    api = Api(app)
    
    class test(Resource):
    def post(self):
        try:
            # Parse the arguments
    
            parser = reqparse.RequestParser()
            parser.add_argument('ID', type=str, help='Id of Item')
            args = parser.parse_args()
    
            id = str(args['ID'])
            conn = mysql.connect()
            cursor = conn.cursor()
            cursor.execute("SELECT * FROM `PowerSystem` WHERE ID=$(id)")
            items_list=[];
            for item in data:
                i = {
                    'ID':str(item[0]),
                    'Timestamp':str(item[1]),
                    'batteryVoltage':str(item[2]),
                    'batteryCurrent':str(item[3]),
                    'solarVoltage':str(item[4]),
                    'solarCurrent':str(item[5]),
                    'loadVoltage':str(item[6]),
                    'loadCurrent':str(item[7]),
                    'batteryPower':str(item[8]),
                    'solarPower':str(item[9]),
                    'loadPower':str(item[10]),
                    'batteryCharge':str(item[11])
                }
                items_list.append(i)
    
            return {'StatusCode':'200','Items':items_list}
    
            except Exception as e:
            return {'error': str(e)}
    
    
    api.add_resource(test, '/test')
    
    
     if __name__ == '__main__':
    app.run(debug=TRUE,host='0.0.0.0')
    
    app.run(debug=TRUE,host='0.0.0.0')
    

    how is this line correct

     cursor.execute("SELECT * FROM `PowerSystem` WHERE ID=$(id)")
    

    so that onlz the mysql data with the respective id is send

    actual

     {"error": "(1305, u'FUNCTION xxxxx.$ does not exist')"}
    

    is send back

    but the result should like

    {{
      "Items": [
    {
      "batteryVoltage": "3.612",
      "solarVoltage": "4.725",
      "loadCurrent": "308.4",
      "ID": "112",
      "loadPower": "1.527",
      "loadVoltage": "4.952",
      "batteryCurrent": "283.2",
      "Timestamp": "2017-05-11 13:04:18",
      "solarCurrent": "191.2",
      "solarPower": "0.903",
      "batteryCharge": "24.86",
      "batteryPower": "1.023"
    },
      ],
      "StatusCode": "200"
    }
    

    Thanks :)

    posted in Development read more
  • T
    temp

    Here is a nice holiday npm package

      https://www.npmjs.com/package/date-holidays
    

    Can someone add it to pimatic?

    Same info like
    https://forum.pimatic.org/topic/685/holidays-script

    Would be nice :)

    posted in Plugins read more
  • T
    temp

    @mwittig solved by activating

     https://myaccount.google.com/lesssecureapps

    posted in Rules and Scripts read more

Looks like your connection to pimatic forum was lost, please wait while we try to reconnect.