Autor Thema: Homematic Wired - Homebrew Devices  (Gelesen 209636 mal)

Offline loetmeister

  • Full Member
  • ***
  • Beiträge: 409
Antw:Homematic Wired - Homebrew Devices
« Antwort #690 am: 04 August 2021, 23:07:16 »
Hi Juri,

in SET muss "peer" stehen. Vermutlich stimmt dann in der XML etwas nicht... so direkt fällt mir aber kein Fehler auf. Eventuell vergleichst du deine XML mit der Vorlagen? (vom Dimmer)
Verhalten sich alle 12 "Key" Kanäle gleich?


Gruß,
Thomas

Offline aperoap

  • Jr. Member
  • **
  • Beiträge: 60
Antw:Homematic Wired - Homebrew Devices
« Antwort #691 am: 04 August 2021, 23:15:45 »
Ich vermute auch dass in xml was nicht stimmt. 13,14,17,20,22,23 haben in der set liste nur config, bei Rest ist die Liste ganz leer.
Gruß
Juri
« Letzte Änderung: 04 August 2021, 23:20:44 von aperoap »

Offline aperoap

  • Jr. Member
  • **
  • Beiträge: 60
Antw:Homematic Wired - Homebrew Devices
« Antwort #692 am: 07 August 2021, 09:54:04 »
Bin seit Tagen dran das peering von den keys hinzukriegen, finde den Fehler noch.

Kann bitte jemand mitschauen?

Aktuelle Fils

ino
//*******************************************************************
//
// hbw_sen_sc_12_dr
//
// DANKSAGUNG:
// Diese Arbeit basiert sich auf HBW-SC-10-Dim-6 und wurde mit Hilfe von Thomas (Mamber FHEM Forum "loetmeister") und
// Tutorial und Hilfe von Thorsten (Mamber FHEM Forum "Thorsten Pferdekaemper") fertiggestellt.
// Hiermit bedanke ich mich bei Thorsten und Thomas für die hervorragende Arbeit mit HomeBrewWired und das Tutorial.
//
// Homematic Wired Hombrew Hardware
// Arduino NANO als Homematic-Device
// 12 digitale Eingänge (Key/Taster & Sensor) & Sensorkontakte
// Diese Arbeit basiert sich auf HBW-SC-10-Dim-6 und wurde mit Hilfe von Thomas (Mamber FHEM Forum "loetmeister") und
// Tutorial und Hilfe von Thorsten (Mamber FHEM Forum "Thorsten Pferdekaemper")
//
// Juri - JARA Armenia


#define HARDWARE_VERSION 0x01
#define FIRMWARE_VERSION 0x003C
#define HMW_DEVICETYPE 0xA6 //device ID (make sure to import hbw_sen_sc_12_dr.xml into FHEM)

#define NUMBER_OF_INPUT_CHAN 12   // input channel - pushbutton, key, other digital in
#define NUMBER_OF_SEN_INPUT_CHAN 12  // equal number of sensor channels, using same ports/IOs as INPUT_CHAN


#define NUM_LINKS_INPUT 20    // address step 6
#define LINKADDRESSSTART_INPUT 0x038   // ends @0x0C7


//#define USE_HARDWARE_SERIAL   // use hardware serial (USART) for final device - this disables debug output
/* Undefine "HBW_DEBUG" in 'HBWired.h' to remove code not needed. "HBW_DEBUG" also works as master switch,
 * as hbwdebug() or hbwdebughex() used in channels will point to empty functions. */


// HB Wired protocol and module
#include <HBWired.h>
#include <HBWLinkKey.h>
#include <HBWKey.h>
#include <HBWSenSC.h>


// Pins

  #define RS485_RXD 4
  #define RS485_TXD 2
  #define RS485_TXEN 3  // Transmit-Enable
  #define BUTTON 8  // Button fuer Factory-Reset etc.

  #define IO1 A3
  #define IO2 10
  #define IO3 11
  #define IO4 A0
  #define IO5 A1
  #define IO6 A2
  #define IO7 A4
  #define IO8 A5
  #define IO9 9  // dummy pin to fill the array elements
  #define IO10 7  // dummy pin to fill the array elements
  #define IO11 6
  #define IO12 5

  #include "FreeRam.h"
  #include <HBWSoftwareSerial.h>
  HBWSoftwareSerial rs485(RS485_RXD, RS485_TXD); // RX, TX


