Giter VIP home page Giter VIP logo

cybear-jinni / cbj_smart_device Goto Github PK

View Code? Open in Web Editor NEW
39.0 2.0 21.0 239.58 MB

๐Ÿ’ก CyBear Jinni Smart Device helps you make electronic devices smarter. That includes controlling them through the app and getting their current status. If you have ever wondered "is there an open source project to make my own smart home?", This is part of one.

Home Page: https://cybearjinni.com

License: GNU Affero General Public License v3.0

Dart 100.00%
smartdevices smarthome smart-home smartthings iot iot-device dart snap-store snap hacktoberfest

cbj_smart_device's Introduction

Important Message

If you arrived here, you probably are searching for the cbj hub.

This repo is for creating your own smart device and is Currently not maintained.


CyBear Jinni Smart Device

Snapcraft dart CI style: lint License: AGPL v3

CyBear Jinni image

Welcome!

This repository is in charge of controlling smart devices and is part of the CyBear Jinni Smart Home system.

The software is written in dart and allows you to control lamps and blinds.

You can control these devices using physical buttons and from the CyBear Jinni App.

This part is using the snap store in order to have easy way to update all the devices software versions with new features and security updates.

Get it from the Snap Store

To get the project running

Attention

  • The software support Raspberry Pi only when running without the snap, for now only NanoPi Duo2 is supported as a snap, you can run the software everywhere else (including your pc) without controlling the pins.

  • You need to buy and solder the parts into the device yourself.

Smart device preparations:

Setting up instructions for the new device can be found in the CyBear Jinni Smart Device Resources repository.

It is recommended to lock the IP of the smart device in the router settings if you intend to use the local option and not just the remote (that is using google Firebase platform).

Explanations on how to connect the device with the app will be given in the CyBear Jinni App Readme file.

Disclaimers

Use at Your Own Risk, we do not take responsibility on any outcome using anything in this repo.

The project is under heavy work and may contain bugs and incorrect instructions.

Thanks to all Contributors โญ

Interested in Contributing? We're glad your are! Read our Contribution Guidelines here.

Social Media Links

Twitter Instagram Linkedin Discord Github

cbj_smart_device's People

Contributors

0xln avatar aaliya-ali avatar acenasir avatar bxtgeek avatar danielgil82 avatar felipedotcom avatar guyluz11 avatar krish7777 avatar lix-dev avatar matbiit avatar narayanansampath avatar sakshi025 avatar sofiacarballo avatar tamir198 avatar tazminia avatar uabua avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cbj_smart_device's Issues

Device name is being used as id

Because device name is being used as device I'd the user cannot give it a name with space.
If he does the toggle switch stop working.

Although changing name back is possible and working.

Add Raspberry Pi support

Currently the code can run on Linux machins.

Interacting with the pins only work for NanoPi Duo2 as it is the smallest device that I found (can fit inside light switch box in the wall).

As Raspberry Pi is the biggest common (computer) tool for makers we should add support for it.
This way more peoples could join us.

  • Test that the program can run on the raspbery pi
  • Add support for it to interact with the device pins.

For every step along the way that you need help you can reach me in Discord

Move to different snap name

The snap of cbj_smart_device use the snap name cybear-jinni, it need to move to cbj-smart-device.
cybear-jinni will be used by the app, on all platform the app should have only the company name.

image

gRPC error after long time that the software is running

After few hours that the software is running fine suddenly it crash with the message:

Unhandled exception:
gRPC Error (14, Missing trailers)

The snap is restarted immediately so for DeviceType "smart Light" for example the light turn off and on again quickly and it back to working as normal.

We are using gRPC in two different places in the software.

  1. firedart package to communicate with Firebase.
  2. gRPC server we are starting with the method startLocalServer(), through there the application talk to is the smart device.
  • First we need to find from what use of gRPC the error is coming from.
  • Find how to fix that, we can catch the error or we can handle it so that it will not continue happen.

Making the button object work separately from device object

Currently button object is part of the smart device objects.
We should separate them to make the program more versatile.
For example if the button object will work alone and just call the functions that we give him to execute than we will be able to let the user assign new functionality to the button.
Devices like blinds and thermostat should be taken into account, such objects will have to include button (for security reasons) and the lights of the button will always represent the actual state of the smart device.
Blinds are moving up?, up button lights are on.
Thermostat is on?, thermostat button lights are on.

