Code Monkey home page Code Monkey logo

cleware-traffic-light's Introduction

cleware-traffic-light

License PyPI version

cleware-traffic-light an easy to use CLI tool written in Python3 to control the cleware USB traffic light. It supports multiple traffic light control and the usage as a module in your own Python application.

Usage

Module

from traffic_light import ClewareTrafficLight, Color, State

ClewareTrafficLight().red_on()
ClewareTrafficLight().yellow_off()

# with address for specific light
ClewareTrafficLight(21).green_on()

CLI

ctl --red on
ctl -r on
ctl --red on --green off
ctl --red off --green on --address 19

Installation

use pip to install cleware-traffic-light

sudo pip3 install cleware-traffic-light

Linux

To use the CLI as a user you first have to create the USB rule

# go to directory
cd /etc/udev/rules.d/

# create file with the rule
touch 99-clewareampel.rules

Rule content

# V4^ (2023-10)
echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="0d50", ATTR{idProduct}=="0008", MODE="660", GROUP="traffic-light"' > 99-clewareampel.rules

# V3 and lower
echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="0d50", ATTR{idProduct}=="0030", MODE="660", GROUP="traffic-light"' > 99-clewareampel.rules

Help

usage: ctl [-h] [-r {on,off}] [-y {on,off}] [-g {on,off}]
                     [-a ADDRESS]

Turns the led of the cleware traffic light on or off

optional arguments:
  -h, --help            show this help message and exit
  -r {on,off}, --red {on,off}
                        Controlls the red led
  -y {on,off}, --yellow {on,off}
                        Controlls the yellow led
  -g {on,off}, --green {on,off}
                        Controlls the green led
  -a ADDRESS, --address ADDRESS
                        Specifies which traffic light should be used

cleware-traffic-light's People

Contributors

joshuarost avatar mupuf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cleware-traffic-light's Issues

New udev rule for USB-TischAmpel4

Hi,

I'm using a USB-TischAmpel4 from 2023-10. This one seems to have a new product id:

$ sudo lsusb | grep Cleware
Bus 001 Device 002: ID 0d50:0030 Cleware GmbH Multiplexer

I'v change my udev rule accordingly. I think having two rules doesn't harm anything, so I would suggest to update the README.md to:

SUBSYSTEM=="usb", ATTR{idVendor}=="0d50", ATTR{idProduct}=="0008", MODE="660", GROUP="traffic-light"
SUBSYSTEM=="usb", ATTR{idVendor}=="0d50", ATTR{idProduct}=="0030", MODE="660", GROUP="traffic-light"

Thanks for maintaining cleware-traffic-light!

Kind regards Markus

Only works once on rpi4

Hi, while the cli-tool works on windows, my raspberry pi 4 can only execute this once after a reboot. The next times I just get errors, mostly timeout errors. Is there any fix to this?

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.