#define LED LED_BUILTIN        // Signal-LED

#define NUMBER_OF_CHAN NUMBER_OF_INPUT_CHAN + NUMBER_OF_SEN_INPUT_CHAN


struct hbw_config {
  uint8_t logging_time;     // 0x01
  uint32_t central_address;  // 0x02 - 0x05
  uint8_t direct_link_deactivate:1;   // 0x06:0
  uint8_t              :7;   // 0x06:1-7

  hbw_config_senSC senCfg[NUMBER_OF_SEN_INPUT_CHAN]; // 0x07 - 0x12 (address step 1)
  hbw_config_key keyCfg[NUMBER_OF_INPUT_CHAN]; // 0x13 - 0x2A (address step 2)

} hbwconfig;


HBWChannel* channels[NUMBER_OF_CHAN];  // total number of channels for the device


class HBDimIODevice : public HBWDevice {
    public:
    HBDimIODevice(uint8_t _devicetype, uint8_t _hardware_version, uint16_t _firmware_version,
               Stream* _rs485, uint8_t _txen,
               uint8_t _configSize, void* _config,
               uint8_t _numChannels, HBWChannel** _channels,
               Stream* _debugstream, HBWLinkSender* linksender = NULL, HBWLinkReceiver* linkreceiver = NULL) :
    HBWDevice(_devicetype, _hardware_version, _firmware_version,
              _rs485, _txen, _configSize, _config, _numChannels, ((HBWChannel**)(_channels)),
              _debugstream, linksender, linkreceiver) {
    };
    virtual void afterReadConfig();
};

// device specific defaults
void HBDimIODevice::afterReadConfig() {
  if(hbwconfig.logging_time == 0xFF) hbwconfig.logging_time = 50;
};

HBDimIODevice* device = NULL;



void setup()
{
  //change from fast-PWM to phase-correct PWM
  // (This is the timer0 controlled PWM module. Do not change prescaler, it would impact millis() & delay() functions.)
  //TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(WGM00);
//  TCCR0A = B00000001; // phase-correct PWM @490Hz
// TODO: fixme - not working! millis() is running two times slower when not in fast-PWM! - interrupt 'issue'
 
 
  // create channels


#if NUMBER_OF_INPUT_CHAN == 12 && NUMBER_OF_SEN_INPUT_CHAN == 12
  static const uint8_t digitalInput[12] = {IO1, IO2, IO3, IO4, IO5, IO6, IO7, IO8, IO9, IO10, IO11, IO12};  // assing pins

  // input sensor and key channels
  for(uint8_t i = 0; i < NUMBER_OF_SEN_INPUT_CHAN; i++) {
    channels[i] = new HBWSenSC(digitalInput[i], &(hbwconfig.senCfg[i]));
    channels[i + NUMBER_OF_SEN_INPUT_CHAN] = new HBWKey(digitalInput[i], &(hbwconfig.keyCfg[i]));
  };
#else
  #error Input channel count and pin missmatch!
#endif



  Serial.begin(115200);  // Serial->USB for debug
  rs485.begin(19200);   // RS485 via SoftwareSerial, must use 19200 baud!
 
  device = new HBDimIODevice(HMW_DEVICETYPE, HARDWARE_VERSION, FIRMWARE_VERSION,
                             &rs485, RS485_TXEN, sizeof(hbwconfig), &hbwconfig,
                             NUMBER_OF_CHAN, (HBWChannel**)channels,
                             &Serial,
                             new HBWLinkKey<NUM_LINKS_INPUT, LINKADDRESSSTART_INPUT>(), NULL);
 
  device->setConfigPins(BUTTON, LED);  // 8 (button) and 13 (led) is the default
  //device->setStatusLEDPins(LED, LED); // Tx, Rx LEDs

  hbwdebug(F("B: 2A "));
  hbwdebug(freeRam());
  hbwdebug(F("\n"));
 
  // show timer register for debug purpose
//  hbwdebug(F("TCCR0A: "));
//  hbwdebug(TCCR0A);
//  hbwdebug(F("\n"));
//  hbwdebug(F("TCCR0B: "));
//  hbwdebug(TCCR0B);
//  hbwdebug(F("\n"));

}


