Mysensors Relay Readings Probleme

Begonnen von marko67, 30 Dezember 2015, 13:58:49

Vorheriges Thema - Nächstes Thema

marko67

Hallo guten Tag,

ich habe den RelayActuator Sketch auf meinen Arduino Nano geflasht. Das Gerät wurde in Fhem eingebunden als  MYSENSOR_101. Das Relais lässt sich auch schalten von Fhem aus allerdings sehen die readings anders aus als in den Vorlagen die ich mir hier im Forum angesehen habe.

Als Beispiele hatte ich den Beitrag von    Meister_Petz,   Franz Tenbrock und hexenmeister aus diesem Beitrag :http://forum.fhem.de/index.php/topic,31663.msg293366.html#msg293366

Ein List auf MYSENSOR_101 ergibt u.a. :

Internals:
   CFGFN
   DEF        101
   IODev      gateway
   I_SKETCH_NAME Relay
   I_SKETCH_VERSION 1.0
   NAME       MYSENSOR_101
   NR         1208
   STATE      ???
   TYPE       MYSENSORS_DEVICE
   ack        0
   protocol   1.5.1
   radioId    101
   repeater   1
   Readings:
     2015-12-30 13:25:19   SKETCH_NAME     Relay
     2015-12-30 13:25:19   SKETCH_VERSION  1.0
     2015-12-30 13:25:17   parentId        0
   Readingmappings:
     1:
       17:
         name       power1
       2:
         name       status1

usw sowie am Ende

Attributes:
   IODev      gateway
   mapReading_power1 1 power
   mapReading_status1 1 status
   mode       repeater
   setReading_power1 1
   setReading_status1 on,off
   version    1.5.1

Warum habe ich als map_Reading power und status?? Und warum bekomme ich in den Readings nicht den zustand sprich on/off angezeigt??

Vielen Dank für Eure Hilfe

Marko



JeeLet

#1
Hello

Yes a subject a little old
but to not pollute the forum I continue here, in addition my problem is the same.

I discovered FHEM (after testing Jeedom, Domoticz, HA) and MySensors

My problem and the language, German and English I don't know (France) .... so "Translate" at 100%

