This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Яндекс Алиса (Yandex Alice)
#61
Всем привет. Несколько уточнений. Учетки от сторонних сервисов работают. Адрес сети может отличаться от remote.logicmachine.net. решил проблему с управлением, правда через костыль. в демона добавил строчку grp.write(groupaddress, data) в случае mapping[groupaddress].init = true

if not mapping[groupaddress].from_bus or os.time()-mapping[groupaddress].from_bus>1 then
if mapping[groupaddress].init then
log("grp write 1", groupaddress, data, mapping[groupaddress])
grp.write(groupaddress, data)
mapping[groupaddress].init = nil
else
log("grp write 2", groupaddress, data)
grp.write(groupaddress, data)


у меня init всегда true и от чего зависит этот атрибут, я не понял.
* table:
["from_bus"]
* number: хххххххххх
["init"]
* bool: true
["dt"]
* number: 1001
["actor"]
* bool: true
вот пример приходящего массива. может кто то знает что это за атрибут и как его корректно в false перевести?

Еще есть вопрос по умению

по умению плагина Yandex управление домом в LM "Температура света в кельвинах" какие типы данных он поддерживает? по наблюдениям только scale, а это 1 байт. температура в кельвинах требует от 2-х байт. Сделал виртуальный адрес и скрипт преобразующий scale в кельвины, но умение не видит этот адрес.
Reply
#62
@kilkams, we can't provide any support with Yandex integration. It is done by a third-party developer who is not active in our forums.
You can try asking your questions in logicmachinerus Telegram group.
Reply
#63
(16.10.2024, 10:48)admin Wrote: @kilkams, we can't provide any support with Yandex integration. It is done by a third-party developer who is not active in our forums.
You can try asking your questions in logicmachinerus Telegram group.

Спасибо, в группе телеграма уже общаюсь.

отвечаю на свой 2-й вопрос.
в файле /www/apps/data/yandex2/lua/lib.lua нужно заменить dt=5 на dt=7.
dictSkills["color_setting.temperature_k"] = {name="Температура света в кельвинах", dt=7, fields={{key="min", name="Минимальное значение", type="number"}, {key="max", name="Максимальное значение", type="number"}}}
Reply
#64
А чего вы на русском общаетесь? Неприлично. Надо на международном языке
Reply
#65
(16.10.2024, 10:31)kilkams Wrote: Всем привет. Несколько уточнений. Учетки от сторонних сервисов работают. Адрес сети может отличаться от remote.logicmachine.net. решил проблему с управлением, правда через костыль. в демона добавил строчку grp.write(groupaddress, data) в случае mapping[groupaddress].init = true

if not mapping[groupaddress].from_bus or os.time()-mapping[groupaddress].from_bus>1 then
if mapping[groupaddress].init then
                                                log("grp write 1", groupaddress, data, mapping[groupaddress])
grp.write(groupaddress, data)
mapping[groupaddress].init = nil
else
log("grp write 2", groupaddress, data)
grp.write(groupaddress, data)


у меня init всегда true и от чего зависит этот атрибут, я не понял.
  * table:
  ["from_bus"]
    * number: хххххххххх
  ["init"]
    * bool: true
  ["dt"]
    * number: 1001
  ["actor"]
    * bool: true
вот пример приходящего массива. может кто то знает что это за атрибут и как его корректно в false перевести?

Еще есть вопрос по умению

по умению плагина Yandex управление домом в LM "Температура света в кельвинах" какие типы данных он поддерживает? по наблюдениям только scale, а это 1 байт. температура в кельвинах требует от 2-х байт. Сделал виртуальный адрес и скрипт преобразующий scale в кельвины, но умение не видит этот адрес.

Answering a question about Kelvin.
Problem description:
The current structure separates color_setting.color_model and color_setting.temperature_k as separate skills, but according to the Yandex API, they should be in a single capability with the type devices.capabilities.color_setting.
Solution:
Replace the function in the /data/apps/store/daemon/yandex2/daemon.lua file. function get_devices(all)