void loop()
{
  device->loop();
  POWERSAVE();  // go sleep a bit
};

Xml
<?xml version="1.0"?>
<device eep_size="1024" version="14">
<supported_types>
<type priority="2" id="hbw_sen_sc_12_dr" name="RS485 12 Digital inputs">
<parameter const_value="0xA6" size="1" index="0"/><!--HMW_DEVICETYPE-->
<parameter const_value="1" size="1" index="1"/><!--HARDWARE_VERSION-->
<parameter const_value="0x003C" size="2" cond_op="GE" index="2"/><!--Min. FIRMWARE_VERSION-->
</type>
</supported_types>

<paramset id="HMW-Sen-SC-12-DR_dev_master" type="MASTER">
<parameter id="LOGGING_TIME">
<logical type="float" unit="s" default="5.0" max="25.5" min="0.1"/>
<physical size="1.0" type="integer" interface="eeprom">
<address index="0x0001"/>
</physical>
<conversion type="float_integer_scale" offset="0.0" factor="10"/>
</parameter>
<parameter id="CENTRAL_ADDRESS" hidden="true">
<logical type="integer"/>
<physical size="4" type="integer" interface="eeprom">
<address index="0x0002"/>
</physical>
</parameter>
<parameter id="DIRECT_LINK_DEACTIVATE" hidden="true">
<logical type="boolean" default="false"/>
<physical interface="eeprom" size="0.1" type="integer">
<address index="0x0006"/>
</physical>
</parameter>
<enforce id="CENTRAL_ADDRESS" value="1"/>
<enforce id="DIRECT_LINK_DEACTIVATE" value="true"/>
</paramset>

<frames>
<frame id="LEVEL_SET" type="#x" channel_field="10" direction="to_device">
<parameter size="1.0" index="11.0" type="integer" param="LEVEL"/>
</frame>
<frame id="LEVEL_GET" type="#S" channel_field="10" direction="to_device"/>
<frame id="INFO_LEVEL" type="#i" channel_field="10" direction="from_device" event="true">
<parameter size="1.0" index="11.0" type="integer" param="LEVEL"/>
<parameter size="0.3" index="12.4" type="integer" param="STATE_FLAGS"/>
</frame>
<frame id="OLD_LEVEL" direction="to_device" type="#x" channel_field="10">
<parameter type="integer" index="11.0" size="1.0" const_value="201"/>
</frame>
<frame id="STATE_LEVEL" type="#i" channel_field="10" direction="from_device" event="true">
<parameter size="1.0" index="11.0" type="integer" param="STATE"/>
</frame>
<frame id="KEY_EVENT_SHORT" type="#K" channel_field="10" direction="from_device" event="true">
<parameter const_value="0" size="0.1" index="12.0" type="integer"/>
<parameter size="0.6" index="12.2" type="integer" param="COUNTER"/>
</frame>
<frame id="KEY_EVENT_LONG" type="#K" channel_field="10" direction="from_device" event="true">
<parameter const_value="1" size="0.1" index="12.0" type="integer"/>
<parameter size="0.6" index="12.2" type="integer" param="COUNTER"/>
</frame>
<frame id="KEY_SIM_SHORT" type="#K" channel_field="10" direction="from_device" receiver_channel_field="11">
<parameter const_value="0" size="0.1" index="12.0" type="integer"/>
<parameter size="0.6" index="12.2" type="integer" param="COUNTER"/>
</frame>
<frame id="KEY_SIM_LONG" type="#K" channel_field="10" direction="from_device" receiver_channel_field="11">
<parameter const_value="1" size="0.1" index="12.0" type="integer"/>
<parameter size="0.6" index="12.2" type="integer" param="COUNTER"/>
</frame>
<frame id="SET_LOCK" type="#l" channel_field="11" direction="to_device">
<parameter type="integer" index="12.0" size="1.0" param="INHIBIT"/>
</frame>
<frame id="TOGGLE_INSTALL_TEST" type="#x" channel_field="10" direction="to_device">
<parameter type="integer" index="11.0" size="1.0" param="TOGGLE_FLAG"/>
</frame>
</frames>

<channels>
<channel index="0" type="MAINTENANCE" count="1" class="maintenance" ui_flags="internal">
<paramset id="maint_ch_master" type="MASTER"/>
<paramset id="maint_ch_values" type="VALUES">
<parameter id="UNREACH" ui_flags="service" operations="read,event">
<logical type="boolean"/>
<physical type="integer" interface="internal" value_id="UNREACH"/>
</parameter>
<parameter id="STICKY_UNREACH" ui_flags="service" operations="read,write,event">
<logical type="boolean"/>
<physical type="integer" interface="internal" value_id="STICKY_UNREACH"/>
</parameter>
<parameter id="CONFIG_PENDING" ui_flags="service" operations="read,event">
<logical type="boolean"/>
<physical type="integer" interface="internal" value_id="CONFIG_PENDING"/>
</parameter>
</paramset>
</channel>

<channel index="1" type="SENSOR" count="12" physical_index_offset="-1"> <!-- input sensor contact chan -->
<paramset type="MASTER" id="hmw_sensor_ch_master" address_start="0x07" address_step="1">
    <parameter id="INPUT_LOCKED">
<logical type="boolean" default="false"/>
<physical size="0.1" type="integer" interface="eeprom">
<address index="+0.0"/>
</physical>
<conversion type="boolean_integer" invert="true"/>
</parameter>
<parameter id="INVERTED">
<logical type="boolean" default="false"/>
<physical size="0.1" type="integer" interface="eeprom">
<address index="+0.1"/>
</physical>
<conversion type="boolean_integer" invert="true"/>
</parameter>
<parameter id="NOTIFY">
<logical type="option">
<option id="ON"/>
<option id="OFF" default="true"/>
</logical>
<physical size="0.1" type="integer" interface="eeprom">
<address index="+0.2"/>
</physical>
</parameter>
</paramset>

<paramset type="VALUES" id="hmw_sensor_ch_values">
<parameter id="SENSOR" operations="read,event" control="DOOR_SENSOR.STATE">
<logical type="boolean"/>
<physical type="integer" interface="command" value_id="STATE">
<event frame="STATE_LEVEL" auth_violate_policy="reject"/>
<get request="LEVEL_GET" response="STATE_LEVEL"/>
</physical>
</parameter>
<parameter id="INSTALL_TEST" operations="event" ui_flags="internal">
<logical type="action"/>
<physical type="integer" interface="command" value_id="TEST_COUNTER">
<event frame="STATE_LEVEL"/>
</physical>
</parameter>
</paramset>
</channel>

<channel index="13" type="KEY" count="12" physical_index_offset="-1"> <!-- input key chan -->
<link_roles>
<source name="SWITCH"/>
</link_roles>
<paramset id="hbw_input_ch_master" type="MASTER" address_start="0x13" address_step="2">
    <parameter id="INPUT_LOCKED">
<logical type="boolean" default="false"/>
<physical size="0.1" type="integer" interface="eeprom">
<address index="+0.0"/>
</physical>
<conversion type="boolean_integer" invert="true"/>
</parameter>
<parameter id="INVERTED">
<logical type="boolean" default="false"/>
<physical size="0.1" type="integer" interface="eeprom">
<address index="+0.1"/>
</physical>
<conversion type="boolean_integer" invert="true"/>
</parameter>

<parameter id="INPUT_TYPE">
<logical type="option">
<option id="DOORSENSOR"/>
<option id="MOTIONSENSOR"/>
<option id="SWITCH"/>
<option id="PUSHBUTTON" default="true"/>
</logical>
<physical size="0.2" type="integer" interface="eeprom">
<address index="+0.3"/>
</physical>
</parameter>
<parameter id="LONG_PRESS_TIME">
<logical type="float" unit="s" default="1.0" max="5.0" min="0.4"/>
<physical size="1.0" type="integer" interface="eeprom">
<address index="+1"/>
</physical>
<conversion type="float_integer_scale" factor="10"/>
<conversion type="integer_integer_map">
<value_map to_device="false" from_device="true" parameter_value="10" device_value="0xff"/>
</conversion>
</parameter>
</paramset>