Comment the failing dart tests

Dart tests are failing and it stop the GitHub dart Action from passing.

Commenting the failing tests are enough for now as the project does not have good working base to the tests.

Add 'schedule a wish' functionality

The WishEnum list right now doesn't have the functionality of setting wish to be executed on specific date/timer function.

Example for use:
Turning the light on every day in 18:00 and turning it off in 5:00 .

Currently the only way to turn the light on and off is to execute the wish by button signal from the app exactly when you want it to happen.

Regression getting error "journal has been rotated"

After number of days the network connections stop working only inside the snap.

Running sudo systemctl status -n 100 snap.smart-home.smart-home return the following:
Warning: journal has been rotated since unit was started, output may be incomplete.

Buttons still working and restarting the snap will reset the problem again to number of days.

Logo in readme need some editing

We have logo of CyBear Jinni in the readme.
CyBear Jinni have the following repository's Smart Device, App, Smart Home so we need some change to distinguish there logo.

For the Smart Device I suggest to put the logo inside a light bulb.

This is a mock that I created, do not use it, it is not good.

Please change the logo to fit the Smart Device project and replace the readme with the new one.

Add log system

Currently the app using the print method but it is not recommended for productions and we get the following warning Avoid "print" calls in production code.

So we need a system or method to log everything into new file on the device memory.

Adding badges to readme

Please make the text "CyBear Jinni Smart Device" center and below it add the image

CyBear Jinni

to the readme and center it.

Below that add the following badges:

Dart CI (passing), effective dart, license (GPL 3.0), Open Source heart.

Github Action Status

style: effective dart

License: GPL-3.0

image

Below the badges the readme text should start

Crash on get UUID on some Linux distro's

sankethbk7777 contact me in discord about a bug while running the code for the first time.
He runs it on Manjaro Linux distro

Board type does not exist
This device is of type: null

Unhandled exception:
RangeError (start): Invalid value: Only valid value is 0: -1
#0      RangeError.checkValidRange (dart:core/errors.dart:358:7)
#1      _StringBase.substring (dart:core-patch/string_patch.dart:400:27)
#2      CommonBashCommandsD.getUuidOfCurrentDevice (package:cbj_smart_device/infrastructure/datasources/system_commands_d/bash_commands_d/common_bash_commands_d.dart:43:21)
<asynchronous suspension>
#3      LocalDbR.getListOfSmartDevices (package:cbj_smart_device/infrastructure/repositories/local_db_r/local_db_r.dart:24:38)
<asynchronous suspension>
#4      LocalDbE.getListOfSmartDevices (package:cbj_smart_device/domain/entities/local_db_e/local_db_e.dart:14:9)
<asynchronous suspension>
#5      SmartDeviceManagerU.smartDeviceMainAsync (package:cbj_smart_device/application/usecases/core_u/smart_device_manager_u.dart:26:9)
<asynchronous suspension>

Windows save hive error

After updating the device with Firebase credentials from the app (see image for the specific action) it crushes with hive error.

Unhandled exception:
FileSystemException: lock failed, path = '/home/Guy/Documents/hive\smartdevices.lock' (OS Error: The process cannot access the file because another process has locked a portion of the file.
, errno = 33)
#0      _RandomAccessFile.lock.<anonymous closure> (dart:io/file_impl.dart:999:9)
#1      _RootZone.runUnary (dart:async/zone.dart:1450:54)
#2      _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#3      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#4      Future._propagateToListeners (dart:async/future_impl.dart:725:32)
#5      Future._completeWithValue (dart:async/future_impl.dart:529:5)
#6      Future._asyncCompleteWithValue.<anonymous closure> (dart:async/future_impl.dart:567:7)
#7      _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#8      _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#9      _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#10     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)

This error is only on Smart Devices running windows

Markdown License badges change in readme

Found out that we put the wrong badge for the license in the readme.
Please update the license badge to the new one.

License: AGPL v3