Code:
function get_devices(all)
    local result = {}

    if redis:exists(name_devices2) then
        local devices = redis:hgetall(name_devices2)

        for id, device in pairs(devices) do
            device = json.pdecode(device)

            if type(device) == "table" and device.name then
                device.id = id
                
                -- Группируем skills по типам capabilities
                local capabilities_map = {}
                local simple_capabilities = {}
                
                if type(device.skills) == "table" then
                    for skill_id, s in pairs(device.skills) do
                        if all then
                            local skill = {id=skill_id}
                            local has_act = false
                            local has_status = false
                            
                            -- Обработка act
                            if s.act then
                                local addr = grp.find(s.act)
                                if addr then
                                    if not mapping[s.act] then
                                        mapping[s.act] = {dt = addr.datatype}
                                    end
                                    mapping[s.act].actor = true
                                    mapping[s.act].init = true
                                    mapping[s.act].value = grp.getvalue(addr)
                                    skill.act = s.act
                                    has_act = true
                                end
                            end
                            
                            -- Обработка status
                            if s.status then
                                local addr = grp.find(s.status)
                                if addr then
                                    if not mapping[s.status] then
                                        mapping[s.status] = {dt = addr.datatype}
                                    end
                                    mapping[s.status].status = true
                                    mapping[s.status].value = grp.getvalue(s.status)
                                    skill.status = s.status
                                    skill.value = grp.getvalue(s.status)
                                    has_status = true
                                end                                 
                            end
                            
                            skill.f = s.f
                            
                            -- Проверяем, относится ли skill к color_setting
                            if skill_id:match("^color_setting%.") then
                                local param_name = skill_id:match("^color_setting%.(.+)$")
                                
                                if not capabilities_map.color_setting then
                                    capabilities_map.color_setting = {
                                        type = "color_setting",
                                        parameters = {}
                                    }
                                end
                                
                                -- Добавляем параметр в color_setting
                                if param_name == "temperature_k" then
                                    if type(skill.f) == "table" and skill.f.min and skill.f.max then
                                        capabilities_map.color_setting.parameters.temperature_k = {
                                            min = skill.f.min,
                                            max = skill.f.max
                                        }
                                        if skill.f.precision then
                                            capabilities_map.color_setting.parameters.temperature_k.precision = skill.f.precision
                                        end
                                    end
                                elseif param_name == "color_model" then
                                    capabilities_map.color_setting.parameters.color_model = "hsv" -- или "rgb"
                                end
                                
                                -- Сохраняем адреса для управления
                                if has_act or has_status then
                                    if not capabilities_map.color_setting.addresses then
                                        capabilities_map.color_setting.addresses = {}
                                    end
                                    capabilities_map.color_setting.addresses[param_name] = {
                                        act = skill.act,
                                        status = skill.status,
                                        value = skill.value,
                                        f = skill.f
                                    }
                                end
                                
                            else
                                -- Обычный skill, не относящийся к color_setting
                                if has_act or has_status then
                                    table.insert(simple_capabilities, skill)
                                end
                            end
                        else
                            -- Режим для UI (не all)
                            table.insert(simple_capabilities, skill_id)
                        end
                    end
                    
                    -- Формируем итоговый массив skills
                    if all then
                        local skills = {}
                        
                        -- Добавляем сгруппированные capabilities
                        for cap_type, cap_data in pairs(capabilities_map) do
                            table.insert(skills, cap_data)
                        end
                        
                        -- Добавляем обычные skills
                        for _, skill in ipairs(simple_capabilities) do
                            table.insert(skills, skill)
                        end
                        
                        device.skills = skills
                    else
                        device.skills = simple_capabilities
                    end
                else
                    device.skills = {}
                end

                table.insert(result, device)
            end
        end
    end

    return result
end

You can now change the backlight temperature via Yandex. Unfortunately, only the values in the table are available. A couple of event scripts are required to convert from % to Kelvin and back.
Code:
Огненный белый 1500
Мягкий белый 2700
Теплый белый 3400
Белый 4500
Дневной белый 5600
Холодный белый 6500
Туманный белый 7500
Небесный белый 9000

I also replaced the dt value in the /www/apps/data/yandex2/lua/lib.lua file from 5 to 7
Code:
dictSkills["color_setting.temperature_k"] = {name="Температура света в кельвинах", dt=7, fields={{key="min", name="Минимальное значение", type="number"}, {key="max", name="Максимальное значение", type="number"}}}
Reply


Forum Jump: