MySensor on Hass.io - can't get it work
-
You might need to take this to the [Home Assistant Forum]
(https://community.home-assistant.io). Something strange is going on at the OS level. Your kernel is recognizing the USB device, but the OS isn't creating the tty. You can trylsusbjust to see if it's still there, but beyond that I'm out of advice. The error you are getting from Home Assistant has awkward wording, but it means that it can't find the serial device. -
Oh, sorry, im so confused after I moved from domoticz to Hass.io. But I don't need Z-wave. What I have is serial gateway based on arduino mega 2560, with a sketch (example) https://hastebin.com/cinokiraka.cpp which controles all lights in my house. The arduino mega is connected to my RPI3 (with Hass.io) via usb (ttyUSB0). It worked perfectly on Domoticz, all lights was discovered automatically. I've checked the documentation of MySensors implementation on Hass.io web site, and read plenty of forums and still nothing :/
I'm still getting errors. https://pastebin.com/VDaVRKkV@maty
If you read the Z-wave documentation I linked to you will get instructions how to add a specific USB device to Hass.io docker. My guess is this could solve your problem.For some devices the /dev/ttyAMA0 device is not detected by udev and is therefore not mapped by Docker. To explicitly set this device for mapping to Home-Assistant, execute the following command using the ssh add-on:
$ curl -d '{"devices": ["ttyAMA0"]}' http://hassio/homeassistant/optionsReplace
ttyAMA0above with the correct device in your case. -
@maty
If you read the Z-wave documentation I linked to you will get instructions how to add a specific USB device to Hass.io docker. My guess is this could solve your problem.For some devices the /dev/ttyAMA0 device is not detected by udev and is therefore not mapped by Docker. To explicitly set this device for mapping to Home-Assistant, execute the following command using the ssh add-on:
$ curl -d '{"devices": ["ttyAMA0"]}' http://hassio/homeassistant/optionsReplace
ttyAMA0above with the correct device in your case.@martinhjelmare
I did It. resault But I'm still getting errors :/I guess I'm hopeless. It's probably sthg silly as always.
update:
after trying different solutions i typed hardware check command and new serial appeared 'AMA0' but I did nothing physically with RPi (din't attach any devices). I tried to check mysensors config with ttyAMA0 instead of USB0, but I still got the same resault.
ps. of course when I was trying your command ($ curl -d '{"devices": ["ttyAMA0"]}' http://hassio/homeassistant/options), I did it with USB0 parameter, not AMA0. -
Yesterday I accidentally restarted Hass.io with all that errors in config. I was afraid that it'll crush after restart but it actually worked. After restart I turned on switch on the wall, and Switch (light relay) appeared on Hass.io home screen.
There are still the same errors in config, and I have some issues with those light switches. Most annoying issue is that Hass.io doesn't update switch state after change via gui. Switch state changes in Hass.io when i use manual switch on the wall but when I use gui it doesn't
http://ibb.co/f8Rvum -
Yesterday I accidentally restarted Hass.io with all that errors in config. I was afraid that it'll crush after restart but it actually worked. After restart I turned on switch on the wall, and Switch (light relay) appeared on Hass.io home screen.
There are still the same errors in config, and I have some issues with those light switches. Most annoying issue is that Hass.io doesn't update switch state after change via gui. Switch state changes in Hass.io when i use manual switch on the wall but when I use gui it doesn't
http://ibb.co/f8RvumYou should send feedback of state changes to home assistant from your device. This is done from the
receivefunction. The switch in home assistant will switch as soon as the feedback comes in.Also set
optimistictofalsein your mysensors config section. -
You should send feedback of state changes to home assistant from your device. This is done from the
receivefunction. The switch in home assistant will switch as soon as the feedback comes in.Also set
optimistictofalsein your mysensors config section.@martinhjelmare
You mean in my sketch, something like this?void receive(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.type==V_LIGHT) { // Change relay state digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF); // Store state in eeprom saveState(message.sensor, message.getBool()); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool());I had optimistic set false.
BTW: Strange thing, baud rate in my sketch is 38400, but when I set it up in Hass.io, lights won't work, when I changed to 115200 in .yaml (in sketch is still 38400), all works fine, except the states update.
-
@martinhjelmare
You mean in my sketch, something like this?void receive(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.type==V_LIGHT) { // Change relay state digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF); // Store state in eeprom saveState(message.sensor, message.getBool()); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool());I had optimistic set false.
BTW: Strange thing, baud rate in my sketch is 38400, but when I set it up in Hass.io, lights won't work, when I changed to 115200 in .yaml (in sketch is still 38400), all works fine, except the states update.
In your example above you never send the feedback from
receive. Use thesendmethod
from withinreceiveto do that.In what sketch have you set baud rate to 38400? For the light device or for the gateway? It's only the gateway baud rate that is relevant for home assistant config, since it's the gateway that interfaces via the serial connection to home assistant.
-
In your example above you never send the feedback from
receive. Use thesendmethod
from withinreceiveto do that.In what sketch have you set baud rate to 38400? For the light device or for the gateway? It's only the gateway baud rate that is relevant for home assistant config, since it's the gateway that interfaces via the serial connection to home assistant.
Should it be something like this added to my sketch?
send(msg.set(RELAY_1;V_LIGHT) send(msg.set(RELAY_2;V_LIGHT) ...I ment BAUD_RATE defined in this sketch
#if F_CPU == 8000000L #define MY_BAUD_RATE 38400 #endifOnce again, sorry for tons of noob questions. But I didn't write that sketch by myself, and my knowledge about programming is below basic.
-
Something like this:
send(msg.set(state));The arduino mega runs at 16 MHz so that if block won't be entered, and the define of baud rate won't change.
-
Something like this:
send(msg.set(state));The arduino mega runs at 16 MHz so that if block won't be entered, and the define of baud rate won't change.
Hi,
I checked my sketch once again, and confronted it with MySensors documentation, and I actually found the send message command in it. Should I change something to make it work properly with Hass.iovoid loop() { // Send locally attached sensor data here if (debouncer.update()) { // Get the update value. int value = debouncer.read(); // Send in the new value. if(value == LOW){ saveState(1, !loadState(1)); digitalWrite(RELAY_1, loadState(1)?RELAY_ON:RELAY_OFF); send(msg.set(loadState(1))); -
Hi,
I checked my sketch once again, and confronted it with MySensors documentation, and I actually found the send message command in it. Should I change something to make it work properly with Hass.iovoid loop() { // Send locally attached sensor data here if (debouncer.update()) { // Get the update value. int value = debouncer.read(); // Send in the new value. if(value == LOW){ saveState(1, !loadState(1)); digitalWrite(RELAY_1, loadState(1)?RELAY_ON:RELAY_OFF); send(msg.set(loadState(1)));Yes. There are two ways of interacting with the device to make a state change. Either by pressing the button or by sending a message from home assistant to the device. The
sendcommand you showed above will only happen if the button is pressed when theloopis running.When you send a message from home assistant to the device, to change the state, the message will be received in your sketch by the
receivefunction.So you need to add a
sendcommand to thereceivefunction and send the new state back to home assistant after doing thedigitalWritecall and saving the state. -
@tom-carpenter
How did You make it? Is it via serial gateway?@maty Yes serial gateway hooked to the pi
-
@maty Yes serial gateway hooked to the pi
@tom-carpenter How did you configure the serial gateway in configuration.yaml? can you please post that section?
Also what arduino hardware did you use?
Thanks