Snips Led Control

led
leds
respeaker
hack
respeaker-2

#41

Yes create a script for snips in which you can set several commands.

Then call the right as in example:


#42

Snips Led Control : Mute hotword button


#43

I have added the script to turn leds off at night with Jeedom

Snips Led Control: Turn LEDs off at night!


#44

#46

you should not be using this for checking when something is not recognised…

should be using hermes/dialogueManager/intentNotRecognized

can also use the hermes/dialogueManager/sessionEnded looking at the termination reason for “intentNotRecognized”


#47

hello can you tell me how you did for matrixvoice because on my side the installation is good and intents recognized but the led do not light, I tested with respeaker4 there works


#48

I only use cutsom led pattern with google and alexa i got some problem. And my custom pattern look like this :

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from models.LedPattern import LedPattern
import time
import threading

class CustomLedPattern(LedPattern):

	def __init__(self, controller):
		super(CustomLedPattern, self).__init__(controller)


	def breathLeds(self, duration=1.0, color=None, leds=None):
		"""
		Smooth light up and down, all or specified leds
		duration in seconds
		color as array [r,g,b]
		leds as array of index
		github.com/KiboOst
		"""
		if leds is None:
			leds = []
		if color is None:
			color = [0, 0, 40]

		if len(leds) == 0:
			leds = [i for i in range(self._numLeds)]

		pause = float(duration / 200.00)
		direction = 1
		brightness = 0

		frame = 0
		while frame < duration and self._animation.isSet():
			for l in leds:
				self._controller.setLed(l, color[0], color[1], color[2], brightness)

			self._controller.show()

			time.sleep(pause)

			if brightness <= 0:
				direction = 1
			elif brightness >= self._controller.defaultBrightness:
				direction = -1

			brightness += direction
			frame += pause


	def tailTranslate(self, duration=0.5, color=None, invert=False):
		"""
		Progressive translation of all leds.
		duration in seconds
		color as array [r,g,b]
		invert as boolean
		for a ping-pong effect call it twice, second call with invert True
		github.com/KiboOst
		"""
		if color is None:
			color = [0, 0, 40]

		pause = float(duration / (self._numLeds * 2))
		step = int(100 / self._numLeds + 1)

		for i in range(self._numLeds):
			self._controller.setLed(i, color[0], color[1], color[2], 0)
			self._controller.show()

		refs = [0 for i in range(self._numLeds)]
		refs[0] = 100

		for i in range(self._numLeds):
			if not self._animation.isSet(): break
			for j in range(i, 0, -1):
				if refs[j] >= step:
					refs[j - 1] = refs[j] - step
				else:
					refs[j - 1] = 0

			if invert: refs = list(reversed(refs))

			for l in range(self._numLeds):
				self._controller.setLed(l, color[0], color[1], color[2], refs[l])
			self._controller.show()

			if invert: refs = list(reversed(refs))

			if self._animation.isSet(): time.sleep(pause)
			refs.pop()
			refs.insert(0, 0)

		for i in range(self._numLeds):
			if not self._animation.isSet(): break
			if invert: refs = list(reversed(refs))
			for l in range(self._numLeds):
				self._controller.setLed(l, color[0], color[1], color[2], refs[l])
			self._controller.show()
			if invert: refs = list(reversed(refs))
			refs.pop()
			refs.insert(0, 0)
			if self._animation.isSet(): time.sleep(pause)


	def translate(self, duration=0.5, color=None, leds=None, invert=False):
		"""
		Translation of all or specified leds
		duration in seconds
		color as array [r,g,b]
		leds as array of index
		github.com/KiboOst
		"""
		if leds is None:
			leds = []
		if color is None:
			color = [0, 0, 40]

		if len(leds) == 0:
			leds = [int(self._numLeds / 2)]

		pause = float(duration / (self._numLeds + 1))
		refs = [0 for i in range(self._numLeds)]

		for i in range(self._numLeds):
			if i in leds:
				refs[i] = 100

		for i in range(self._numLeds + 1):
			if not self._animation.isSet(): break
			if invert: refs = list(reversed(refs))
			for l in range(self._numLeds):
				self._controller.setLed(l, color[0], color[1], color[2], refs[l])
				self._controller.show()
			if invert: refs = list(reversed(refs))
			if self._animation.isSet(): time.sleep(pause)
			refs.pop()
			refs.insert(0, 0)


	def wakeup(self, *args):
		self.off()
		self._animation.set()
		self.tailTranslate(0.3, [100, 0, 0])
		self.tailTranslate(0.3, [100, 0, 0], True)


	def listen(self, *args):
		self.off()
		self._animation.set()
		while self._animation.isSet():
			self.tailTranslate(0.5, [0,0,100])
			self.tailTranslate(0.5, [0,0,100], True)


	def think(self, *args):
		self.off()
		self._animation.set()
		while self._animation.isSet():
			self.tailTranslate(0.3, [100,60,5])
			self.tailTranslate(0.3, [100,60,5], True)


	def speak(self, *args):
		self.off()
		self._animation.set()
		#break for tts without siteid
		i = 0
		while self._animation.isSet():
			self.tailTranslate(0.5, [0,100,0])
			self.tailTranslate(0.5, [0,100,0], True)
			i += 1
			if i > 7:
				self.idle()
				break


	def idle(self, *args):
		self.off()
		self._animation.set()
		while self._animation.isSet():
			self.breathLeds(5, [0, 0, 75])


	########## DO NEVER CALL CustomLedPattern functions past this line ###########
	def onError(self, *args):
		for i in range(self._numLeds):
			self._controller.setLed(i, 120, 0, 0, self._controller.defaultBrightness)
		self._controller.show()
		time.sleep(0.5)


	def onSuccess(self, *args):
		for i in range(self._numLeds):
			self._controller.setLed(i, 0, 120, 0, self._controller.defaultBrightness)
		self._controller.show()
		time.sleep(0.5)


	def onButton1(self, *args):
		self._controller.toggleState()


	def onStart(self, *args):
		self._controller.wakeup()
		self._controller.idle()

May be you can try this


#49

ok i use custom and you’re configuration but i have same problem leds are off
i haven’t error

sudo python main.py --hardware=matrixvoice --pattern=custom --leds=6
Starting Snips Led Control
Initializing SnipsLedControl
Loading configurations
Loaded 8 hardware references

  • Mqtt server set to localhost
  • Mqtt port set to 1883
  • Client id set to default
  • Hardware set to Matrix Voice
  • Using custom as pattern with 6 leds
    Initializing leds controller
    Connected to data publisher with port 20024

#50

I got this with your command :

sudo python main.py --hardware=matrixvoice --pattern=custom --leds=6
Starting Snips Led Control
Initializing SnipsLedControl
Loading configurations
Loaded 8 hardware references
- Mqtt server set to localhost
- Mqtt port set to 1883
- Client id set to default
- Hardware set to Matrix Voice
- Using custom as pattern with 6 leds
Initializing leds controller
Connected to data publisher with port 20024
Counted 18 leds on device
INFO:SnipsLedControl:Counted 18 leds on device
LED count obtained. Disconnecting from data publisher 20024
INFO:SnipsLedControl:LED count obtained. Disconnecting from data publisher 20024
Snips Led Control started
INFO:SnipsLedControl:Snips Led Control started 

And 6 leds are light on

When you install snipsledcontrol, does all packages have been installed? no error ?


#51

on first install i have many lines of errors in red on putty, you know how to uninstall Snipsledcontrol completely


#52

Your matrix voice doesn’t have only 6 leds… This will fail because matrix voice sends the led count and it must be correct. Latest dev version has a hardcoded check

@Tarlak This is an old version, this pattern is now having its own file called “kiboost”


#53

With your update script i keep it and didn’t see that kiboost one was the same :yum:


#54

Ha, ok :slight_smile: :slight_smile:


#55

@nicoxygen Many errors doesn’t really help, if we don’t see what errors…


#56

yes that’s why I ask you how to completely remove snipsledcontrol in order to reinstall it and send you error messages


#57

There’s no removal instructions. The installation installs a few dependencies, that’s all it does

But, speaking of that I think I know what happens :slight_smile:

Can you please do this:

sudo systemctl stop snipsLedControl
sudo chmod +x /snipsLedControl_v1.5/installers/matrixvoice.sh
cd snipsLedControl_v1.5
sudo ./install.sh v1.5

And follow the instructions


#58

Do i have to use paho?

pi@snips-wohnzimmmer:~/snipsLedControl $ sudo python main.py --hardware=respeaker4 --pattern=google --defaultBrightness=25
Traceback (most recent call last):
  File "main.py", line 9, in <module>
    from models.SnipsLedControl         import SnipsLedControl
  File "/home/pi/snipsLedControl/models/SnipsLedControl.py", line 8, in <module>
    import paho.mqtt.client as mqtt
ImportError: No module named paho.mqtt.client

#59

yes you need it, or you can change the script to use something else. But the installer does install it by itself normally


#60

hello, ok i have full reinstall with option: matrixvoice and custom:

error:

Collecting paho-mqtt
Exception:
Traceback (most recent call last):
File “/usr/lib/python2.7/dist-packages/pip/basecommand.py”, line 215, in main
status = self.run(options, args)
File “/usr/lib/python2.7/dist-packages/pip/commands/install.py”, line 353, in run
wb.build(autobuilding=True)
File “/usr/lib/python2.7/dist-packages/pip/wheel.py”, line 749, in build
self.requirement_set.prepare_files(self.finder)
File “/usr/lib/python2.7/dist-packages/pip/req/req_set.py”, line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File “/usr/lib/python2.7/dist-packages/pip/req/req_set.py”, line 554, in _prepare_file
require_hashes
File “/usr/lib/python2.7/dist-packages/pip/req/req_install.py”, line 278, in populate_link
self.link = finder.find_requirement(self, upgrade)
File “/usr/lib/python2.7/dist-packages/pip/index.py”, line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File “/usr/lib/python2.7/dist-packages/pip/index.py”, line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File “/usr/lib/python2.7/dist-packages/pip/index.py”, line 568, in _get_pages
page = self._get_page(location)
File “/usr/lib/python2.7/dist-packages/pip/index.py”, line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File “/usr/lib/python2.7/dist-packages/pip/index.py”, line 792, in get_page
“Cache-Control”: “max-age=600”,
File “/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py”, line 501, in get
return self.request(‘GET’, url, **kwargs)
File “/usr/lib/python2.7/dist-packages/pip/download.py”, line 386, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File “/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py”, line 488, in request
resp = self.send(prep, **send_kwargs)
File “/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py”, line 609, in send
r = adapter.send(request, **kwargs)
File “/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/adapter.py”, line 47, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File “/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/adapters.py”, line 423, in send
timeout=timeout
File “/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py”, line 643, in urlopen
_stacktrace=sys.exc_info()[2])
File “/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/util/retry.py”, line 315, in increment
total -= 1
TypeError: unsupported operand type(s) for -=: ‘Retry’ and ‘int’


#61

Well, this is a python/pip error unfortunately