domoticz.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:domoticz-slack-bot 作者: atharvai 项目源码 文件源码
def create_or_update_user_variable(self, name, value, var_type=2):
        try:
            if int(var_type) == 3:
                if isinstance(value, datetime):
                    var_value = datetime.strftime(value, '%Y-%m-%d')
            elif int(var_type) == 4:
                if isinstance(value, time):
                    var_value = time.strftime(value, '%H:%M')
        finally:
            var_value = str(value)

        params = uservariables['save'].copy()
        params['vname'] = name
        params['vvalue'] = var_value
        params['vtype'] = str(var_type)
        req = requests.get(self.base_url, params)
        status = req.json()
        if status == 'Variable name already exists!':
            params['param'] = uservariables['update']['param']
            req = requests.get(self.base_url, params)
            status = req.json()
        return status
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号