定制 jalallinux/laravel-thingsboard 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jalallinux/laravel-thingsboard

Composer 安装命令:

composer require jalallinux/laravel-thingsboard

包简介

ThingsBoard laravel client

README 文档

README

Latest Stable Version Latest Version on Packagist Tests Total Downloads

ThingsBoard is an open-source IoT platform for data collection, processing, visualization, and device management. This project is a Laravel Package that provides convenient client SDK for Integrate with Thingsboard APIs.

Installation

You can install the package via composer

composer require jalallinux/laravel-thingsboard

Publish config file

You can publish config file to change default configs

 php artisan vendor:publish --provider JalalLinuX\\Thingsboard\\LaravelThingsboardServiceProvider --tag config

Publish language file

You can publish config file to change default languages

 php artisan vendor:publish --provider JalalLinuX\\Thingsboard\\LaravelThingsboardServiceProvider --tag lang

Preparing for usage

User class must implement JalalLinuX\Thingsboard\Interfaces\ThingsboardUser like this:

class User extends Authenticatable implements JalalLinuX\Thingsboard\Interfaces\ThingsboardUser
{
    public function getThingsboardEmailAttribute(): string
    {
        return $this->attributes['thingsboard_email'];
    }

    public function getThingsboardPasswordAttribute(): string
    {
        return $this->attributes['thingsboard_password'];
    }

    public function getThingsboardAuthorityAttribute(): EnumAuthority
    {
        return EnumAuthority::from($this->attributes['thingsboard_authority']);
    }
    
    ...

Then can use trait JalalLinuX\Thingsboard\Traits\ThingsboardUser like this:

class User extends Authenticatable implements JalalLinuX\Thingsboard\Interfaces\ThingsboardUser
{
    use \JalalLinuX\Thingsboard\Traits\ThingsboardUser
    
    ...
}

Usage with Tntity classes

use JalalLinuX\Thingsboard\Entities\DeviceApi;

/** Without Authentication */
DeviceApi::instance()->setAttribute('deviceToken', 'A1_TEST_TOKEN')->postTelemetry([...])

/** With Authentication */
Device::instance()->withUser($tenantUser)->getDeviceById('ca3b8fc0-dcf6-11ed-a299-0f591673a2d6')
Device::instance()->withUser($tenantUser)->setAttribute('id', 'ca3b8fc0-dcf6-11ed-a299-0f591673a2d6')->getDeviceById()
Device::instance(['id' => 'ca3b8fc0-dcf6-11ed-a299-0f591673a2d6'])->withUser($tenantUser)->getDeviceById()

Usage with Helper function

/** Without Authentication */
thingsboard()->deviceApi()->setAttribute('deviceToken', 'A1_TEST_TOKEN')->postDeviceAttributes([...])

/** With Authentication */
thingsboard()->device()->withUser($tenantUser)->getDeviceById('ca3b8fc0-dcf6-11ed-a299-0f591673a2d6')
thingsboard($tenantUser)->device()->setAttribute('id', 'ca3b8fc0-dcf6-11ed-a299-0f591673a2d6')->getDeviceById()
thingsboard()->device(['id' => 'ca3b8fc0-dcf6-11ed-a299-0f591673a2d6'])->withUser($tenantUser)->getDeviceById()

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 147
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 32
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 32
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-06-05