I have a node which acts as a dimmer and a door lock. Normally the dimmer is working fine. However after the node sends a new status of the lock to Domoticz the switching part of the dimmer stops to work. You can set the dimmer to everything >0 and <100. But 0 and 100 do nothing. After checking the node's serial console it seems that Domoticz starts sending the switching instructions with subtype 36 (V_LOCK_STATUS) instead of 2 (V_STATUS). This can only be resolved by restarting Domoticz. Then the dimmer works without problems till the next status update of the lock. Is this a known problem?
I am using the latest stable version of Domoticz.
Domoticz using wrong sub type in some cases?
Moderator: leecollings
- gizmocuz
- Posts: 2352
- Joined: Thursday 11 July 2013 18:59
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Top of the world
- Contact:
Re: Domoticz using wrong sub type in some cases?
Could you post your sketch here?
Quality outlives Quantity!
-
- Posts: 9
- Joined: Sunday 17 January 2016 23:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Domoticz using wrong sub type in some cases?
This is the Sketch I am using. It is based on the LED dimmer example:
Code: Select all
#include <MySensor.h>
#include <SPI.h>
#define LED_PIN 3 // Arduino pin attached to MOSFET Gate pin
#define FADE_DELAY 5 // Delay in ms for each percentage fade up/down (10ms = 1s full-range dim)
//Buttons, digital in with pullup
#define DOOR_SENSOR_PIN 4 // Arduino Digital I/O pin number for button
#define DOOR_SENSOR_ID 2 // Id of the sensor child
//Value other than 0 or 1 forces update on boot
int oldValue=3;
MyMessage msg(DOOR_SENSOR_ID,V_LOCK_STATUS);
MySensor gw;
static int currentLevel = 0; // Current dim level...
MyMessage dimmerMsg(0, V_DIMMER);
//MyMessage lightMsg(1, V_LIGHT);
/***
* Dimmable LED initialization method
*/
void setup()
{
gw.begin(incomingMessage,AUTO,true );
delay(100);
gw.sendSketchInfo("1 CH LED Dimmer", "1.0");
// Register the LED Dimmable Light with the gateway
gw.present( 0, S_DIMMER );
// Pull the gateway's current dim level - restore light level upon sendor node power-up
gw.request( 0, V_DIMMER );
// Setup the buttons
pinMode(DOOR_SENSOR_PIN,INPUT);
// Activate internal pull-up
digitalWrite(DOOR_SENSOR_PIN,HIGH);
//Present door contact
gw.present(DOOR_SENSOR_ID, S_DOOR);
}
/***
* Dimmable LED main processing loop
*/
void loop()
{
// Get the update value
int value = digitalRead(DOOR_SENSOR_PIN);
if (value != oldValue) {
gw.send(msg.set(value?"1":"0")); // Send new state and request ack back
}
oldValue = value;
gw.process();
}
void incomingMessage(const MyMessage &message) {
if (message.type == V_LIGHT || message.type == V_DIMMER) {
Serial.print( "Type_OK" );
// Retrieve the power or dim level from the incoming request message
int requestedLevel = atoi( message.data );
// Adjust incoming level if this is a V_LIGHT variable update [0 == off, 1 == on]
requestedLevel *= ( message.type == V_LIGHT ? 100 : 1 );
// Clip incoming level to valid range of 0 to 100
requestedLevel = requestedLevel > 100 ? 100 : requestedLevel;
requestedLevel = requestedLevel < 0 ? 0 : requestedLevel;
Serial.print( "Changing level to " );
Serial.print( requestedLevel );
Serial.print( ", from " );
Serial.println( currentLevel );
fadeToLevel( requestedLevel );
// Inform the gateway of the current DimmableLED's SwitchPower1 and LoadLevelStatus value...
// gw.send(lightMsg.set(currentLevel > 0 ? 1 : 0));
// hek comment: Is this really nessesary?
// gw.send( dimmerMsg.set(currentLevel) );
}
}
/***
* This method provides a graceful fade up/down effect
*/
void fadeToLevel( int toLevel ) {
int delta = ( toLevel - currentLevel ) < 0 ? -1 : 1;
while ( currentLevel != toLevel ) {
currentLevel += delta;
analogWrite( LED_PIN, (int)(currentLevel / 100. * 255) );
delay( FADE_DELAY );
}
}
-
- Posts: 9
- Joined: Sunday 17 January 2016 23:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Domoticz using wrong sub type in some cases?
I think I solved the problem myself. V_LOCK_STATUS is not the right type for a door contact. The correct type is V_TRIPPED. After changing this in the declaration of msg the node behaves normally. Still it seems like a bug to me, that Domoticz used the wrong type for a completely different child. Child 2 was updated using a wrong type and after this the same type is used when sensing a command to child 0 or 1.
I tried to figure this out in the Domoticz code, but it's really hard to get started with it. Is there some documentation or a version with comments in the code available?
I tried to figure this out in the Domoticz code, but it's really hard to get started with it. Is there some documentation or a version with comments in the code available?
- gizmocuz
- Posts: 2352
- Joined: Thursday 11 July 2013 18:59
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Top of the world
- Contact:
Re: Domoticz using wrong sub type in some cases?
Have a look in MySensorsBase.cpp
The comments are the function names like
FindNextNodeID
LoadDevicesFromDatabase
But have a look in 'WriteToHardware'
The comments are the function names like
FindNextNodeID
LoadDevicesFromDatabase
But have a look in 'WriteToHardware'
Quality outlives Quantity!
Who is online
Users browsing this forum: No registered users and 1 guest