My question:
How to reassemble the Relay control on FHEM
(I'm looking for tutorials and other info, but nothing meaningful for me)

Equipment :
   Odroid-C2 - Armbian - FHEM  <---USB---> Gateway-0  Mega2560 <----- RS485----> Arduino en Node-23 ( 2 Switch et 2 Relais )



the sketch of node 23

/*
* https://www.mysensors.org/build/relay
* https://forum.fhem.de/index.php/topic,101967.15.html?PHPSESSID=ikaibtep2miden5s33qtqemj1v
*
*
*                        ******************************
*  NAME : .ino                       
*
*  DESCRIPTION :
*
*  VERSION :
*
*   INFO:
*
*/

      //----------------------- Library Configuration ---------------------

  #define MY_DEBUG              /*Activer le débogage sur le moniteur série*/
 
  #define MY_TRANSPORT_WAIT_READY_MS 3000 /*Tempo d'attente de mis en Com, des millisecondes*/
  #define  MY_SPLASH_SCREEN_DISABLED /*désactive écran de démarrage MySensors (économie 120oct. en flash)*/

  #define MY_RS485                   //-------------Bus RS485------------
  #define MY_RS485_DE_PIN 2
  #define MY_RS485_BAUD_RATE22 9600  /* débit du bus rs485*/
// #define MY_RS485_HWSERIAL Serial1    /*pour Mega2560,Serial 1-2- ou 3 ? */


#define MY_INCLUSION_MODE_FEATURE   /*Enable inclusion mode*/

#define MY_NODE_ID 23           /*Node en ID static*/

#include <MySensors.h>
#include <Bounce2.h>

#define RELAY_ON 1
#define RELAY_OFF 0

#define SSR_A_ID 3   // Id of the sensor child for FHEM
#define SSR_B_ID 4   // Id of the sensor child for FHEM

#define SENSOR_PIN_A 6 // Pin for Sensor on ArdBoard
#define SENSOR_PIN_B 7 // Pin for Sensor on ArdBoard

const int relayPinA = 3; // Pin for Output on ArdBoard
const int relayPinB = 4; // Pin for Output on ArdBoard

int oldValueSensorA = -1;
int oldValueSensorB = -1;

bool stateA = false;
bool stateB = false;

Bounce debouncerA = Bounce();
Bounce debouncerB = Bounce();

MyMessage msgA(SSR_A_ID, V_TRIPPED);
MyMessage msgB(SSR_B_ID, V_TRIPPED);

void setup()  {
  pinMode(SENSOR_PIN_A, INPUT_PULLUP); // Setup the button Activate internal pull-up
  pinMode(SENSOR_PIN_B, INPUT_PULLUP); // Setup the button Activate internal pull-up

  // Activate internal pull-up
  digitalWrite(SENSOR_PIN_A,HIGH);
  digitalWrite(SENSOR_PIN_B,HIGH);


  // Then set relay pins in output mode
  pinMode(relayPinA, OUTPUT);
  pinMode(relayPinB, OUTPUT);

  // After setting up the buttons, setup debouncer
  debouncerA.attach(SENSOR_PIN_A);
  debouncerA.interval(5);
  debouncerB.attach(SENSOR_PIN_B);
  debouncerB.interval(5);

  // Make sure relays are off when starting up
  digitalWrite(relayPinA, RELAY_OFF);
  digitalWrite(relayPinB, RELAY_OFF);
}

void presentation() {
    sendSketchInfo("RelayGW", "1.0");
    present(SSR_A_ID, S_DOOR);
    present(SSR_B_ID, S_DOOR);
}


void loop() {
   debouncerA.update();
  // Get the update value
  int valueSensorA = debouncerA.read();
  if (valueSensorA != oldValueSensorA) {
    //send(msgA.set(stateA ? false : true), true); // Send new state and request ack back
    send(msgA.set(valueSensorA==HIGH ? 1: 0));
  }
  oldValueSensorA = valueSensorA;

  debouncerB.update();
  // Get the update value
  int valueSensorB = debouncerB.read();
  if (valueSensorB != oldValueSensorB) {
    //send(msgA.set(stateA ? false : true), true); // Send new state and request ack back
    send(msgB.set(valueSensorB==HIGH ? 1: 0));
  }
  oldValueSensorB = valueSensorB;
}

void receive(const MyMessage &message) {
  // We only expect one type of message from controller. But we better check anyway.
  if (message.type == V_STATUS) {
     
    switch (message.sensor) {
      case 1:
        stateA = message.getBool();
        digitalWrite(message.sensor + 4, stateA ? RELAY_ON : RELAY_OFF);
        break;
      case 2:
        stateB = message.getBool();
        digitalWrite(message.sensor + 4, stateB ? RELAY_ON : RELAY_OFF);
        break;
    }
   
      // Write some debug info
    Serial.print("Incoming change for sensor:");
    Serial.println(message.sensor);
    Serial.print("from node:");
    Serial.println(message.sender);
    Serial.print(", New status: ");
    Serial.println(message.getBool());
  }
}
//--------------------- fin Pgm --------------------




https://nsm09.casimages.com/img/2020/11/03//20110304411023870817108347.png

Thanks for the spark start


info
https://forum.fhem.de/index.php/topic,101967.15.html?PHPSESSID=ikaibtep2miden5s33qtqemj1v
https://forum.fhem.de/index.php?topic=75362.15


Beta-User

Bienvenue...

Well, opening new threads isn't a crime, so just do it - especially if there's no real link to the "cold case".

Additionally: It's more gentle to ask additional questions if you are the thread starter and not someone else...

Dealing with relay's in FHEM&MySensors is a bit special, I'd recommend to just start off with the standard Relay Sketch from MySensors (just do the necessary adjustments for the RS485 part). This procedure has at least one big advantage: There's an attrTemplate to configure it as a real on/off device supported by SetExtensions (means: e.g. on-for-timer and blink will work). Then we could dig into the next steps.

If you get trouble with that, please open a new thread (in Bastelecke"->"MySensors") and also add a "list" of your FHEM-MySensors-Device (I personally prefer the RAW list format).
There you also find some links to advanced sketches you might find usefull.

Regards, Beta-User
Server: HP-elitedesk@Debian 12, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: ZigBee2mqtt, MiLight@ESP-GW, BT@OpenMQTTGw | ZWave | SIGNALduino | MapleCUN | RHASSPY
svn: u.a Weekday-&RandomTimer, Twilight,  div. attrTemplate-files, MySensors

JeeLet

Guten Abend

Ansicht zum Öffnen
ein neuer Diskussionsthread
in Bastelecke / MySensors.

Ja, das RAW-Listenformat ist einfacher.

Ich danke dir sehr