<paramset id="hmw_input_ch_link" type="LINK" channel_param="CHANNEL" peer_param="ACTUATOR" count="20" address_start="0x38" address_step="6">
<parameter hidden="true" id="CHANNEL" operations="none">
<logical type="integer" default="255" max="255" min="0"/>
<physical size="1.0" type="integer" interface="eeprom">
<address index="+0"/>
</physical>
</parameter>
<parameter hidden="true" id="ACTUATOR" operations="none">
<logical type="address"/>
<physical type="array">
<physical size="4.0" type="integer" interface="eeprom">
<address index="+1"/>
</physical>
<physical size="1.0" type="integer" interface="eeprom">
<address index="+5"/>
</physical>
</physical>
</parameter>
</paramset>

<paramset type="VALUES" id="hbw_input_ch_values">
<parameter id="PRESS_SHORT" operations="event" loopback="true" control="BUTTON.SHORT">
<logical type="action"/>
<physical type="integer" interface="command" value_id="COUNTER">
<event frame="KEY_EVENT_SHORT"/>
</physical>
<conversion type="action_key_counter" counter_size="6" sim_counter="SIM_COUNTER"/>
</parameter>
<parameter id="PRESS_LONG" operations="event" loopback="true" control="BUTTON.LONG">
<logical type="action"/>
<physical type="integer" interface="command" value_id="COUNTER">
<event frame="KEY_EVENT_LONG"/>
</physical>
<conversion type="action_key_counter" counter_size="6" sim_counter="SIM_COUNTER"/>
</parameter>
<parameter id="SENSOR" operations="read,event" control="DOOR_SENSOR.STATE">
<logical type="boolean" default="false"/>
<physical type="integer" interface="command" value_id="LEVEL">
<get request="LEVEL_GET" response="INFO_LEVEL"/>
<event frame="INFO_LEVEL" auth_violate_policy="reject"/>
</physical>

</parameter>

<parameter id="INSTALL_TEST" operations="event" ui_flags="internal">
<logical type="action"/>
<physical type="integer" interface="command" value_id="TEST_COUNTER">
<event frame="KEY_EVENT_SHORT"/>
<event frame="KEY_EVENT_LONG"/>
<event frame="INFO_LEVEL"/>
</physical>
</parameter>
</paramset>
</channel>


</channels>
</device>

Gruß
Juri
« Letzte Änderung: 07 August 2021, 10:00:02 von aperoap »

Offline aperoap

  • Jr. Member
  • **
  • Beiträge: 60
Antw:Homematic Wired - Homebrew Devices
« Antwort #693 am: 08 August 2021, 17:44:21 »
Hallo zusammen, hab den Fehler gefunden. Es lag daran dass der hbw_sen_sc_12_d als einziger device in rs485 Netzwerk war. Das peering wird in fhem nur angezeigt, wenn ein Aktor, Welches paaringfähig ist rs485 vorhanden ist.
Somit ist der hbw_sen_sc_12_d komplett funktionsfähig.
Die funktionierenden files noch mal in Abhang.

Gruß
Juri

Offline loetmeister

  • Full Member
  • ***
  • Beiträge: 409
Antw:Homematic Wired - Homebrew Devices
« Antwort #694 am: 08 August 2021, 21:38:05 »
Hi Juri,

schön das es nun Funktioniert (und gar kein Problem mit dem Device war)  8)

"LOGGING_TIME" könntest du komplett raus nehmen, das wird nur bei Aktoren genutzt.
Ansonsten würde ich das Device mit ins Github aufnehmen, wenns ok ist?

Gruß,
Thomas

Offline loetmeister

  • Full Member
  • ***
  • Beiträge: 409
Antw:Homematic Wired - Homebrew Devices
« Antwort #695 am: 10 August 2021, 22:43:28 »
Hi,

habe dein Device hinzugefügt.
https://github.com/loetmeister/HBWired/tree/master/HBW-Sen-SC-12-DR

LOGGING_TIME hab ich rausgenommen... dann kann man die Standard "HBWDevice" Klasse verwenden und es wird etwas übersichtlicher.
Damit es konsistent zu den anderen Devices ist, habe ich die hardware serial Option hinzugefügt (USE_HARDWARE_SERIAL). Pins habe ich so gelassen, weiß nicht warum zwei als "dummy pin" bezeichnet sind? Ist das nur ein alter Kommentar? (IO9, IO10)

Gruß,
Thomas

 

decade-submarginal