Merge pull request #676 from proddy/dev

NO and Commands translations
This commit is contained in:
Proddy
2022-10-11 08:28:12 +02:00
committed by GitHub
23 changed files with 440 additions and 446 deletions

View File

@@ -129,12 +129,7 @@ const SignIn: FC = () => {
<PLflag style={{ width: 24 }} /> <PLflag style={{ width: 24 }} />
&nbsp;PL &nbsp;PL
</Button> </Button>
<Button <Button size="small" variant={locale === 'no' ? 'contained' : 'outlined'} onClick={() => selectLocale('no')}>
disabled
size="small"
variant={locale === 'no' ? 'contained' : 'outlined'}
onClick={() => selectLocale('no')}
>
<NOflag style={{ width: 24 }} /> <NOflag style={{ width: 24 }} />
&nbsp;NO &nbsp;NO
</Button> </Button>

View File

@@ -93,7 +93,7 @@ const LayoutAuthMenu: FC = () => {
<PLflag style={{ width: 16, verticalAlign: 'middle' }} /> <PLflag style={{ width: 16, verticalAlign: 'middle' }} />
&nbsp;PL &nbsp;PL
</MenuItem> </MenuItem>
<MenuItem key="no" value="no" disabled> <MenuItem key="no" value="no">
<NOflag style={{ width: 16, verticalAlign: 'middle' }} /> <NOflag style={{ width: 16, verticalAlign: 'middle' }} />
&nbsp;NO &nbsp;NO
</MenuItem> </MenuItem>

View File

@@ -1,270 +1,269 @@
import type { BaseTranslation } from '../i18n-types'; import type { BaseTranslation } from '../i18n-types';
const no: BaseTranslation = { const no: BaseTranslation = {
LANGUAGE: 'Language', LANGUAGE: 'Språk',
RETRY: 'Retry', RETRY: 'Forsøk igjen',
LOADING: 'Loading', LOADING: 'Laster',
IS_REQUIRED: 'is required', IS_REQUIRED: 'er nødvendig',
SIGN_IN: 'Sign In', SIGN_IN: 'Logg inn',
SIGN_OUT: 'Sign Out', SIGN_OUT: 'Logg ut',
USERNAME: 'Username', USERNAME: 'Brukernavn',
PASSWORD: 'Password', PASSWORD: 'Passord',
DASHBOARD: 'Dashboard', DASHBOARD: 'Dashboard',
SETTINGS: 'Settings', SETTINGS: 'Innstillinger',
SAVED: 'saved', SAVED: 'lagret',
HELP: 'Help', HELP: 'Hjelp',
LOGGED_IN: 'Logged in as {name}', LOGGED_IN: 'Logget in som {name}',
PLEASE_SIGNIN: 'Please sign in to continue', PLEASE_SIGNIN: 'Venligst logge inn for å fortsetta',
UPLOAD_SUCCESSFUL: 'Upload successful', UPLOAD_SUCCESSFUL: 'Opplasting lykkes',
DOWNLOAD_SUCCESSFUL: 'Download successful', DOWNLOAD_SUCCESSFUL: 'Nedlasting lykkes',
INVALID_LOGIN: 'Invalid login details', INVALID_LOGIN: 'Ugyldig innlogging',
NETWORK: 'Network', NETWORK: 'Nettverk',
SECURITY: 'Security', SECURITY: 'Sikkerhet',
ONOFF_CAP: 'ON/OFF', ONOFF_CAP: 'PÅ/AV',
ONOFF: 'on/off', ONOFF: 'på/av',
TYPE: 'Type', TYPE: 'Type',
DESCRIPTION: 'Description', DESCRIPTION: 'Beskrivelse',
ENTITIES: 'Entities', ENTITIES: 'Ojekter',
REFRESH: 'Refresh', REFRESH: 'Oppdater',
EXPORT: 'Export', EXPORT: 'Eksport',
DEVICE_DETAILS: 'Device Details', DEVICE_DETAILS: 'Enhetsdetaljer',
BRAND: 'Brand', BRAND: 'Fabrikat',
ENTITY_NAME: 'Entity Name', ENTITY_NAME: 'Objektsnavn',
VALUE: 'Value', VALUE: 'Verdi',
SHOW_FAV: 'only show favorites', SHOW_FAV: ' Vis kun favoritter',
DEVICE_SENSOR_DATA: 'Device and Sensor Data', DEVICE_SENSOR_DATA: 'Enheter og Sensordata',
DEVICES_SENSORS: 'Devices & Sensors', DEVICES_SENSORS: 'Enheter og Sensorer',
ATTACHED_SENSORS: 'Attached EMS-ESP Sensors', ATTACHED_SENSORS: 'Tilkoblede EMS-ESP Sensorer',
RUN_COMMAND: 'Call Command', RUN_COMMAND: 'Kjør kommando',
CHANGE_VALUE: 'Change Value', CHANGE_VALUE: 'Endre Verdi',
CANCEL: 'Cancel', CANCEL: 'Avbryt',
RESET: 'Reset', RESET: 'Nullstill',
SEND: 'Send', SEND: 'Send',
SAVE: 'Save', SAVE: 'Lagre',
REMOVE: 'Remove', REMOVE: 'Fjern',
PROBLEM_UPDATING: 'Problem updating', PROBLEM_UPDATING: 'Problem med oppdatering',
PROBLEM_LOADING: 'Problem loading', PROBLEM_LOADING: 'Problem med opplasting',
ACCESS_DENIED: 'Access Denied', ACCESS_DENIED: 'Tilgang nektet',
ANALOG_SENSOR: 'Analog Sensor', ANALOG_SENSOR: 'Analog Sensor',
ANALOG_SENSORS: 'Analog Sensors', ANALOG_SENSORS: 'Analoge Sensorer',
UPDATED: 'Updated', UPDATED: 'Oppdatert',
UPDATE: 'Update', UPDATE: 'Oppdater',
REMOVED: 'Removed', REMOVED: 'Slettet',
DELETION: 'Deletion', DELETION: 'Sletting',
OFFSET: 'Offset', OFFSET: 'Kompensering',
FACTOR: 'Factor', FACTOR: 'Faktor',
FREQ: 'Frequency', FREQ: 'Frekvens',
STARTVALUE: 'Start value', STARTVALUE: 'Startverdi',
WARN_GPIO: 'Warning: be careful when assigning a GPIO!', WARN_GPIO: 'Advarsel: vær forsiktig ved aktivering av GPIO!',
EDIT: 'Edit', EDIT: 'Endre',
TEMP_SENSOR: 'Temperature Sensor', TEMP_SENSOR: 'Temperatursensor',
TEMP_SENSORS: 'Temperature Sensors', TEMP_SENSORS: 'Temperaturesensorer',
WRITE_COMMAND: 'Write command {cmd}', WRITE_COMMAND: 'Skriv kommando {cmd}',
EMS_BUS_WARNING: EMS_BUS_WARNING:
'EMS bus disconnected. If this warning still persists after a few seconds please check settings and board profile', 'EMS bussen koblet ned. Hvis denne advarselen fortsetter etter noen f¨sekunder sjekk instillinger og prosessorkort',
EMS_BUS_SCANNING: 'Scanning for EMS devices...', EMS_BUS_SCANNING: 'Søker etter EMS enheter...',
CONNECTED: 'Connected', CONNECTED: 'Tilkoblet',
TX_ISSUES: 'Tx issues - try a different Tx Mode', TX_ISSUES: 'Tx problemer - prøv en annen Tx Modus',
DISCONNECTED: 'Disconnected', DISCONNECTED: 'Frakoblet',
EMS_SCAN: 'Are you sure you want to initiate a full device scan of the EMS bus?', EMS_SCAN: 'Er du sikker på du vil starte full søking av EMS bussen?',
EMS_BUS_STATUS: 'EMS Bus Status', EMS_BUS_STATUS: 'EMS Buss Status',
ACTIVE_DEVICES: 'Active Devices & Sensors', ACTIVE_DEVICES: 'Aktive Enheter og Sensorer',
DEVICE: 'Device', DEVICE: 'Enhet',
SUCCESS: 'SUCCESS', SUCCESS: 'VELLYKKET',
FAIL: 'FAIL', FAIL: 'MISLYKKET',
QUALITY: 'QUALITY', QUALITY: 'KVALITET',
SCAN_DEVICES: 'Scan for new devices', SCAN_DEVICES: 'Søk etter nye enheter',
EMS_BUS_STATUS_TITLE: 'EMS Bus & Activity Status', EMS_BUS_STATUS_TITLE: 'EMS Buss & Aktivitet Status',
SCAN: 'Scan', SCAN: 'Søk',
STATUS_NAMES: [ STATUS_NAMES: [
'EMS Telegrams Received (Rx)', 'EMS Telegrammer Mottatt (Rx)',
'EMS Reads (Tx)', 'EMS Lest (Tx)',
'EMS Writes (Tx)', 'EMS Skrevet (Tx)',
'Temperature Sensor Reads', 'Temperatur Sensor Lest',
'Analog Sensor Reads', 'Analog Sensor Lest',
'MQTT Publishes', 'MQTT Publiseringer',
'API Calls', 'API Anrop',
'Syslog Messages' 'Syslog Meldinger'
], ],
NUM_DEVICES: '{num} Device{{s}}', NUM_DEVICES: '{num} Enhet{{er}}',
NUM_TEMP_SENSORS: '{num} Temperature Sensor{{s}}', NUM_TEMP_SENSORS: '{num} Temperatursensor{{er}}',
NUM_ANALOG_SENSORS: '{num} Analog Sensor{{s}}', NUM_ANALOG_SENSORS: '{num} Analogsensor{{er}}',
NUM_DAYS: '{num} Day{{s}}', NUM_DAYS: '{num} Dag{{er}}',
NUM_SECONDS: '{num} Second{{s}}', NUM_SECONDS: '{num} Sekund{{er}}',
NUM_HOURS: '{num} Hour{{s}}', NUM_HOURS: '{num} Time{{r}}',
NUM_MINUTES: '{num} Minute{{s}}', NUM_MINUTES: '{num} Minutt{{er}}',
APPLICATION_SETTINGS: 'Application Settings', APPLICATION_SETTINGS: 'Innstillinger',
CUSTOMIZATION: 'Customization', CUSTOMIZATION: 'Tilpasninger',
APPLICATION_RESTARTING: 'EMS-ESP is restarting', APPLICATION_RESTARTING: 'EMS-ESP restarter',
BOARD_PROFILE_TEXT: BOARD_PROFILE_TEXT:
'Select a pre-configured interface board profile from the list below or choose Custom to configure your own hardware settings', 'Velg en pre-konfigurert prosessor profil fra listen under eller velg Tilpasset for å konfigurere dine egne innstillinger',
BOARD_PROFILE: 'Board Profile', BOARD_PROFILE: 'Prosessor Profil',
BUTTON: 'Button', BUTTON: 'Knapp',
TEMPERATURE: 'Temperature', TEMPERATURE: 'Temperatur',
DISABLED: 'disabled', DISABLED: 'avslått',
GENERAL_OPTIONS: 'General Options', GENERAL_OPTIONS: 'Generelle Innstillinger',
LANGUAGE_ENTITIES: 'Language (for device entities)', LANGUAGE_ENTITIES: 'Språk (for objekter)',
HIDE_LED: 'Hide LED', HIDE_LED: 'Skjul LED',
ENABLE_TELNET: 'Enable Telnet Console', ENABLE_TELNET: 'Aktiver Telnet',
ENABLE_ANALOG: 'Enable Analog Sensors', ENABLE_ANALOG: 'Aktiver Analoge Sensorer',
CONVERT_FAHRENHEIT: 'Convert temperature values to Fahrenheit', CONVERT_FAHRENHEIT: 'Konverter temperatur til Fahrenheit',
BYPASS_TOKEN: 'Bypass Access Token authorization on API calls', BYPASS_TOKEN: 'Utelat Aksess Token authorisering av API kall',
READONLY: 'Enable read-only mode (blocks all outgoing EMS Tx Write commands)', READONLY: 'Aktiver read-only modus (blokker all EMS Tx Skriving)',
UNDERCLOCK_CPU: 'Underclock CPU speed', UNDERCLOCK_CPU: 'Underklokking av prosessorhastighet',
ENABLE_SHOWER_TIMER: 'Enable Shower Timer', ENABLE_SHOWER_TIMER: 'Aktiver Dusjtimer',
ENABLE_SHOWER_ALERT: 'Enable Shower Alert', ENABLE_SHOWER_ALERT: 'Aktiver Dusj-varsling',
TRIGGER_TIME: 'Trigger Time', TRIGGER_TIME: 'Aktiveringstid',
COLD_SHOT_DURATION: 'Cold Shot Duration', COLD_SHOT_DURATION: 'Tid på kaldt vann',
FORMATTING_OPTIONS: 'Formatting Options', FORMATTING_OPTIONS: 'Formatteringsalternativs',
BOOLEAN_FORMAT_DASHBOARD: 'Boolean Format Dashboard', BOOLEAN_FORMAT_DASHBOARD: 'Bool Format Dashboard',
BOOLEAN_FORMAT_API: 'Boolean Format API/MQTT', BOOLEAN_FORMAT_API: 'Bool Format API/MQTT',
ENUM_FORMAT: 'Enum Format API/MQTT', ENUM_FORMAT: 'Enum Format API/MQTT',
INDEX: 'Index', INDEX: 'Indeks',
ENABLE_PARASITE: 'Enable parasite power', ENABLE_PARASITE: 'Aktiver parasitt strømforsyning',
LOGGING: 'Logging', LOGGING: 'Logging',
LOG_HEX: 'Log EMS telegrams in hexadecimal', LOG_HEX: 'Logg EMS telegrammer i hexadesimal',
ENABLE_SYSLOG: 'Enable Syslog', ENABLE_SYSLOG: 'Aktiver Syslog',
MARK_INTERVAL: 'Mark Interval', MARK_INTERVAL: 'Oppdateringsintervall',
SECONDS: 'seconds', SECONDS: 'sekunder',
MINUTES: 'minutes', MINUTES: 'minutter',
RESTART: 'Restart', RESTART: 'Omstart',
HOURS: 'hours', HOURS: 'timer',
RESTART_TEXT: 'EMS-ESP needs to be restarted to apply changed system settings', RESTART_TEXT: 'EMS-ESP må omstartes for å iverksette endrede systeminstillinger',
RESTART_CONFIRM: 'Are you sure you want to restart EMS-ESP?', RESTART_CONFIRM: 'Er du sikker på at du vil omstarte EMS-ESP?',
COMMAND: 'Command', COMMAND: 'Kommando',
CUSTOMIZATIONS_RESTART: 'All customizations have been removed. Restarting...', CUSTOMIZATIONS_RESTART: 'Alle tilpasninger har blitt slettet. Restarter...',
CUSTOMIZATIONS_FULL: 'Selected entities exceeded limit. Please save in batches', CUSTOMIZATIONS_FULL: 'Antall valgte objekter for høyt. Largre i mindre antall om gangen',
CUSTOMIZATIONS_SAVED: 'Customizations saved', CUSTOMIZATIONS_SAVED: 'Tilpasninger lagret',
CUSTOMIZATIONS_HELP_1: 'Select a device and customize the entities options or click to rename', CUSTOMIZATIONS_HELP_1: 'Velg en enhet og tilpass underenheter med hjelp av alternativer eller velg å gi nytt navn',
CUSTOMIZATIONS_HELP_2: 'mark as favorite', CUSTOMIZATIONS_HELP_2: 'merk som favoritt',
CUSTOMIZATIONS_HELP_3: 'disable write action', CUSTOMIZATIONS_HELP_3: 'inaktiviser skriving',
CUSTOMIZATIONS_HELP_4: 'exclude from MQTT and API', CUSTOMIZATIONS_HELP_4: 'ekskludere fra MQTT og API',
CUSTOMIZATIONS_HELP_5: 'hide from Dashboard', CUSTOMIZATIONS_HELP_5: 'gjemme fra Dashboard',
SELECT_DEVICE: 'Select a device', SELECT_DEVICE: 'Velg en enhet',
SET_ALL: 'set all', SET_ALL: 'sett alle',
OPTIONS: 'Options', OPTIONS: 'Alternativ',
NAME: 'Name', NAME: 'Navn',
CUSTOMIZATIONS_RESET: CUSTOMIZATIONS_RESET:
'Are you sure you want remove all customizations including the custom settings of the Temperature and Analog sensors?', 'Er du sikker på att du vil fjerne tilpassninger inkludert innstillinger for Temperatur og Analoge sensorer?',
DEVICE_ENTITIES: 'Device Entities', DEVICE_ENTITIES: 'Enhets objekter',
USER_CUSTOMIZATION: 'User Customization', USER_CUSTOMIZATION: 'Brukertilpasninger',
SUPPORT_INFORMATION: 'Support Information', SUPPORT_INFORMATION: 'Supportinformasjon',
CLICK_HERE: 'Click Here', CLICK_HERE: 'Klikk her',
HELP_INFORMATION_1: 'Visit the online wiki to get instructions on how to configure EMS-ESP', HELP_INFORMATION_1: 'Besøk wiki for instruksjoner for å konfigurere EMS-ESP',
HELP_INFORMATION_2: 'For live community chat join our Discord server', HELP_INFORMATION_2: 'For community-support besøk vår Discord-server',
HELP_INFORMATION_3: 'To request a feature or report a bug', HELP_INFORMATION_3: 'For å be om en ny funksjon eller melde feil',
HELP_INFORMATION_4: HELP_INFORMATION_4:
'remember to download and attach your system information for a faster response when reporting an issue', 'husk å laste ned og legg ved din systeminformasjon for en raskere respons når du rapporterer et problem',
HELP_INFORMATION_5: HELP_INFORMATION_5: 'EMS-ESP er gratis og åpen kildekode. Bidra til utviklingen ved å gi oss en stjerne på GitHub!',
'EMS-ESP is a free and open-source project. Please support its future development by giving it a star on Github!', SUPPORT_INFO: 'Supportinfo',
SUPPORT_INFO: 'Support Info', UPLOAD: 'Opplasning',
UPLOAD: 'Upload', DOWNLOAD: 'Nedlasting',
DOWNLOAD: 'Download', ABORTED: 'avbrutt',
ABORTED: 'aborted', FAILED: 'feilet',
FAILED: 'failed', SUCCESSFUL: 'vellykket',
SUCCESSFUL: 'successful',
SYSTEM: 'System', SYSTEM: 'System',
LOG: 'Log', LOG: 'Logg',
STATUS: 'Status', STATUS: 'Status',
UPLOAD_DOWNLOAD: 'Upload/Download', UPLOAD_DOWNLOAD: 'Opp/Nedlasting',
SYSTEM_VERSION_RUNNING: 'You are currently running version', SYSTEM_VERSION_RUNNING: 'Du benytter versjon',
SYSTEM_APPLY_FIRMWARE: 'to apply the new firmware', SYSTEM_APPLY_FIRMWARE: 'for å aktivere ny firmware',
CLOSE: 'Close', CLOSE: 'Steng',
USE: 'Use', USE: 'Bruk',
FACTORY_RESET: 'Factory Reset', FACTORY_RESET: 'Sett tilbake til fabrikkinstilling',
SYSTEM_FACTORY_TEXT: 'Device has been factory reset and will now restart', SYSTEM_FACTORY_TEXT: 'Enhet har blitt satt tilbake til fabrikkinstilling og vil restarte',
SYSTEM_FACTORY_TEXT_DIALOG: 'Are you sure you want to reset the device to its factory defaults?', SYSTEM_FACTORY_TEXT_DIALOG: 'Er du sikker på at du vil resette enheten til fabrikkinstillinger?',
VERSION_CHECK: 'Version Check', VERSION_CHECK: 'Versjonsjekk',
THE_LATEST: 'The latest', THE_LATEST: 'Den nyeste',
VERSION_IS: 'version is', VERSION_IS: 'versjonen er',
PLATFORM: 'Device (Platform / SDK)', PLATFORM: 'Enhet (Platform / SDK)',
UPTIME: 'System Uptime', UPTIME: 'System Oppetid',
CPU_FREQ: 'CPU Frequency', CPU_FREQ: 'CPU Frekvens',
HEAP: 'Heap (Free / Max Alloc)', HEAP: 'Heap (Ledig / Max Allokert)',
PSRAM: 'PSRAM (Size / Free)', PSRAM: 'PSRAM (Størrelse / Ledig)',
FLASH: 'Flash Chip (Size / Speed)', FLASH: 'Flash Chip (Størrelse / Hastighet)',
APPSIZE: 'Application (Used / Free)', APPSIZE: 'Applikasjon (Brukt / Ledig)',
FILESYSTEM: 'File System (Used / Free)', FILESYSTEM: 'File System (Brukt / Ledig)',
BUFFER_SIZE: 'Buffer Size', BUFFER_SIZE: 'Buffer Størrelse',
COMPACT: 'Compact', COMPACT: 'Komprimere',
ENABLE_OTA: 'Enable OTA Updates', ENABLE_OTA: 'Aktiviser OTA oppdateringer',
DOWNLOAD_CUSTOMIZATION_TEXT: 'Download the entity customizations', DOWNLOAD_CUSTOMIZATION_TEXT: 'Last ned objektstilpasninger',
DOWNLOAD_SETTINGS_TEXT: DOWNLOAD_SETTINGS_TEXT:
'Download the application settings. Be careful when sharing your settings as this file contains passwords and other sensitive system information', 'Last ned applikasjonskonfigurasjon. Vær varsom med å dele fila da den inneholder passord og annen sensitiv system informasjon',
UPLOAD_TEXT: 'Upload a new firmware (.bin) file, settings or customizations (.json) file below', UPLOAD_TEXT: 'Last opp en ny firmware (.bin) fil, innstillinger eller tilpassninger (.json) fil nedenfor',
UPLOADING: 'Uploading', UPLOADING: 'Opplasting',
UPLOAD_DROP_TEXT: 'Drop file or click here', UPLOAD_DROP_TEXT: 'Slipp fil eller klikk her',
ERROR: 'Unexpected Error, please try again', ERROR: 'Ukjent feil, prøv igjen',
TIME_SET: 'Time set', TIME_SET: 'Still in tid',
MANAGE_USERS: 'Manage Users', MANAGE_USERS: 'Administrer Brukere',
IS_ADMIN: 'is Admin', IS_ADMIN: 'er Admin',
USER_WARNING: 'You must have at least one admin user configured', USER_WARNING: 'Du må ha minst en admin bruker konfigurert',
ADD: 'Add', ADD: 'Legg til',
ACCESS_TOKEN_FOR: 'Access Token for', ACCESS_TOKEN_FOR: 'Aksess Token for',
ACCESS_TOKEN_TEXT: ACCESS_TOKEN_TEXT:
'The token below is used with REST API calls that require authorization. It can be passed either as a Bearer token in the Authorization header or in the access_token URL query parameter.', 'Token nedenfor benyttes med REST API-kall som krever autorisering. Den kan sendes med enten som en Bearer token i Authorization-headern eller i access_token URL query-parameter.',
GENERATING_TOKEN: 'Generating token', GENERATING_TOKEN: 'Generer token',
USER: 'User', USER: 'Bruker',
MODIFY: 'Modify', MODIFY: 'Endre',
SU_TEXT: SU_TEXT:
'The su (super user) password is used to sign authentication tokens and also enable admin privileges within the Console.', 'su brukeren (super user) passord benyttes for å signere autentiserings token samt å tillate admin privileger i konsoll modus.',
NOT_ENABLED: 'Not enabled', NOT_ENABLED: 'Ikke aktiv',
ERRORS: 'Errors', ERRORS: 'Feil',
DISCONNECT_REASON: 'Disconnect Reason', DISCONNECT_REASON: 'Årsak til nedkobling',
ENABLE_MQTT: 'Enable MQTT', ENABLE_MQTT: 'Aktiver MQTT',
OPTIONAL: 'Optional', OPTIONAL: 'Valgfritt',
FORMATTING: 'Formatting', FORMATTING: 'Formatering',
FORMAT: 'Format', FORMAT: 'Format',
MQTT_NEST_1: 'Nested in a single topic', MQTT_NEST_1: 'Nestet i en topic',
MQTT_NEST_2: 'As individual topics', MQTT_NEST_2: 'Som individuelle topics',
MQTT_RESPONSE: 'Publish command output to a `response` topic', MQTT_RESPONSE: 'Publiser kommandoer til en `response` topic',
MQTT_PUBLISH_TEXT_1: 'Publish single value topics on change', MQTT_PUBLISH_TEXT_1: 'Publiser singel verdi topics ved endringer',
MQTT_PUBLISH_TEXT_2: 'Publish to command topics (ioBroker)', MQTT_PUBLISH_TEXT_2: 'Publiser til kommando topics (ioBroker)',
MQTT_PUBLISH_TEXT_3: 'Enable MQTT Discovery (Home Assistant, Domoticz)', MQTT_PUBLISH_TEXT_3: 'Aktiver MQTT Discovery (Home Assistant, Domoticz)',
MQTT_PUBLISH_TEXT_4: 'Prefix for the Discovery topics', MQTT_PUBLISH_TEXT_4: 'Prefiks for Discovery topics',
MQTT_PUBLISH_INTERVALS: 'Publish Intervals', MQTT_PUBLISH_INTERVALS: 'Publiseringsintervall',
MQTT_INT_BOILER: 'Boilers and Heat Pumps', MQTT_INT_BOILER: 'Fyr/Varmepumpe',
MQTT_INT_THERMOSTATS: 'Thermostats', MQTT_INT_THERMOSTATS: 'Termostat',
MQTT_INT_SOLAR: 'Solar Modules', MQTT_INT_SOLAR: 'Solpaneler',
MQTT_INT_MIXER: 'Mixer Modules', MQTT_INT_MIXER: 'Blandeventil',
DEFAULT: 'Default', DEFAULT: 'Standard',
MQTT_CLEAN_SESSION: 'Set Clean Session', MQTT_CLEAN_SESSION: 'Benytt Clean Session',
MQTT_RETAIN_FLAG: 'Always set Retain flag', MQTT_RETAIN_FLAG: 'Alltid sett Retain flag',
INACTIVE: 'Inactive', INACTIVE: 'Innaktiv',
ACTIVE: 'Active', ACTIVE: 'Aktiv',
UNKNOWN: 'Unknown', UNKNOWN: 'Ukjent',
SET_TIME: 'Set Time', SET_TIME: 'Sett Tid',
SET_TIME_TEXT: 'Enter local date and time below to set the time', SET_TIME_TEXT: 'Skriv inn dato og klokke nedenfor',
LOCAL_TIME: 'Local Time', LOCAL_TIME: 'Lokaltid',
UTC_TIME: 'UTC Time', UTC_TIME: 'UTC Tid',
ENABLE_NTP: 'Enable NTP', ENABLE_NTP: 'Aktiver NTP',
TIME_ZONE: 'Time Zone', TIME_ZONE: 'Tidssone',
ACCESS_POINT: 'Access Point', ACCESS_POINT: 'Aksesspunkt',
AP_PROVIDE: 'Enable Access Point', AP_PROVIDE: 'Aktiver Aksesspunkt',
AP_PROVIDE_TEXT_1: 'always', AP_PROVIDE_TEXT_1: 'alltid',
AP_PROVIDE_TEXT_2: 'when WiFi is disconnected', AP_PROVIDE_TEXT_2: 'når WiFi er utilgjengelig',
AP_PROVIDE_TEXT_3: 'never', AP_PROVIDE_TEXT_3: 'aldri',
AP_PREFERRED_CHANNEL: 'Preferred Channel', AP_PREFERRED_CHANNEL: 'Foretrukket kanal',
AP_HIDE_SSID: 'Hide SSID', AP_HIDE_SSID: 'Skjul SSID',
NETWORK_SCAN: 'Scan WiFi Networks', NETWORK_SCAN: 'Søk etter trådløst nettverk',
IDLE: 'Idle', IDLE: 'Klar',
LOST: 'Lost', LOST: 'Mistet',
SCANNING: 'Scanning', SCANNING: 'Søker',
SCAN_AGAIN: 'Scan again', SCAN_AGAIN: 'Søk igjen',
NETWORK_SCANNER: 'Network Scanner', NETWORK_SCANNER: 'Nettverk Scanner',
NETWORK_NO_WIFI: 'No WiFi networks found', NETWORK_NO_WIFI: 'Ingen trådløse nett funnet',
NETWORK_BLANK_SSID: 'leave blank to disable WiFi', NETWORK_BLANK_SSID: 'la feltet være blankt for å deaktivisere trådløst nettverk',
POWER: 'Power', POWER: 'Effekt',
NETWORK_DISABLE_SLEEP: 'Disable WiFi Sleep Mode', NETWORK_DISABLE_SLEEP: 'Hindre at trådløst nettverk går i Sleep Mode',
NETWORK_LOW_BAND: 'Use Lower WiFi Bandwidth', NETWORK_LOW_BAND: 'Benytt smalere båndbredde på trådløst nettverk',
NETWORK_USE_DNS: 'Enable mDNS Service', NETWORK_USE_DNS: 'Aktiviser mDNS Service',
NETWORK_ENABLE_IPV6: 'Enable IPv6 support', NETWORK_ENABLE_IPV6: 'Aktiviser IPv6 støtte',
NETWORK_FIXED_IP: 'Use Fixed IP address', NETWORK_FIXED_IP: 'Benytt statisk IP adresse',
ADMIN: 'Admin', ADMIN: 'Admin',
GUEST: 'Guest', GUEST: 'Gjest',
NEW: 'New', NEW: 'Ny',
RENAME: 'Rename', RENAME: 'Bytt navn',
ENTITY: 'Entity' ENTITY: 'Entitet'
}; };
export default no; export default no;

View File

@@ -425,7 +425,7 @@ Commands::Completion Commands::complete_command(Shell & shell, const CommandLine
if (commands.exact.count(longest->first) == 1) { if (commands.exact.count(longest->first) == 1) {
for (auto & name : longest->second->name_) { for (auto & name : longest->second->name_) {
result.replacement->push_back(std::move((name))); // TODO remove all moves? result.replacement->push_back(name);
} }
// Add a space because there are sub-commands for a command that has matched exactly // Add a space because there are sub-commands for a command that has matched exactly

View File

@@ -443,7 +443,6 @@ bool SyslogService::transmit(const QueuedLogMessage & message) {
udp_.print('-'); udp_.print('-');
} }
// TODO should use flash?
udp_.printf_P(PSTR(" %s %s - - - "), hostname_.c_str(), (message.content_->name)); udp_.printf_P(PSTR(" %s %s - - - "), hostname_.c_str(), (message.content_->name));
char id_c_str[15]; char id_c_str[15];

View File

@@ -31,7 +31,6 @@ void AnalogSensor::start() {
} }
analogSetAttenuation(ADC_2_5db); // for all channels 1.5V analogSetAttenuation(ADC_2_5db); // for all channels 1.5V
LOG_INFO("Starting Analog sensor service"); LOG_INFO("Starting Analog sensor service");
// Add API call for /info // Add API call for /info
@@ -39,18 +38,18 @@ void AnalogSensor::start() {
EMSdevice::DeviceType::ANALOGSENSOR, EMSdevice::DeviceType::ANALOGSENSOR,
F_(info), F_(info),
[&](const char * value, const int8_t id, JsonObject & output) { return command_info(value, id, output); }, [&](const char * value, const int8_t id, JsonObject & output) { return command_info(value, id, output); },
F_(info_cmd)); FL_(info_cmd));
Command::add( Command::add(
EMSdevice::DeviceType::ANALOGSENSOR, EMSdevice::DeviceType::ANALOGSENSOR,
F_(setvalue), F_(setvalue),
[&](const char * value, const int8_t id) { return command_setvalue(value, id); }, [&](const char * value, const int8_t id) { return command_setvalue(value, id); },
("set io value"), // TODO translate this FL_(setiovalue_cmd),
CommandFlag::ADMIN_ONLY); CommandFlag::ADMIN_ONLY);
Command::add( Command::add(
EMSdevice::DeviceType::ANALOGSENSOR, EMSdevice::DeviceType::ANALOGSENSOR,
F_(commands), F_(commands),
[&](const char * value, const int8_t id, JsonObject & output) { return command_commands(value, id, output); }, [&](const char * value, const int8_t id, JsonObject & output) { return command_commands(value, id, output); },
F_(commands_cmd)); FL_(commands_cmd));
Mqtt::subscribe(EMSdevice::DeviceType::ANALOGSENSOR, "analogsensor/#", nullptr); // use empty function callback Mqtt::subscribe(EMSdevice::DeviceType::ANALOGSENSOR, "analogsensor/#", nullptr); // use empty function callback
} }

View File

@@ -238,7 +238,7 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char *
uint8_t Command::call(const uint8_t device_type, const char * cmd, const char * value, const bool is_admin, const int8_t id, JsonObject & output) { uint8_t Command::call(const uint8_t device_type, const char * cmd, const char * value, const bool is_admin, const int8_t id, JsonObject & output) {
uint8_t return_code = CommandRet::OK; uint8_t return_code = CommandRet::OK;
std::string dname = EMSdevice::device_type_2_device_name(device_type); auto dname = EMSdevice::device_type_2_device_name(device_type);
// see if there is a command registered // see if there is a command registered
auto cf = find_command(device_type, cmd); auto cf = find_command(device_type, cmd);
@@ -248,7 +248,7 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char *
if ((device_type > EMSdevice::DeviceType::SYSTEM) && (!value || !strlen(value))) { if ((device_type > EMSdevice::DeviceType::SYSTEM) && (!value || !strlen(value))) {
if (!cf || !cf->cmdfunction_json_) { if (!cf || !cf->cmdfunction_json_) {
#if defined(EMSESP_DEBUG) #if defined(EMSESP_DEBUG)
LOG_DEBUG("[DEBUG] Calling %s command '%s' to retrieve attributes", dname.c_str(), cmd); LOG_DEBUG("[DEBUG] Calling %s command '%s' to retrieve attributes", dname, cmd);
#endif #endif
return EMSESP::get_device_value_info(output, cmd, id, device_type) ? CommandRet::OK : CommandRet::ERROR; // entity = cmd return EMSESP::get_device_value_info(output, cmd, id, device_type) ? CommandRet::OK : CommandRet::ERROR; // entity = cmd
} }
@@ -262,17 +262,19 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char *
return CommandRet::NOT_ALLOWED; // command not allowed return CommandRet::NOT_ALLOWED; // command not allowed
} }
auto description = Helpers::translated_word(cf->description_);
if ((value == nullptr) || (strlen(value) == 0)) { if ((value == nullptr) || (strlen(value) == 0)) {
if (EMSESP::system_.readonly_mode()) { if (EMSESP::system_.readonly_mode()) {
LOG_INFO(("[readonly] Calling command '%s/%s' (%s)"), dname.c_str(), cmd, cf->description_); LOG_INFO(("[readonly] Calling command '%s/%s' (%s)"), dname, cmd, description);
} else { } else {
LOG_DEBUG(("Calling command '%s/%s' (%s)"), dname.c_str(), cmd, cf->description_); LOG_DEBUG(("Calling command '%s/%s' (%s)"), dname, cmd, description);
} }
} else { } else {
if (EMSESP::system_.readonly_mode()) { if (EMSESP::system_.readonly_mode()) {
LOG_INFO(("[readonly] Calling command '%s/%s' (%s) with value %s"), dname.c_str(), cmd, cf->description_, value); LOG_INFO(("[readonly] Calling command '%s/%s' (%s) with value %s"), dname, cmd, description, value);
} else { } else {
LOG_DEBUG(("Calling command '%s/%s' (%s) with value %s"), dname.c_str(), cmd, cf->description_, value); LOG_DEBUG(("Calling command '%s/%s' (%s) with value %s"), dname, cmd, description, value);
} }
} }
@@ -299,7 +301,7 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char *
} }
// add a command to the list, which does not return json // add a command to the list, which does not return json
void Command::add(const uint8_t device_type, const char * cmd, const cmd_function_p cb, const char * description, uint8_t flags) { void Command::add(const uint8_t device_type, const char * cmd, const cmd_function_p cb, const char * const * description, uint8_t flags) {
// if the command already exists for that device type don't add it // if the command already exists for that device type don't add it
if (find_command(device_type, cmd) != nullptr) { if (find_command(device_type, cmd) != nullptr) {
return; return;
@@ -314,7 +316,7 @@ void Command::add(const uint8_t device_type, const char * cmd, const cmd_functio
} }
// add a command to the list, which does return a json object as output // add a command to the list, which does return a json object as output
void Command::add(const uint8_t device_type, const char * cmd, const cmd_json_function_p cb, const char * description, uint8_t flags) { void Command::add(const uint8_t device_type, const char * cmd, const cmd_json_function_p cb, const char * const * description, uint8_t flags) {
// if the command already exists for that device type don't add it // if the command already exists for that device type don't add it
if (find_command(device_type, cmd) != nullptr) { if (find_command(device_type, cmd) != nullptr) {
return; return;
@@ -348,7 +350,6 @@ Command::CmdFunction * Command::find_command(const uint8_t device_type, const ch
// list all commands for a specific device, output as json // list all commands for a specific device, output as json
bool Command::list(const uint8_t device_type, JsonObject & output) { bool Command::list(const uint8_t device_type, JsonObject & output) {
if (cmdfunctions_.empty()) { if (cmdfunctions_.empty()) {
output["message"] = "no commands available"; output["message"] = "no commands available";
return false; return false;
@@ -366,7 +367,7 @@ bool Command::list(const uint8_t device_type, JsonObject & output) {
for (const auto & cl : sorted_cmds) { for (const auto & cl : sorted_cmds) {
for (const auto & cf : cmdfunctions_) { for (const auto & cf : cmdfunctions_) {
if ((cf.device_type_ == device_type) && !cf.has_flags(CommandFlag::HIDDEN) && cf.description_ && (cl == std::string(cf.cmd_))) { if ((cf.device_type_ == device_type) && !cf.has_flags(CommandFlag::HIDDEN) && cf.description_ && (cl == std::string(cf.cmd_))) {
output[cl] = cf.description_; output[cl] = Helpers::translated_word(cf.description_);
} }
} }
} }
@@ -425,7 +426,7 @@ void Command::show(uuid::console::Shell & shell, uint8_t device_type, bool verbo
shell.print(EMSdevice::tag_to_string(DeviceValueTAG::TAG_DEVICE_DATA_WW)); shell.print(EMSdevice::tag_to_string(DeviceValueTAG::TAG_DEVICE_DATA_WW));
shell.print(' '); shell.print(' ');
} }
shell.print((cf.description_)); shell.print(Helpers::translated_word(cf.description_));
if (!cf.has_flags(CommandFlag::ADMIN_ONLY)) { if (!cf.has_flags(CommandFlag::ADMIN_ONLY)) {
shell.print(' '); shell.print(' ');
shell.print(COLOR_BRIGHT_RED); shell.print(COLOR_BRIGHT_RED);
@@ -475,19 +476,19 @@ bool Command::device_has_commands(const uint8_t device_type) {
// list sensors and EMS devices // list sensors and EMS devices
void Command::show_devices(uuid::console::Shell & shell) { void Command::show_devices(uuid::console::Shell & shell) {
shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::SYSTEM).c_str()); shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::SYSTEM));
if (EMSESP::dallassensor_.have_sensors()) { if (EMSESP::dallassensor_.have_sensors()) {
shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::DALLASSENSOR).c_str()); shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::DALLASSENSOR));
} }
if (EMSESP::analogsensor_.have_sensors()) { if (EMSESP::analogsensor_.have_sensors()) {
shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::ANALOGSENSOR).c_str()); shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::ANALOGSENSOR));
} }
for (const auto & device_class : EMSFactory::device_handlers()) { for (const auto & device_class : EMSFactory::device_handlers()) {
for (const auto & emsdevice : EMSESP::emsdevices) { for (const auto & emsdevice : EMSESP::emsdevices) {
if (emsdevice && (emsdevice->device_type() == device_class.first) && (device_has_commands(device_class.first))) { if (emsdevice && (emsdevice->device_type() == device_class.first) && (device_has_commands(device_class.first))) {
shell.printf("%s ", EMSdevice::device_type_2_device_name(device_class.first).c_str()); shell.printf("%s ", EMSdevice::device_type_2_device_name(device_class.first));
break; // we only want to show one (not multiple of the same device types) break; // we only want to show one (not multiple of the same device types)
} }
} }
@@ -503,7 +504,7 @@ void Command::show_all(uuid::console::Shell & shell) {
// show system first // show system first
shell.print(COLOR_BOLD_ON); shell.print(COLOR_BOLD_ON);
shell.print(COLOR_YELLOW); shell.print(COLOR_YELLOW);
shell.printf(" %s: ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::SYSTEM).c_str()); shell.printf(" %s: ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::SYSTEM));
shell.print(COLOR_RESET); shell.print(COLOR_RESET);
show(shell, EMSdevice::DeviceType::SYSTEM, true); show(shell, EMSdevice::DeviceType::SYSTEM, true);
@@ -511,14 +512,14 @@ void Command::show_all(uuid::console::Shell & shell) {
if (EMSESP::dallassensor_.have_sensors()) { if (EMSESP::dallassensor_.have_sensors()) {
shell.print(COLOR_BOLD_ON); shell.print(COLOR_BOLD_ON);
shell.print(COLOR_YELLOW); shell.print(COLOR_YELLOW);
shell.printf(" %s: ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::DALLASSENSOR).c_str()); shell.printf(" %s: ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::DALLASSENSOR));
shell.print(COLOR_RESET); shell.print(COLOR_RESET);
show(shell, EMSdevice::DeviceType::DALLASSENSOR, true); show(shell, EMSdevice::DeviceType::DALLASSENSOR, true);
} }
if (EMSESP::analogsensor_.have_sensors()) { if (EMSESP::analogsensor_.have_sensors()) {
shell.print(COLOR_BOLD_ON); shell.print(COLOR_BOLD_ON);
shell.print(COLOR_YELLOW); shell.print(COLOR_YELLOW);
shell.printf(" %s: ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::ANALOGSENSOR).c_str()); shell.printf(" %s: ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::ANALOGSENSOR));
shell.print(COLOR_RESET); shell.print(COLOR_RESET);
show(shell, EMSdevice::DeviceType::ANALOGSENSOR, true); show(shell, EMSdevice::DeviceType::ANALOGSENSOR, true);
} }
@@ -528,7 +529,7 @@ void Command::show_all(uuid::console::Shell & shell) {
if (Command::device_has_commands(device_class.first)) { if (Command::device_has_commands(device_class.first)) {
shell.print(COLOR_BOLD_ON); shell.print(COLOR_BOLD_ON);
shell.print(COLOR_YELLOW); shell.print(COLOR_YELLOW);
shell.printf(" %s: ", EMSdevice::device_type_2_device_name(device_class.first).c_str()); shell.printf(" %s: ", EMSdevice::device_type_2_device_name(device_class.first));
shell.print(COLOR_RESET); shell.print(COLOR_RESET);
show(shell, device_class.first, true); show(shell, device_class.first, true);
} }

View File

@@ -59,14 +59,14 @@ class Command {
const char * cmd_; const char * cmd_;
const cmd_function_p cmdfunction_; const cmd_function_p cmdfunction_;
const cmd_json_function_p cmdfunction_json_; const cmd_json_function_p cmdfunction_json_;
const char * description_; const char * const * description_;
CmdFunction(const uint8_t device_type, CmdFunction(const uint8_t device_type,
const uint8_t flags, const uint8_t flags,
const char * cmd, const char * cmd,
const cmd_function_p cmdfunction, const cmd_function_p cmdfunction,
const cmd_json_function_p cmdfunction_json, const cmd_json_function_p cmdfunction_json,
const char * description) const char * const * description)
: device_type_(device_type) : device_type_(device_type)
, flags_(flags) , flags_(flags)
, cmd_(cmd) , cmd_(cmd)
@@ -97,12 +97,18 @@ class Command {
static uint8_t call(const uint8_t device_type, const char * cmd, const char * value); static uint8_t call(const uint8_t device_type, const char * cmd, const char * value);
// with normal call back function taking a value and id // with normal call back function taking a value and id
static void static void add(const uint8_t device_type,
add(const uint8_t device_type, const char * cmd, const cmd_function_p cb, const char * description, uint8_t flags = CommandFlag::MQTT_SUB_FLAG_DEFAULT); const char * cmd,
const cmd_function_p cb,
const char * const * description,
uint8_t flags = CommandFlag::MQTT_SUB_FLAG_DEFAULT);
// callback function taking value, id and a json object for its output // callback function taking value, id and a json object for its output
static void static void add(const uint8_t device_type,
add(const uint8_t device_type, const char * cmd, const cmd_json_function_p cb, const char * description, uint8_t flags = CommandFlag::MQTT_SUB_FLAG_DEFAULT); const char * cmd,
const cmd_json_function_p cb,
const char * const * description,
uint8_t flags = CommandFlag::MQTT_SUB_FLAG_DEFAULT);
static void show_all(uuid::console::Shell & shell); static void show_all(uuid::console::Shell & shell);
static Command::CmdFunction * find_command(const uint8_t device_type, const char * cmd); static Command::CmdFunction * find_command(const uint8_t device_type, const char * cmd);

View File

@@ -277,15 +277,16 @@ void EMSESPShell::add_console_commands() {
[](Shell & shell, const std::vector<std::string> & arguments) { [](Shell & shell, const std::vector<std::string> & arguments) {
uint16_t watch_id = WATCH_ID_NONE; uint16_t watch_id = WATCH_ID_NONE;
// only use english commands, not the translations
if (!arguments.empty()) { if (!arguments.empty()) {
// get raw/pretty // get raw/pretty
if (arguments[0] == (F_(raw))) { if (arguments[0] == (F_(raw))) {
EMSESP::watch(EMSESP::WATCH_RAW); // raw EMSESP::watch(EMSESP::WATCH_RAW); // raw
} else if (arguments[0] == Helpers::translated_word(FL_(on), true) || arguments[0] == (FL_(on)[0])) { } else if (arguments[0] == (FL_(on)[0])) {
EMSESP::watch(EMSESP::WATCH_ON); // on EMSESP::watch(EMSESP::WATCH_ON); // on
} else if (arguments[0] == Helpers::translated_word(FL_(off), true) || arguments[0] == (FL_(off)[0])) { } else if (arguments[0] == (FL_(off)[0])) {
EMSESP::watch(EMSESP::WATCH_OFF); // off EMSESP::watch(EMSESP::WATCH_OFF); // off
} else if (arguments[0] == Helpers::translated_word(FL_(unknown), true) || arguments[0] == (FL_(unknown)[0])) { } else if (arguments[0] == (FL_(unknown)[0])) {
EMSESP::watch(EMSESP::WATCH_UNKNOWN); // unknown EMSESP::watch(EMSESP::WATCH_UNKNOWN); // unknown
watch_id = WATCH_ID_NONE; watch_id = WATCH_ID_NONE;
} else { } else {

View File

@@ -50,12 +50,12 @@ void DallasSensor::start() {
EMSdevice::DeviceType::DALLASSENSOR, EMSdevice::DeviceType::DALLASSENSOR,
F_(info), F_(info),
[&](const char * value, const int8_t id, JsonObject & output) { return command_info(value, id, output); }, [&](const char * value, const int8_t id, JsonObject & output) { return command_info(value, id, output); },
F_(info_cmd)); FL_(info_cmd));
Command::add( Command::add(
EMSdevice::DeviceType::DALLASSENSOR, EMSdevice::DeviceType::DALLASSENSOR,
F_(commands), F_(commands),
[&](const char * value, const int8_t id, JsonObject & output) { return command_commands(value, id, output); }, [&](const char * value, const int8_t id, JsonObject & output) { return command_commands(value, id, output); },
F_(commands_cmd)); FL_(commands_cmd));
Mqtt::subscribe(EMSdevice::DeviceType::DALLASSENSOR, "dallasssensor/#", nullptr); // use empty function callback Mqtt::subscribe(EMSdevice::DeviceType::DALLASSENSOR, "dallasssensor/#", nullptr); // use empty function callback
} }

View File

@@ -2227,7 +2227,7 @@ bool Boiler::set_maintenance(const char * value, const int8_t id) {
std::string s; std::string s;
if (Helpers::value2string(value, s)) { if (Helpers::value2string(value, s)) {
if (s == Helpers::translated_word(FL_(reset))) { if (s == std::string(Helpers::translated_word(FL_(reset)))) {
// LOG_INFO("Reset boiler maintenance message"); // LOG_INFO("Reset boiler maintenance message");
write_command(0x05, 0x08, 0xFF, 0x1C); write_command(0x05, 0x08, 0xFF, 0x1C);
return true; return true;

View File

@@ -594,7 +594,6 @@ void Thermostat::process_RC20Timer(std::shared_ptr<const Telegram> telegram) {
// we use EN settings for the day abbreviation // we use EN settings for the day abbreviation
std::string sday = (FL_(enum_dayOfWeek)[day][0]); std::string sday = (FL_(enum_dayOfWeek)[day][0]);
// std::string sday = Helpers::translated_word(FL_(enum_dayOfWeek)[day]);
if (day == 7) { if (day == 7) {
snprintf(data, sizeof(data), "%02d not_set", no); snprintf(data, sizeof(data), "%02d not_set", no);
@@ -802,19 +801,10 @@ void Thermostat::process_RC35wwTimer(std::shared_ptr<const Telegram> telegram) {
char data[sizeof(wwSwitchTime_)]; char data[sizeof(wwSwitchTime_)];
// we use EN settings for the day abbreviation // we use EN settings for the day abbreviation
std::string sday = (FL_(enum_dayOfWeek)[day][0]); std::string sday = (FL_(enum_dayOfWeek)[day][0]);
// std::string sday = Helpers::translated_word(FL_(enum_dayOfWeek)[day]);
if (day == 7) { if (day == 7) {
snprintf(data, sizeof(data), "%02d not_set", no); snprintf(data, sizeof(data), "%02d not_set", no);
} else { } else {
snprintf(data, snprintf(data, sizeof(data), "%02d %s %02d:%02d %s", no, sday.c_str(), time / 6, 10 * (time % 6), on ? "on" : "off");
sizeof(data),
"%02d %s %02d:%02d %s",
no,
sday.c_str(),
time / 6,
10 * (time % 6),
// on ? (Helpers::translated_word(FL_(on))).c_str() : (Helpers::translated_word(FL_(off))).c_str());
on ? "on" : "off");
} }
if (telegram->type_id == 0x38) { if (telegram->type_id == 0x38) {
has_update(wwSwitchTime_, data, sizeof(wwSwitchTime_)); has_update(wwSwitchTime_, data, sizeof(wwSwitchTime_));
@@ -1281,7 +1271,6 @@ void Thermostat::process_RC35Timer(std::shared_ptr<const Telegram> telegram) {
// we use EN settings for the day abbreviation // we use EN settings for the day abbreviation
std::string sday = (FL_(enum_dayOfWeek)[day][0]); std::string sday = (FL_(enum_dayOfWeek)[day][0]);
// std::string sday = Helpers::translated_word(FL_(enum_dayOfWeek)[day]);
if (day == 7) { if (day == 7) {
snprintf(data, sizeof(data), "%02d not_set", no); snprintf(data, sizeof(data), "%02d not_set", no);
} else if (model() == EMS_DEVICE_FLAG_RC30) { } else if (model() == EMS_DEVICE_FLAG_RC30) {
@@ -2220,82 +2209,93 @@ bool Thermostat::set_roominfl_factor(const char * value, const int8_t id) {
return true; return true;
} }
// sets the thermostat working mode, where mode is a string // sets the thermostat working mode
// converts string mode to HeatingCircuit::Mode
bool Thermostat::set_mode(const char * value, const int8_t id) { bool Thermostat::set_mode(const char * value, const int8_t id) {
if ((value == nullptr) || (strlen(value) >= 20)) { if ((value == nullptr) || (strlen(value) >= 20)) {
return false; return false;
} }
std::string mode; // first determine which enum we are using
const char * const ** mode_list = nullptr; // points to a translated list of modes
if (value[0] >= '0' && value[0] <= '9') { switch (model()) {
uint8_t num = value[0] - '0'; case EMSdevice::EMS_DEVICE_FLAG_RC10:
switch (model()) { mode_list = FL_(enum_mode6);
case EMSdevice::EMS_DEVICE_FLAG_RC10: break;
mode = Helpers::translated_word(FL_(enum_mode6)[num], true); case EMSdevice::EMS_DEVICE_FLAG_RC20:
break; case EMSdevice::EMS_DEVICE_FLAG_RC20_N:
case EMSdevice::EMS_DEVICE_FLAG_RC20: mode_list = FL_(enum_mode2);
case EMSdevice::EMS_DEVICE_FLAG_RC20_N: break;
mode = Helpers::translated_word(FL_(enum_mode2)[num], true); case EMSdevice::EMS_DEVICE_FLAG_RC25:
break; case EMSdevice::EMS_DEVICE_FLAG_RC30:
case EMSdevice::EMS_DEVICE_FLAG_RC25: case EMSdevice::EMS_DEVICE_FLAG_RC35:
case EMSdevice::EMS_DEVICE_FLAG_RC30: case EMSdevice::EMS_DEVICE_FLAG_RC30_N:
case EMSdevice::EMS_DEVICE_FLAG_RC35: mode_list = FL_(enum_mode3);
case EMSdevice::EMS_DEVICE_FLAG_RC30_N: break;
mode = Helpers::translated_word(FL_(enum_mode3)[num], true); case EMSdevice::EMS_DEVICE_FLAG_RC300:
break; case EMSdevice::EMS_DEVICE_FLAG_RC100:
case EMSdevice::EMS_DEVICE_FLAG_RC300: mode_list = FL_(enum_mode);
case EMSdevice::EMS_DEVICE_FLAG_RC100: break;
mode = Helpers::translated_word(FL_(enum_mode)[num], true); case EMSdevice::EMS_DEVICE_FLAG_JUNKERS:
break; mode_list = FL_(enum_mode4);
case EMSdevice::EMS_DEVICE_FLAG_JUNKERS: break;
mode = Helpers::translated_word(FL_(enum_mode4)[num], true); case EMSdevice::EMS_DEVICE_FLAG_CRF:
break; mode_list = FL_(enum_mode5);
case EMSdevice::EMS_DEVICE_FLAG_CRF: break;
mode = Helpers::translated_word(FL_(enum_mode5)[num], true); default:
break;
default:
return false;
}
} else if (!Helpers::value2string(value, mode)) {
return false; return false;
} }
uint8_t hc_num = (id == -1) ? AUTO_HEATING_CIRCUIT : id; uint8_t enum_index = 0;
if (Helpers::translated_word(FL_(off), true) == mode) { // check for a mode number as a string with a single digit (0..9)
return set_mode_n(HeatingCircuit::Mode::OFF, hc_num); if (value[0] >= '0' && value[0] <= '9') {
enum_index = value[0] - '0';
if (enum_index >= Helpers::count_items(mode_list)) {
return false; // invalid number, not in enum
}
} else {
// check for the mode being a full string name
if (!Helpers::value2enum(value, enum_index, mode_list)) {
return false; // not found
}
} }
if (Helpers::translated_word(FL_(manual), true) == mode) {
return set_mode_n(HeatingCircuit::Mode::MANUAL, hc_num); uint8_t hc_num = (id == -1) ? AUTO_HEATING_CIRCUIT : id; // heating circuit
}
if (Helpers::translated_word(FL_(auto), true) == mode) { // compare the english string
auto mode = mode_list[enum_index][0];
if (!strcmp(mode, FL_(auto)[0])) {
return set_mode_n(HeatingCircuit::Mode::AUTO, hc_num); return set_mode_n(HeatingCircuit::Mode::AUTO, hc_num);
} }
if (Helpers::translated_word(FL_(day), true) == mode) { if (!strcmp(mode, FL_(off)[0])) {
return set_mode_n(HeatingCircuit::Mode::OFF, hc_num);
}
if (!strcmp(mode, FL_(manual)[0])) {
return set_mode_n(HeatingCircuit::Mode::MANUAL, hc_num);
}
if (!strcmp(mode, FL_(day)[0])) {
return set_mode_n(HeatingCircuit::Mode::DAY, hc_num); return set_mode_n(HeatingCircuit::Mode::DAY, hc_num);
} }
if (Helpers::translated_word(FL_(night), true) == mode) { if (!strcmp(mode, FL_(night)[0])) {
return set_mode_n(HeatingCircuit::Mode::NIGHT, hc_num); return set_mode_n(HeatingCircuit::Mode::NIGHT, hc_num);
} }
if (Helpers::translated_word(FL_(heat), true) == mode) { if (!strcmp(mode, FL_(heat)[0])) {
return set_mode_n(HeatingCircuit::Mode::HEAT, hc_num); return set_mode_n(HeatingCircuit::Mode::HEAT, hc_num);
} }
if (Helpers::translated_word(FL_(nofrost), true) == mode) { if (!strcmp(mode, FL_(nofrost)[0])) {
return set_mode_n(HeatingCircuit::Mode::NOFROST, hc_num); return set_mode_n(HeatingCircuit::Mode::NOFROST, hc_num);
} }
if (Helpers::translated_word(FL_(eco), true) == mode) { if (!strcmp(mode, FL_(eco)[0])) {
return set_mode_n(HeatingCircuit::Mode::ECO, hc_num); return set_mode_n(HeatingCircuit::Mode::ECO, hc_num);
} }
if (Helpers::translated_word(FL_(holiday), true) == mode) { if (!strcmp(mode, FL_(holiday)[0])) {
return set_mode_n(HeatingCircuit::Mode::HOLIDAY, hc_num); return set_mode_n(HeatingCircuit::Mode::HOLIDAY, hc_num);
} }
if (Helpers::translated_word(FL_(comfort), true) == mode) { if (!strcmp(mode, FL_(comfort)[0])) {
return set_mode_n(HeatingCircuit::Mode::COMFORT, hc_num); return set_mode_n(HeatingCircuit::Mode::COMFORT, hc_num);
} }
return false; return false; // not found
} }
// Set the thermostat working mode // Set the thermostat working mode
@@ -2318,14 +2318,12 @@ bool Thermostat::set_mode_n(const uint8_t mode, const uint8_t hc_num) {
case HeatingCircuit::Mode::OFF: case HeatingCircuit::Mode::OFF:
set_mode_value = 0; set_mode_value = 0;
break; break;
case HeatingCircuit::Mode::DAY: case HeatingCircuit::Mode::DAY:
case HeatingCircuit::Mode::HEAT: case HeatingCircuit::Mode::HEAT:
case HeatingCircuit::Mode::MANUAL: case HeatingCircuit::Mode::MANUAL:
case HeatingCircuit::Mode::NOFROST: case HeatingCircuit::Mode::NOFROST:
set_mode_value = 1; set_mode_value = 1;
break; break;
default: // AUTO & ECO default: // AUTO & ECO
set_mode_value = 2; set_mode_value = 2;
break; break;
@@ -2690,11 +2688,6 @@ bool Thermostat::set_switchtime(const char * value, const uint16_t type_id, char
if (!strncmp(&value[3], (FL_(enum_dayOfWeek)[i][0]), 2)) { if (!strncmp(&value[3], (FL_(enum_dayOfWeek)[i][0]), 2)) {
day = i; day = i;
} }
// auto translated_dow = Helpers::translated_word(FL_(enum_dayOfWeek)[i]);
// if (!strncmp(&value[3], translated_dow.c_str(), translated_dow.length())) {
// day = i;
// }
} }
} }
if (strlen(value) > 10) { if (strlen(value) > 10) {
@@ -2734,14 +2727,12 @@ bool Thermostat::set_switchtime(const char * value, const uint16_t type_id, char
if (data[0] != 0xE7) { if (data[0] != 0xE7) {
// we use EN settings for the day abbreviation // we use EN settings for the day abbreviation
std::string sday = (FL_(enum_dayOfWeek)[day][0]); std::string sday = (FL_(enum_dayOfWeek)[day][0]);
// std::string sday = Helpers::translated_word(FL_(enum_dayOfWeek)[day]);
if (model() == EMS_DEVICE_FLAG_RC35 || model() == EMS_DEVICE_FLAG_RC30_N) { if (model() == EMS_DEVICE_FLAG_RC35 || model() == EMS_DEVICE_FLAG_RC30_N) {
snprintf(out, len, "%02d %s %02d:%02d %s", no, sday.c_str(), time / 6, 10 * (time % 6), on ? "on" : "off"); snprintf(out, len, "%02d %s %02d:%02d %s", no, sday.c_str(), time / 6, 10 * (time % 6), on ? "on" : "off");
} else if ((model() == EMS_DEVICE_FLAG_RC20) || (model() == EMS_DEVICE_FLAG_RC30)) { } else if ((model() == EMS_DEVICE_FLAG_RC20) || (model() == EMS_DEVICE_FLAG_RC30)) {
snprintf(out, len, "%02d %s %02d:%02d T%d", no, sday.c_str(), time / 6, 10 * (time % 6), on); snprintf(out, len, "%02d %s %02d:%02d T%d", no, sday.c_str(), time / 6, 10 * (time % 6), on);
} else { } else {
std::string son = (FL_(enum_switchmode)[on][0]); std::string son = (FL_(enum_switchmode)[on][0]);
// std::string son = Helpers::translated_word(FL_(enum_switchmode)[on]);
snprintf(out, len, "%02d %s %02d:%02d %s", no, sday.c_str(), time / 6, 10 * (time % 6), son.c_str()); snprintf(out, len, "%02d %s %02d:%02d %s", no, sday.c_str(), time / 6, 10 * (time % 6), son.c_str());
} }
} else { } else {

View File

@@ -81,7 +81,7 @@ std::string EMSdevice::brand_to_string() const {
} }
// returns the name of the MQTT topic to use for a specific device, without the base // returns the name of the MQTT topic to use for a specific device, without the base
std::string EMSdevice::device_type_2_device_name(const uint8_t device_type) { const char * EMSdevice::device_type_2_device_name(const uint8_t device_type) {
switch (device_type) { switch (device_type) {
case DeviceType::SYSTEM: case DeviceType::SYSTEM:
return (F_(system)); return (F_(system));
@@ -259,7 +259,7 @@ bool EMSdevice::has_tag(const uint8_t tag) const {
// called from the command 'entities' // called from the command 'entities'
void EMSdevice::list_device_entries(JsonObject & output) const { void EMSdevice::list_device_entries(JsonObject & output) const {
for (const auto & dv : devicevalues_) { for (const auto & dv : devicevalues_) {
std::string fullname = dv.get_fullname(); auto fullname = dv.get_fullname();
if (!dv.has_state(DeviceValueState::DV_WEB_EXCLUDE) && dv.type != DeviceValueType::CMD && !fullname.empty()) { if (!dv.has_state(DeviceValueState::DV_WEB_EXCLUDE) && dv.type != DeviceValueType::CMD && !fullname.empty()) {
// if we have a tag prefix it // if we have a tag prefix it
char key[50]; char key[50];
@@ -495,8 +495,7 @@ void EMSdevice::add_device_value(uint8_t tag,
} }
// add the command to our library // add the command to our library
// cmd is the short_name and the description is the fullname (not the custom fullname) Command::add(device_type_, short_name, f, fullname, flags);
Command::add(device_type_, short_name, f, Helpers::translated_fullname(fullname), flags);
} }
// single list of options // single list of options
@@ -638,9 +637,9 @@ void EMSdevice::publish_value(void * value_p) const {
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE]; char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
if (Mqtt::publish_single2cmd()) { if (Mqtt::publish_single2cmd()) {
if (dv.tag >= DeviceValueTAG::TAG_HC1) { if (dv.tag >= DeviceValueTAG::TAG_HC1) {
snprintf(topic, sizeof(topic), "%s/%s/%s", device_type_2_device_name(device_type_).c_str(), tag_to_mqtt(dv.tag).c_str(), (dv.short_name)); snprintf(topic, sizeof(topic), "%s/%s/%s", device_type_2_device_name(device_type_), tag_to_mqtt(dv.tag).c_str(), (dv.short_name));
} else { } else {
snprintf(topic, sizeof(topic), "%s/%s", device_type_2_device_name(device_type_).c_str(), (dv.short_name)); snprintf(topic, sizeof(topic), "%s/%s", device_type_2_device_name(device_type_), (dv.short_name));
} }
} else if (Mqtt::is_nested() && dv.tag >= DeviceValueTAG::TAG_HC1) { } else if (Mqtt::is_nested() && dv.tag >= DeviceValueTAG::TAG_HC1) {
snprintf(topic, sizeof(topic), "%s/%s/%s", Mqtt::tag_to_topic(device_type_, dv.tag).c_str(), tag_to_mqtt(dv.tag).c_str(), (dv.short_name)); snprintf(topic, sizeof(topic), "%s/%s/%s", Mqtt::tag_to_topic(device_type_, dv.tag).c_str(), tag_to_mqtt(dv.tag).c_str(), (dv.short_name));
@@ -663,7 +662,7 @@ void EMSdevice::publish_value(void * value_p) const {
Helpers::render_value(payload, *(uint8_t *)(value_p), 0); Helpers::render_value(payload, *(uint8_t *)(value_p), 0);
} else { } else {
auto enum_str = Helpers::translated_word(dv.options[*(uint8_t *)(value_p)]); auto enum_str = Helpers::translated_word(dv.options[*(uint8_t *)(value_p)]);
strlcpy(payload, enum_str.c_str(), sizeof(payload)); strlcpy(payload, enum_str, sizeof(payload));
} }
} }
break; break;
@@ -824,7 +823,7 @@ void EMSdevice::generate_values_web(JsonObject & output) {
JsonArray l = obj.createNestedArray("l"); JsonArray l = obj.createNestedArray("l");
for (uint8_t i = 0; i < dv.options_size; i++) { for (uint8_t i = 0; i < dv.options_size; i++) {
auto enum_str = Helpers::translated_word(dv.options[i]); auto enum_str = Helpers::translated_word(dv.options[i]);
if (!enum_str.empty()) { if (enum_str) {
l.add(enum_str); l.add(enum_str);
} }
} }
@@ -918,12 +917,12 @@ void EMSdevice::generate_values_web_customization(JsonArray & output) {
// don't add the fullname if its a command // don't add the fullname if its a command
auto fullname = Helpers::translated_word(dv.fullname); auto fullname = Helpers::translated_word(dv.fullname);
if (dv.type != DeviceValueType::CMD) { if (dv.type != DeviceValueType::CMD) {
if (!fullname.empty()) { if (fullname) {
if ((dv.tag == DeviceValueTAG::TAG_NONE) || tag_to_string(dv.tag).empty()) { if ((dv.tag == DeviceValueTAG::TAG_NONE) || tag_to_string(dv.tag).empty()) {
obj["n"] = fullname; obj["n"] = fullname;
} else { } else {
char name[50]; char name[50];
snprintf(name, sizeof(name), "%s %s", tag_to_string(dv.tag).c_str(), fullname.c_str()); snprintf(name, sizeof(name), "%s %s", tag_to_string(dv.tag).c_str(), fullname);
obj["n"] = name; obj["n"] = name;
} }
} }
@@ -934,7 +933,7 @@ void EMSdevice::generate_values_web_customization(JsonArray & output) {
obj["cn"] = custom_fullname; obj["cn"] = custom_fullname;
} }
} else { } else {
obj["n"] = "!" + fullname; // prefix commands with a ! obj["n"] = "!" + std::string(fullname); // prefix commands with a !
} }
// add the custom name, is optional // add the custom name, is optional
@@ -1363,11 +1362,11 @@ bool EMSdevice::generate_values(JsonObject & output, const uint8_t tag_filter, c
sizeof(time_s), sizeof(time_s),
"%d %s %d %s %d %s", "%d %s %d %s %d %s",
(time_value / 1440), (time_value / 1440),
Helpers::translated_word(FL_(days)).c_str(), Helpers::translated_word(FL_(days)),
((time_value % 1440) / 60), ((time_value % 1440) / 60),
Helpers::translated_word(FL_(hours)).c_str(), Helpers::translated_word(FL_(hours)),
(time_value % 60), (time_value % 60),
Helpers::translated_word(FL_(minutes)).c_str()); Helpers::translated_word(FL_(minutes)));
json[name] = time_s; json[name] = time_s;
} else { } else {
json[name] = time_value; json[name] = time_value;

View File

@@ -46,11 +46,11 @@ class EMSdevice {
std::string device_type_name() const; std::string device_type_name() const;
static std::string device_type_2_device_name(const uint8_t device_type); static const char * device_type_2_device_name(const uint8_t device_type);
static uint8_t device_name_2_device_type(const char * topic); static uint8_t device_name_2_device_type(const char * topic);
static std::string uom_to_string(uint8_t uom); static std::string uom_to_string(uint8_t uom);
static std::string tag_to_string(uint8_t tag); static std::string tag_to_string(uint8_t tag);
static std::string tag_to_mqtt(uint8_t tag); static std::string tag_to_mqtt(uint8_t tag);
bool has_tag(const uint8_t tag) const; bool has_tag(const uint8_t tag) const;

View File

@@ -74,7 +74,7 @@ DeviceValue::DeviceValue(uint8_t device_type,
Serial.print(custom_fullname.c_str()); Serial.print(custom_fullname.c_str());
Serial.print(COLOR_RESET); Serial.print(COLOR_RESET);
} else { } else {
Serial.print(Helpers::translated_word(fullname).c_str()); Serial.print(Helpers::translated_word(fullname));
} }
Serial.print(" (#options="); Serial.print(" (#options=");
Serial.print(options_size); Serial.print(options_size);
@@ -88,7 +88,7 @@ DeviceValue::DeviceValue(uint8_t device_type,
Serial.print(i + 1); Serial.print(i + 1);
Serial.print(":"); Serial.print(":");
auto str = Helpers::translated_word(options[i]); auto str = Helpers::translated_word(options[i]);
Serial.print((str.c_str())); Serial.print(str);
i++; i++;
} }
} else if (options_single != nullptr) { } else if (options_single != nullptr) {

View File

@@ -1039,7 +1039,7 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, const
fetch_device_values(device_id); // go and fetch its data fetch_device_values(device_id); // go and fetch its data
// Print to LOG showing we've added a new device // Print to LOG showing we've added a new device
LOG_INFO("Recognized new %s with deviceID 0x%02X", EMSdevice::device_type_2_device_name(device_type).c_str(), device_id); LOG_INFO("Recognized new %s with deviceID 0x%02X", EMSdevice::device_type_2_device_name(device_type), device_id);
// add command commands for all devices, except for connect, controller and gateway // add command commands for all devices, except for connect, controller and gateway
if ((device_type == DeviceType::CONNECT) || (device_type == DeviceType::CONTROLLER) || (device_type == DeviceType::GATEWAY)) { if ((device_type == DeviceType::CONNECT) || (device_type == DeviceType::CONTROLLER) || (device_type == DeviceType::GATEWAY)) {
@@ -1052,7 +1052,7 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, const
[device_type](const char * value, const int8_t id, JsonObject & output) { [device_type](const char * value, const int8_t id, JsonObject & output) {
return command_info(device_type, output, id, EMSdevice::OUTPUT_TARGET::API_VERBOSE); return command_info(device_type, output, id, EMSdevice::OUTPUT_TARGET::API_VERBOSE);
}, },
F_(info_cmd)); FL_(info_cmd));
Command::add( Command::add(
device_type, device_type,
("values"), ("values"),
@@ -1065,15 +1065,16 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, const
device_type, device_type,
F_(commands), F_(commands),
[device_type](const char * value, const int8_t id, JsonObject & output) { return command_commands(device_type, output, id); }, [device_type](const char * value, const int8_t id, JsonObject & output) { return command_commands(device_type, output, id); },
F_(commands_cmd)); FL_(commands_cmd));
Command::add( Command::add(
device_type, device_type,
F_(entities), F_(entities),
[device_type](const char * value, const int8_t id, JsonObject & output) { return command_entities(device_type, output, id); }, [device_type](const char * value, const int8_t id, JsonObject & output) { return command_entities(device_type, output, id); },
F_(entities_cmd)); FL_(entities_cmd));
// MQTT subscribe to the device e.g. "ems-esp/boiler/#" // MQTT subscribe to the device e.g. "ems-esp/boiler/#"
Mqtt::subscribe(device_type, EMSdevice::device_type_2_device_name(device_type) + "/#", nullptr); auto topic = std::string(EMSdevice::device_type_2_device_name(device_type)) + "/#";
Mqtt::subscribe(device_type, topic, nullptr);
return true; return true;
} }

View File

@@ -179,9 +179,9 @@ char * Helpers::render_boolean(char * result, const bool value, const bool dashb
uint8_t bool_format_ = dashboard ? EMSESP::system_.bool_dashboard() : EMSESP::system_.bool_format(); uint8_t bool_format_ = dashboard ? EMSESP::system_.bool_dashboard() : EMSESP::system_.bool_format();
if (bool_format_ == BOOL_FORMAT_ONOFF_STR) { if (bool_format_ == BOOL_FORMAT_ONOFF_STR) {
strlcpy(result, value ? translated_word(FL_(on)).c_str() : translated_word(FL_(off)).c_str(), 5); strlcpy(result, value ? translated_word(FL_(on)) : translated_word(FL_(off)), 5);
} else if (bool_format_ == BOOL_FORMAT_ONOFF_STR_CAP) { } else if (bool_format_ == BOOL_FORMAT_ONOFF_STR_CAP) {
strlcpy(result, value ? translated_word(FL_(ON)).c_str() : translated_word(FL_(OFF)).c_str(), 5); strlcpy(result, value ? translated_word(FL_(ON)) : translated_word(FL_(OFF)), 5);
} else if ((bool_format_ == BOOL_FORMAT_10) || (bool_format_ == BOOL_FORMAT_10_STR)) { } else if ((bool_format_ == BOOL_FORMAT_10) || (bool_format_ == BOOL_FORMAT_10_STR)) {
strlcpy(result, value ? "1" : "0", 2); strlcpy(result, value ? "1" : "0", 2);
} else { } else {
@@ -593,12 +593,12 @@ bool Helpers::value2bool(const char * value, bool & value_b) {
std::string bool_str = toLower(value); // convert to lower case std::string bool_str = toLower(value); // convert to lower case
if ((bool_str == Helpers::translated_word(FL_(on))) || (bool_str == "on") || (bool_str == "1") || (bool_str == "true")) { if ((bool_str == std::string(Helpers::translated_word(FL_(on)))) || (bool_str == "on") || (bool_str == "1") || (bool_str == "true")) {
value_b = true; value_b = true;
return true; // is a bool return true; // is a bool
} }
if ((bool_str == Helpers::translated_word(FL_(off))) || (bool_str == "off") || (bool_str == "0") || (bool_str == "false")) { if ((bool_str == std::string(Helpers::translated_word(FL_(off)))) || (bool_str == "off") || (bool_str == "0") || (bool_str == "false")) {
value_b = false; value_b = false;
return true; // is a bool return true; // is a bool
} }
@@ -615,7 +615,7 @@ bool Helpers::value2enum(const char * value, uint8_t & value_ui, const char * co
std::string str = toLower(value); std::string str = toLower(value);
for (value_ui = 0; strs[value_ui]; value_ui++) { for (value_ui = 0; strs[value_ui]; value_ui++) {
std::string str1 = toLower(Helpers::translated_word(strs[value_ui])); std::string str1 = toLower(std::string(Helpers::translated_word(strs[value_ui])));
std::string str2 = toLower((strs[value_ui][0])); // also check for default language std::string str2 = toLower((strs[value_ui][0])); // also check for default language
if ((str1 != "") if ((str1 != "")
&& ((str2 == "off" && str == "false") || (str2 == "on" && str == "true") || (str == str1) || (str == str2) && ((str2 == "off" && str == "false") || (str2 == "on" && str == "true") || (str == str1) || (str == str2)
@@ -627,19 +627,25 @@ bool Helpers::value2enum(const char * value, uint8_t & value_ui, const char * co
return false; return false;
} }
// checks to see if a string is member of a vector and return the index, also allow true/false for on/off // finds the string (value) of a list vector (strs)
// returns true if found, and sets the value_ui to the index, else false
// also allow true/false for on/off
bool Helpers::value2enum(const char * value, uint8_t & value_ui, const char * const * strs) { bool Helpers::value2enum(const char * value, uint8_t & value_ui, const char * const * strs) {
if ((value == nullptr) || (strlen(value) == 0)) { if ((value == nullptr) || (strlen(value) == 0)) {
return false; return false;
} }
std::string str = toLower(value); std::string str = toLower(value);
std::string s_on = Helpers::translated_word(FL_(on));
std::string s_off = Helpers::translated_word(FL_(off));
// stops when a nullptr is found, which is the end delimeter of a MAKE_PSTR_LIST()
// could use count_items() to avoid buffer over-run but this works
for (value_ui = 0; strs[value_ui]; value_ui++) { for (value_ui = 0; strs[value_ui]; value_ui++) {
std::string enum_str = toLower((strs[value_ui])); std::string enum_str = toLower((strs[value_ui]));
if ((enum_str != "") if ((enum_str != "")
&& ((enum_str == "off" && (str == Helpers::translated_word(FL_(off)) || str == "false")) && ((enum_str == "off" && (str == s_off || str == "false")) || (enum_str == "on" && (str == s_on || str == "true")) || (str == enum_str)
|| (enum_str == "on" && (str == Helpers::translated_word(FL_(on)) || str == "true")) || (str == enum_str)
|| (value[0] == ('0' + value_ui) && value[1] == '\0'))) { || (value[0] == ('0' + value_ui) && value[1] == '\0'))) {
return true; return true;
} }
@@ -702,31 +708,13 @@ uint8_t Helpers::count_items(const char * const ** list) {
return list_size; return list_size;
} }
// return translated string as a std::string, optionally converting to lowercase (for console commands)
std::string Helpers::translated_word(const char * const * strings, bool to_lower) {
uint8_t language_index = EMSESP::system_.language_index();
uint8_t index = 0;
// check for empty
if (!strings) {
return ""; // it's a nullptr with no translations, return empty to prevent unwanted crash
}
// see how many translations we have for this entity. if there is no translation for this, revert to EN
if (Helpers::count_items(strings) >= language_index + 1 && strlen(strings[language_index])) {
index = language_index;
}
return to_lower ? toLower((strings[index])) : (strings[index]);
}
// returns char pointer to translated description or fullname // returns char pointer to translated description or fullname
const char * Helpers::translated_fullname(const char * const * strings) { const char * Helpers::translated_word(const char * const * strings) {
uint8_t language_index = EMSESP::system_.language_index(); uint8_t language_index = EMSESP::system_.language_index();
uint8_t index = 0; uint8_t index = 0;
// check for empty
if (!strings) { if (!strings) {
return nullptr; // it's a nullptr with no translations, return empty to prevent unwanted crash return ""; // no translations
} }
// see how many translations we have for this entity. if there is no translation for this, revert to EN // see how many translations we have for this entity. if there is no translation for this, revert to EN

View File

@@ -77,9 +77,7 @@ class Helpers {
static uint8_t count_items(const char * const ** list); static uint8_t count_items(const char * const ** list);
static uint8_t count_items(const char * const * list); static uint8_t count_items(const char * const * list);
static std::string translated_word(const char * const * strings, bool to_lower = false); static const char * translated_word(const char * const * strings);
static const char * translated_fullname(const char * const * strings);
#ifdef EMSESP_STANDALONE #ifdef EMSESP_STANDALONE
static char * ultostr(char * ptr, uint32_t value, const uint8_t base); static char * ultostr(char * ptr, uint32_t value, const uint8_t base);

View File

@@ -219,11 +219,6 @@ MAKE_PSTR(uom_sqm, "sqm")
MAKE_PSTR(uom_m3, "m3") MAKE_PSTR(uom_m3, "m3")
MAKE_PSTR(uom_l, "l") MAKE_PSTR(uom_l, "l")
// commands
MAKE_PSTR(info_cmd, "lists all values")
MAKE_PSTR(commands_cmd, "lists all commands")
MAKE_PSTR(entities_cmd, "lists all entities")
// TAG mapping - maps to DeviceValueTAG_s in emsdevice.cpp // TAG mapping - maps to DeviceValueTAG_s in emsdevice.cpp
// use empty string if want to suppress showing tags // use empty string if want to suppress showing tags
// mqtt tags must not have spaces // mqtt tags must not have spaces

View File

@@ -28,9 +28,26 @@
#define EMSESP_LOCALE_PL "pl" #define EMSESP_LOCALE_PL "pl"
#define EMSESP_LOCALE_NO "no" #define EMSESP_LOCALE_NO "no"
// translations are in order en, de,nl, se.... // translations are in order en, de, nl, se, pl, no, ....
// if there is no translation, it will default to en // if there is no translation, it will default to en
// commands
MAKE_PSTR_LIST(info_cmd, "lists all values")
MAKE_PSTR_LIST(commands_cmd, "lists all commands")
MAKE_PSTR_LIST(entities_cmd, "lists all entities")
MAKE_PSTR_LIST(send_cmd, "send a telegram")
MAKE_PSTR_LIST(setiovalue_cmd, "set io value")
MAKE_PSTR_LIST(changeloglevel_cmd, "change log level")
MAKE_PSTR_LIST(fetch_cmd, "refresh all EMS values")
MAKE_PSTR_LIST(restart_cmd, "restart EMS-ESP")
MAKE_PSTR_LIST(watch_cmd, "watch incoming telegrams")
MAKE_PSTR_LIST(publish_cmd, "publish all to MQTT")
MAKE_PSTR_LIST(system_info_cmd, "show system status")
#if defined(EMSESP_DEBUG)
MAKE_PSTR_LIST(test_cmd, "run a test")
#endif
// General // General
MAKE_PSTR_LIST(on, "on", "an", "aan", "") MAKE_PSTR_LIST(on, "on", "an", "aan", "")
MAKE_PSTR_LIST(off, "off", "aus", "uit", "av") MAKE_PSTR_LIST(off, "off", "aus", "uit", "av")

View File

@@ -899,15 +899,16 @@ void Mqtt::publish_ha_sensor_config(DeviceValue & dv, const std::string & model,
StaticJsonDocument<EMSESP_JSON_SIZE_HA_CONFIG> dev_json; StaticJsonDocument<EMSESP_JSON_SIZE_HA_CONFIG> dev_json;
// always create the ids // always create the ids
JsonArray ids = dev_json.createNestedArray("ids"); JsonArray ids = dev_json.createNestedArray("ids");
char ha_device[40]; char ha_device[40];
std::string device_type_name = EMSdevice::device_type_2_device_name(dv.device_type); auto device_type_name = EMSdevice::device_type_2_device_name(dv.device_type);
snprintf(ha_device, sizeof(ha_device), "ems-esp-%s", device_type_name.c_str()); snprintf(ha_device, sizeof(ha_device), "ems-esp-%s", device_type_name);
ids.add(ha_device); ids.add(ha_device);
if (create_device_config) { if (create_device_config) {
device_type_name[0] = toupper(device_type_name[0]); // capitalize auto cap_name = strdup(device_type_name);
dev_json["name"] = "EMS-ESP " + device_type_name; cap_name[0] = toupper(cap_name[0]); // capitalize
dev_json["name"] = std::string("EMS-ESP ") + cap_name;
dev_json["mf"] = brand; dev_json["mf"] = brand;
dev_json["mdl"] = model; dev_json["mdl"] = model;
dev_json["via_device"] = "ems-esp"; dev_json["via_device"] = "ems-esp";
@@ -972,8 +973,7 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdevice
} }
// create the device name // create the device name
char device_name[50]; auto device_name = EMSdevice::device_type_2_device_name(device_type);
strlcpy(device_name, EMSdevice::device_type_2_device_name(device_type).c_str(), sizeof(device_name));
// create entity by add the hc/wwc tag if present, separating with a . // create entity by add the hc/wwc tag if present, separating with a .
char new_entity[50]; char new_entity[50];
@@ -1341,11 +1341,13 @@ std::string Mqtt::tag_to_topic(uint8_t device_type, uint8_t tag) {
return EMSdevice::tag_to_mqtt(tag); return EMSdevice::tag_to_mqtt(tag);
} }
std::string topic = EMSdevice::device_type_2_device_name(device_type);
// if there is a tag add it // if there is a tag add it
if (!EMSdevice::tag_to_mqtt(tag).empty() && ((tag == DeviceValueTAG::TAG_BOILER_DATA_WW) || (!is_nested() && tag >= DeviceValueTAG::TAG_HC1))) { if (!EMSdevice::tag_to_mqtt(tag).empty() && ((tag == DeviceValueTAG::TAG_BOILER_DATA_WW) || (!is_nested() && tag >= DeviceValueTAG::TAG_HC1))) {
return EMSdevice::device_type_2_device_name(device_type) + "_data_" + EMSdevice::tag_to_mqtt(tag); return topic + "_data_" + EMSdevice::tag_to_mqtt(tag);
} else { } else {
return EMSdevice::device_type_2_device_name(device_type) + "_data"; return topic + "_data";
} }
} }

View File

@@ -249,8 +249,7 @@ void System::syslog_init() {
syslog_.hostname(hostname().c_str()); syslog_.hostname(hostname().c_str());
// register the command // register the command
// TODO translate this Command::add(EMSdevice::DeviceType::SYSTEM, F_(syslog), System::command_syslog_level, FL_(changeloglevel_cmd), CommandFlag::ADMIN_ONLY);
Command::add(EMSdevice::DeviceType::SYSTEM, F_(syslog), System::command_syslog_level, ("change the syslog level"), CommandFlag::ADMIN_ONLY);
} else if (was_enabled) { } else if (was_enabled) {
// in case service is still running, this flushes the queue // in case service is still running, this flushes the queue
@@ -664,25 +663,21 @@ void System::system_check() {
// commands - takes static function pointers // commands - takes static function pointers
void System::commands_init() { void System::commands_init() {
// TODO translate this Command::add(EMSdevice::DeviceType::SYSTEM, F_(send), System::command_send, FL_(send_cmd), CommandFlag::ADMIN_ONLY);
Command::add(EMSdevice::DeviceType::SYSTEM, F_(send), System::command_send, ("send a telegram"), CommandFlag::ADMIN_ONLY); Command::add(EMSdevice::DeviceType::SYSTEM, F_(fetch), System::command_fetch, FL_(fetch_cmd), CommandFlag::ADMIN_ONLY);
Command::add(EMSdevice::DeviceType::SYSTEM, F_(fetch), System::command_fetch, ("refresh all EMS values"), CommandFlag::ADMIN_ONLY); Command::add(EMSdevice::DeviceType::SYSTEM, F_(restart), System::command_restart, FL_(restart_cmd), CommandFlag::ADMIN_ONLY);
Command::add(EMSdevice::DeviceType::SYSTEM, F_(restart), System::command_restart, ("restart EMS-ESP"), CommandFlag::ADMIN_ONLY); Command::add(EMSdevice::DeviceType::SYSTEM, F_(watch), System::command_watch, FL_(watch_cmd));
Command::add(EMSdevice::DeviceType::SYSTEM, F_(watch), System::command_watch, ("watch incoming telegrams"));
// register syslog command in syslog init
// Command::add(EMSdevice::DeviceType::SYSTEM, F_(syslog), System::command_syslog_level, ("set syslog level"), CommandFlag::ADMIN_ONLY);
if (Mqtt::enabled()) { if (Mqtt::enabled()) {
Command::add(EMSdevice::DeviceType::SYSTEM, F_(publish), System::command_publish, ("force a MQTT publish")); Command::add(EMSdevice::DeviceType::SYSTEM, F_(publish), System::command_publish, FL_(publish_cmd));
} }
// these commands will return data in JSON format // these commands will return data in JSON format
Command::add(EMSdevice::DeviceType::SYSTEM, F_(info), System::command_info, ("show system status")); Command::add(EMSdevice::DeviceType::SYSTEM, F_(info), System::command_info, FL_(system_info_cmd));
Command::add(EMSdevice::DeviceType::SYSTEM, F_(commands), System::command_commands, ("fetch system commands")); Command::add(EMSdevice::DeviceType::SYSTEM, F_(commands), System::command_commands, FL_(commands_cmd));
#if defined(EMSESP_DEBUG) #if defined(EMSESP_DEBUG)
Command::add(EMSdevice::DeviceType::SYSTEM, ("test"), System::command_test, ("run a specific test")); Command::add(EMSdevice::DeviceType::SYSTEM, ("test"), System::command_test, FL_(test_cmd));
#endif #endif
// MQTT subscribe "ems-esp/system/#" // MQTT subscribe "ems-esp/system/#"

View File

@@ -246,6 +246,14 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
shell.invoke_command("show mqtt"); shell.invoke_command("show mqtt");
} }
if (command == "modes") {
shell.printfln("Testing thermostat modes...");
run_test("general");
shell.invoke_command("call thermostat mode auto");
shell.invoke_command("call thermostat mode Manuell"); // DE
shell.invoke_command("call thermostat mode 1");
}
if (command == "render") { if (command == "render") {
shell.printfln("Testing render..."); shell.printfln("Testing render...");