[![License: AGPL v3](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)

Hive database location needs to move

Currently the Hive database is used in the software to save data for the next time the software will run.

The location that it saves the data is /home/user name that run the software/Documents/Hive.

Because the end product is using snaps we need to use a different path if it detects that we are inside the snap using the SNAP_USER_COMMON environment variables.

This variable exist only when the software is running inside the snap so it should save to there if exist and if not will save to the old place.

Saving to hive can be found in hive_store_d.dart and in hive_d.dart.

This is good practice and I think it will solve one of the bugs that make the software crush after a long time, and it will make the program more secure.

Integrate the permission system

We have permissions system code that need to be connected to the requests to execute 'wishes'.

The permissions system can be found in the file permissions_manager.dart and will bock users that does not have the permissions to preform certain actions or allow to preform them.

Change readme logo url

Current logo in readme have space in the top of the image.

I have created new one without that, pleas update the readme to have the new one and update the height to 400


CyBear Jinni image

Readme dart ci bage is icorrect

Readme dart ci bage is incorrect

It is currently

[dart CI](https://github.com/CyBear-Jinni/CBJ_Smart-Device/workflows/Dart%20CI/badge.svg)](https://github.com/CyBear-Jinni/CBJ_Smart-Device/actions?query=workflow%3A%22Dart+CI%22)

But the repo name has changed from CBJ_Smart-Device to cbj_smart-device

Running smart device on windows fail

The program exits with the following error:

Smart device is activated
Path/argument 1 is not specified
error: RangeError (index): Invalid value: Valid value range is empty: 0
Unhandled exception:
RangeError: Value not in range: -1
#0      _StringBase.substring (dart:core-patch/string_patch.dart:388:7)
#1      CommonBashCommendsD.getDeviceHostName (package:SmartDeviceDart/features/smart_device/infrastructure/datasources/bash_commends_d/common_bash_commends_d.dart:45:21)
<asynchronous suspension>
#2      DevicePinListManager.setPhysicalDeviceTypeByHostName (package:SmartDeviceDart/features/smart_device/infrastructure/datasources/core_d/manage_physical_components/device_pin_manager.dart:39:52)
#3      main (file:///C:/Users/The%20Vegan/Desktop/tets%20for%20guy/CBJ_Smart-Device/SmartDeviceDart/bin/main.dart:18:32)
#4      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#5      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

Process finished with exit code 255

Detecting video playing on device

That's a functionality for the software to detect playing videos and their length.

The software should detect playing videos on VLC and on YouTube on the browser.

This way we can add the functionality to send to the hub some computer State packet, and the Hub start a scene in the room compatible with the computer state like watching a video scene.

If we can detect the video length we can decide if this is just a small video or a full movie, for small videos we will not start a movie scene for example.

Readme update

As part of #144 is done we need to change the readme snapstore links (for now to be empty).

Bash script need small fix for edge case

It seems that the Linux Bash command uname -p does not wok on all the OS's and return unknown and not the architecture of the device CPU.

I found out the using the command uname -m solve it.

So for this page dartSdkDownload.sh please change uname -p to uname -m.

Setting device pins automatically depending on the device

Currently we set the devices pins manually in the file set_devices_e.dart.

This needs to change as each device have its own pin configuration.

We need to add file for each device that will instruct what is the order that the device should give pins.
Giving pins should take into account the type of device that the user want to add, because different device types can use different types of pins.

Make Snap execute commands in the system

Currently we install inside the snap (package manager) the WiringNP (an GPIO access library for NanoPi to control the device pins).
This is blocking us from supporting more devices with different GPIO access library like the one for Raspberry Pi WiringPi.

Edit: the rest of the issue is no longer the plan for the fix, jump to here for the correct plan on how to fix this.

So we want to link the gpio inside the snap into the gpio library outside of it that installed by default on these devices.
This way when running the gpio in the terminal inside our software in the snap it will just call the gpio outside and work because they will be linked.

The gpio is executable that we can use from the terminal.

I have created a "new topic" in the snapcraft.io
https://forum.snapcraft.io/t/running-executable-that-located-out-side-of-the-snap/20492

This is our snapcraft.yaml file.

If you have any questions, or want to reproduce the process to test if you fixed it please contact me in our Discord server

Add smart computer device type

A new smart computer device type is required.

It should be able for now just to suspend the computer.

In the future it will be able to do a lot of stuff like reading process and sending feedback to the Cbj Hub.

Readme file small fixes

Please make the CyBear Jinni image in the readme smaller

Use this lines of code

CyBear Jinni image

[<div align="center"><img alt="CyBear Jinni image" height="300" src="https://user-images.githubusercontent.com/9304740/94843279-24a49900-0425-11eb-83f3-87e8ba40b1dc.png">](https://github.com/CyBear-Jinni/CBJ_Smart-Home)
</div>

And move the badges to be above it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.